diff --git a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.Properties.cs b/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.Properties.cs
deleted file mode 100644
index e850f0775..000000000
--- a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.Properties.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/DropShadowPanel
-
-namespace Notepads.Controls
-{
- using Windows.UI;
- using Windows.UI.Composition;
- using Windows.UI.Xaml;
-
- ///
- /// The control allows the creation of a DropShadow for any Xaml FrameworkElement in markup
- /// making it easier to add shadows to Xaml without having to directly drop down to Windows.UI.Composition APIs.
- ///
- public partial class DropShadowPanel
- {
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty BlurRadiusProperty =
- DependencyProperty.Register(nameof(BlurRadius), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(9.0, OnBlurRadiusChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ColorProperty =
- DependencyProperty.Register(nameof(Color), typeof(Color), typeof(DropShadowPanel), new PropertyMetadata(Colors.Black, OnColorChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty OffsetXProperty =
- DependencyProperty.Register(nameof(OffsetX), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetXChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty OffsetYProperty =
- DependencyProperty.Register(nameof(OffsetY), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetYChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty OffsetZProperty =
- DependencyProperty.Register(nameof(OffsetZ), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetZChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ShadowOpacityProperty =
- DependencyProperty.Register(nameof(ShadowOpacity), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(1.0, OnShadowOpacityChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty IsMaskedProperty =
- DependencyProperty.Register(nameof(IsMasked), typeof(bool), typeof(DropShadowPanel), new PropertyMetadata(true, OnIsMaskedChanged));
-
- ///
- /// Gets DropShadow. Exposes the underlying composition object to allow custom Windows.UI.Composition animations.
- ///
- public DropShadow DropShadow => _dropShadow;
-
- ///
- /// Gets or sets the mask of the underlying .
- /// Allows for a custom to be set.
- ///
- public CompositionBrush Mask
- {
- get => _dropShadow?.Mask;
-
- set
- {
- if (_dropShadow != null)
- {
- _dropShadow.Mask = value;
- }
- }
- }
-
- ///
- /// Gets or sets the blur radius of the drop shadow.
- ///
- public double BlurRadius
- {
- get => (double)GetValue(BlurRadiusProperty);
- set => SetValue(BlurRadiusProperty, value);
- }
-
- ///
- /// Gets or sets the color of the drop shadow.
- ///
- public Color Color
- {
- get => (Color)GetValue(ColorProperty);
- set => SetValue(ColorProperty, value);
- }
-
- ///
- /// Gets or sets the x offset of the drop shadow.
- ///
- public double OffsetX
- {
- get => (double)GetValue(OffsetXProperty);
- set => SetValue(OffsetXProperty, value);
- }
-
- ///
- /// Gets or sets the y offset of the drop shadow.
- ///
- public double OffsetY
- {
- get => (double)GetValue(OffsetYProperty);
- set => SetValue(OffsetYProperty, value);
- }
-
- ///
- /// Gets or sets the z offset of the drop shadow.
- ///
- public double OffsetZ
- {
- get => (double)GetValue(OffsetZProperty);
- set => SetValue(OffsetZProperty, value);
- }
-
- ///
- /// Gets or sets the opacity of the drop shadow.
- ///
- public double ShadowOpacity
- {
- get => (double)GetValue(ShadowOpacityProperty);
- set => SetValue(ShadowOpacityProperty, value);
- }
-
- ///
- /// Gets or sets a value indicating whether the panel uses an alpha mask to create a more precise shadow vs. a quicker rectangle shape.
- ///
- ///
- /// Turn this off to lose fidelity and gain performance of the panel.
- ///
- public bool IsMasked
- {
- get => (bool)GetValue(IsMaskedProperty);
- set => SetValue(IsMaskedProperty, value);
- }
-
- private static void OnBlurRadiusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnBlurRadiusChanged((double)e.NewValue);
- }
- }
-
- private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnColorChanged((Color)e.NewValue);
- }
- }
-
- private static void OnOffsetXChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnOffsetXChanged((double)e.NewValue);
- }
- }
-
- private static void OnOffsetYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnOffsetYChanged((double)e.NewValue);
- }
- }
-
- private static void OnOffsetZChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnOffsetZChanged((double)e.NewValue);
- }
- }
-
- private static void OnShadowOpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.OnShadowOpacityChanged((double)e.NewValue);
- }
- }
-
- private static void OnIsMaskedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is DropShadowPanel panel)
- {
- panel.UpdateShadowMask();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.cs b/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.cs
deleted file mode 100644
index 81a4ca10f..000000000
--- a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/DropShadowPanel
-
-namespace Notepads.Controls
-{
- using System.Numerics;
- using Windows.UI;
- using Windows.UI.Composition;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Hosting;
- using Windows.UI.Xaml.Shapes;
-
- ///
- /// The control allows the creation of a DropShadow for any Xaml FrameworkElement in markup
- /// making it easier to add shadows to Xaml without having to directly drop down to Windows.UI.Composition APIs.
- ///
- [TemplatePart(Name = PartShadow, Type = typeof(Border))]
- public partial class DropShadowPanel : ContentControl
- {
- private const string PartShadow = "ShadowElement";
-
- private readonly DropShadow _dropShadow;
- private readonly SpriteVisual _shadowVisual;
- private Border _border;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public DropShadowPanel()
- {
- DefaultStyleKey = typeof(DropShadowPanel);
-
- Compositor compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
-
- _shadowVisual = compositor.CreateSpriteVisual();
-
- _dropShadow = compositor.CreateDropShadow();
- _shadowVisual.Shadow = _dropShadow;
- }
-
- ///
- /// Update the visual state of the control when its template is changed.
- ///
- protected override void OnApplyTemplate()
- {
- _border = GetTemplateChild(PartShadow) as Border;
-
- if (_border != null)
- {
- ElementCompositionPreview.SetElementChildVisual(_border, _shadowVisual);
- }
-
- ConfigureShadowVisualForCastingElement();
-
- base.OnApplyTemplate();
- }
-
- ///
- protected override void OnContentChanged(object oldContent, object newContent)
- {
- if (oldContent != null)
- {
- if (oldContent is FrameworkElement oldElement)
- {
- oldElement.SizeChanged -= OnSizeChanged;
- }
- }
-
- if (newContent != null)
- {
- if (newContent is FrameworkElement newElement)
- {
- newElement.SizeChanged += OnSizeChanged;
- }
- }
-
- base.OnContentChanged(oldContent, newContent);
- }
-
- private void OnSizeChanged(object sender, SizeChangedEventArgs e)
- {
- UpdateShadowSize();
- }
-
- private void ConfigureShadowVisualForCastingElement()
- {
- UpdateShadowMask();
- UpdateShadowSize();
- }
-
- private void OnBlurRadiusChanged(double newValue)
- {
- if (_dropShadow != null)
- {
- _dropShadow.BlurRadius = (float)newValue;
- }
- }
-
- private void OnColorChanged(Color newValue)
- {
- if (_dropShadow != null)
- {
- _dropShadow.Color = newValue;
- }
- }
-
- private void OnOffsetXChanged(double newValue)
- {
- if (_dropShadow != null)
- {
- UpdateShadowOffset((float)newValue, _dropShadow.Offset.Y, _dropShadow.Offset.Z);
- }
- }
-
- private void OnOffsetYChanged(double newValue)
- {
- if (_dropShadow != null)
- {
- UpdateShadowOffset(_dropShadow.Offset.X, (float)newValue, _dropShadow.Offset.Z);
- }
- }
-
- private void OnOffsetZChanged(double newValue)
- {
- if (_dropShadow != null)
- {
- UpdateShadowOffset(_dropShadow.Offset.X, _dropShadow.Offset.Y, (float)newValue);
- }
- }
-
- private void OnShadowOpacityChanged(double newValue)
- {
- if (_dropShadow != null)
- {
- _dropShadow.Opacity = (float)newValue;
- }
- }
-
- private void UpdateShadowMask()
- {
- if (Content != null && IsMasked)
- {
- CompositionBrush mask = null;
-
- if (Content is Image image)
- {
- mask = image.GetAlphaMask();
- }
- else if (Content is Shape shape)
- {
- mask = shape.GetAlphaMask();
- }
- else if (Content is TextBlock textBlock)
- {
- mask = textBlock.GetAlphaMask();
- }
-
- _dropShadow.Mask = mask;
- }
- else
- {
- _dropShadow.Mask = null;
- }
- }
-
- private void UpdateShadowOffset(float x, float y, float z)
- {
- if (_dropShadow != null)
- {
- _dropShadow.Offset = new Vector3(x, y, z);
- }
- }
-
- private void UpdateShadowSize()
- {
- if (_shadowVisual != null)
- {
- Vector2 newSize = new Vector2(0, 0);
- if (Content is FrameworkElement content)
- {
- newSize = new Vector2((float)content.ActualWidth, (float)content.ActualHeight);
- }
-
- _shadowVisual.Size = newSize;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.xaml b/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.xaml
deleted file mode 100644
index d56d2d6fd..000000000
--- a/src/Notepads.Controls/DropShadowPanel/DropShadowPanel.xaml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.Data.cs b/src/Notepads.Controls/GridSplitter/GridSplitter.Data.cs
deleted file mode 100644
index 2a2f72695..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.Data.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- ///
- /// Represents the control that redistributes space between columns or rows of a Grid control.
- ///
- public partial class GridSplitter
- {
- ///
- /// Enum to indicate whether GridSplitter resizes Columns or Rows
- ///
- public enum GridResizeDirection
- {
- ///
- /// Determines whether to resize rows or columns based on its Alignment and
- /// width compared to height
- ///
- Auto,
-
- ///
- /// Resize columns when dragging Splitter.
- ///
- Columns,
-
- ///
- /// Resize rows when dragging Splitter.
- ///
- Rows
- }
-
- ///
- /// Enum to indicate what Columns or Rows the GridSplitter resizes
- ///
- public enum GridResizeBehavior
- {
- ///
- /// Determine which columns or rows to resize based on its Alignment.
- ///
- BasedOnAlignment,
-
- ///
- /// Resize the current and next Columns or Rows.
- ///
- CurrentAndNext,
-
- ///
- /// Resize the previous and current Columns or Rows.
- ///
- PreviousAndCurrent,
-
- ///
- /// Resize the previous and next Columns or Rows.
- ///
- PreviousAndNext
- }
-
- ///
- /// Enum to indicate the supported gripper cursor types.
- ///
- public enum GripperCursorType
- {
- ///
- /// Change the cursor based on the splitter direction
- ///
- Default = -1,
-
- ///
- /// Standard Arrow cursor
- ///
- Arrow,
-
- ///
- /// Standard Cross cursor
- ///
- Cross,
-
- ///
- /// Standard Custom cursor
- ///
- Custom,
-
- ///
- /// Standard Hand cursor
- ///
- Hand,
-
- ///
- /// Standard Help cursor
- ///
- Help,
-
- ///
- /// Standard IBeam cursor
- ///
- IBeam,
-
- ///
- /// Standard SizeAll cursor
- ///
- SizeAll,
-
- ///
- /// Standard SizeNortheastSouthwest cursor
- ///
- SizeNortheastSouthwest,
-
- ///
- /// Standard SizeNorthSouth cursor
- ///
- SizeNorthSouth,
-
- ///
- /// Standard SizeNorthwestSoutheast cursor
- ///
- SizeNorthwestSoutheast,
-
- ///
- /// Standard SizeWestEast cursor
- ///
- SizeWestEast,
-
- ///
- /// Standard UniversalNo cursor
- ///
- UniversalNo,
-
- ///
- /// Standard UpArrow cursor
- ///
- UpArrow,
-
- ///
- /// Standard Wait cursor
- ///
- Wait
- }
-
- ///
- /// Enum to indicate the behavior of window cursor on grid splitter hover
- ///
- public enum SplitterCursorBehavior
- {
- ///
- /// Update window cursor on Grid Splitter hover
- ///
- ChangeOnSplitterHover,
-
- ///
- /// Update window cursor on Grid Splitter Gripper hover
- ///
- ChangeOnGripperHover
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.Events.cs b/src/Notepads.Controls/GridSplitter/GridSplitter.Events.cs
deleted file mode 100644
index b57cee22c..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.Events.cs
+++ /dev/null
@@ -1,302 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- using Windows.System;
- using Windows.UI.Core;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Input;
- using Windows.UI.Xaml.Media;
-
- ///
- /// Represents the control that redistributes space between columns or rows of a Grid control.
- ///
- public partial class GridSplitter
- {
- // Symbols for GripperBar in Segoe MDL2 Assets
- private const string GripperBarVertical = "\xE784";
- private const string GripperBarHorizontal = "\xE76F";
- private const string GripperDisplayFont = "Segoe MDL2 Assets";
-
- private void GridSplitter_Loaded(object sender, RoutedEventArgs e)
- {
- _resizeDirection = GetResizeDirection();
- _resizeBehavior = GetResizeBehavior();
-
- // Adding Grip to Grid Splitter
- if (Element == default(UIElement))
- {
- CreateGripperDisplay();
- Element = _gripperDisplay;
- }
-
- if (_hoverWrapper == null)
- {
- var hoverWrapper = new GripperHoverWrapper(
- CursorBehavior == SplitterCursorBehavior.ChangeOnSplitterHover
- ? this
- : Element,
- _resizeDirection,
- GripperCursor,
- GripperCustomCursorResource);
- ManipulationStarted += hoverWrapper.SplitterManipulationStarted;
- ManipulationCompleted += hoverWrapper.SplitterManipulationCompleted;
-
- _hoverWrapper = hoverWrapper;
- }
- }
-
- private void CreateGripperDisplay()
- {
- if (_gripperDisplay == null)
- {
- _gripperDisplay = new TextBlock
- {
- FontFamily = new FontFamily(GripperDisplayFont),
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- Foreground = GripperForeground,
- Text = _resizeDirection == GridResizeDirection.Columns ? GripperBarVertical : GripperBarHorizontal
- };
- }
- }
-
- ///
- protected override void OnKeyDown(KeyRoutedEventArgs e)
- {
- var step = 1;
- var ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control);
- if (ctrl.HasFlag(CoreVirtualKeyStates.Down))
- {
- step = 5;
- }
-
- if (_resizeDirection == GridResizeDirection.Columns)
- {
- if (e.Key == VirtualKey.Left)
- {
- HorizontalMove(-step);
- }
- else if (e.Key == VirtualKey.Right)
- {
- HorizontalMove(step);
- }
- else
- {
- return;
- }
-
- e.Handled = true;
- return;
- }
-
- if (_resizeDirection == GridResizeDirection.Rows)
- {
- if (e.Key == VirtualKey.Up)
- {
- VerticalMove(-step);
- }
- else if (e.Key == VirtualKey.Down)
- {
- VerticalMove(step);
- }
- else
- {
- return;
- }
-
- e.Handled = true;
- }
-
- base.OnKeyDown(e);
- }
-
- ///
- protected override void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
- {
- // saving the previous state
- PreviousCursor = Window.Current.CoreWindow.PointerCursor;
- _resizeDirection = GetResizeDirection();
- _resizeBehavior = GetResizeBehavior();
-
- if (_resizeDirection == GridResizeDirection.Columns)
- {
- Window.Current.CoreWindow.PointerCursor = ColumnsSplitterCursor;
- }
- else if (_resizeDirection == GridResizeDirection.Rows)
- {
- Window.Current.CoreWindow.PointerCursor = RowSplitterCursor;
- }
-
- base.OnManipulationStarted(e);
- }
-
- ///
- protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e)
- {
- Window.Current.CoreWindow.PointerCursor = PreviousCursor;
-
- base.OnManipulationCompleted(e);
- }
-
- ///
- protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e)
- {
- var horizontalChange = e.Delta.Translation.X;
- var verticalChange = e.Delta.Translation.Y;
-
- if (_resizeDirection == GridResizeDirection.Columns)
- {
- if (HorizontalMove(horizontalChange))
- {
- return;
- }
- }
- else if (_resizeDirection == GridResizeDirection.Rows)
- {
- if (VerticalMove(verticalChange))
- {
- return;
- }
- }
-
- base.OnManipulationDelta(e);
- }
-
- private bool VerticalMove(double verticalChange)
- {
- if (CurrentRow == null || SiblingRow == null)
- {
- return true;
- }
-
- // if current row has fixed height then resize it
- if (!IsStarRow(CurrentRow))
- {
- // No need to check for the row Min height because it is automatically respected
- if (!SetRowHeight(CurrentRow, verticalChange, GridUnitType.Pixel))
- {
- return true;
- }
- }
-
- // if sibling row has fixed width then resize it
- else if (!IsStarRow(SiblingRow))
- {
- // Would adding to this column make the current column violate the MinWidth?
- if (IsValidRowHeight(CurrentRow, verticalChange) == false)
- {
- return false;
- }
-
- if (!SetRowHeight(SiblingRow, verticalChange * -1, GridUnitType.Pixel))
- {
- return true;
- }
- }
-
- // if both row haven't fixed height (auto *)
- else
- {
- // change current row height to the new height with respecting the auto
- // change sibling row height to the new height relative to current row
- // respect the other star row height by setting it's height to it's actual height with stars
-
- // We need to validate current and sibling height to not cause any un expected behavior
- if (!IsValidRowHeight(CurrentRow, verticalChange) ||
- !IsValidRowHeight(SiblingRow, verticalChange * -1))
- {
- return true;
- }
-
- foreach (var rowDefinition in Resizable.RowDefinitions)
- {
- if (rowDefinition == CurrentRow)
- {
- SetRowHeight(CurrentRow, verticalChange, GridUnitType.Star);
- }
- else if (rowDefinition == SiblingRow)
- {
- SetRowHeight(SiblingRow, verticalChange * -1, GridUnitType.Star);
- }
- else if (IsStarRow(rowDefinition))
- {
- rowDefinition.Height = new GridLength(rowDefinition.ActualHeight, GridUnitType.Star);
- }
- }
- }
-
- return false;
- }
-
- private bool HorizontalMove(double horizontalChange)
- {
- if (CurrentColumn == null || SiblingColumn == null)
- {
- return true;
- }
-
- // if current column has fixed width then resize it
- if (!IsStarColumn(CurrentColumn))
- {
- // No need to check for the Column Min width because it is automatically respected
- if (!SetColumnWidth(CurrentColumn, horizontalChange, GridUnitType.Pixel))
- {
- return true;
- }
- }
-
- // if sibling column has fixed width then resize it
- else if (!IsStarColumn(SiblingColumn))
- {
- // Would adding to this column make the current column violate the MinWidth?
- if (IsValidColumnWidth(CurrentColumn, horizontalChange) == false)
- {
- return false;
- }
-
- if (!SetColumnWidth(SiblingColumn, horizontalChange * -1, GridUnitType.Pixel))
- {
- return true;
- }
- }
-
- // if both column haven't fixed width (auto *)
- else
- {
- // change current column width to the new width with respecting the auto
- // change sibling column width to the new width relative to current column
- // respect the other star column width by setting it's width to it's actual width with stars
-
- // We need to validate current and sibling width to not cause any un expected behavior
- if (!IsValidColumnWidth(CurrentColumn, horizontalChange) ||
- !IsValidColumnWidth(SiblingColumn, horizontalChange * -1))
- {
- return true;
- }
-
- foreach (var columnDefinition in Resizable.ColumnDefinitions)
- {
- if (columnDefinition == CurrentColumn)
- {
- SetColumnWidth(CurrentColumn, horizontalChange, GridUnitType.Star);
- }
- else if (columnDefinition == SiblingColumn)
- {
- SetColumnWidth(SiblingColumn, horizontalChange * -1, GridUnitType.Star);
- }
- else if (IsStarColumn(columnDefinition))
- {
- columnDefinition.Width = new GridLength(columnDefinition.ActualWidth, GridUnitType.Star);
- }
- }
- }
-
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.Helper.cs b/src/Notepads.Controls/GridSplitter/GridSplitter.Helper.cs
deleted file mode 100644
index 1c53cf135..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.Helper.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
-
- ///
- /// Represents the control that redistributes space between columns or rows of a Grid control.
- ///
- public partial class GridSplitter
- {
- private static bool IsStarColumn(ColumnDefinition definition)
- {
- return ((GridLength)definition.GetValue(ColumnDefinition.WidthProperty)).IsStar;
- }
-
- private static bool IsStarRow(RowDefinition definition)
- {
- return ((GridLength)definition.GetValue(RowDefinition.HeightProperty)).IsStar;
- }
-
- private bool SetColumnWidth(ColumnDefinition columnDefinition, double horizontalChange, GridUnitType unitType)
- {
- var newWidth = columnDefinition.ActualWidth + horizontalChange;
-
- var minWidth = columnDefinition.MinWidth;
- if (!double.IsNaN(minWidth) && newWidth < minWidth)
- {
- newWidth = minWidth;
- }
-
- var maxWidth = columnDefinition.MaxWidth;
- if (!double.IsNaN(maxWidth) && newWidth > maxWidth)
- {
- newWidth = maxWidth;
- }
-
- if (newWidth > ActualWidth)
- {
- columnDefinition.Width = new GridLength(newWidth, unitType);
- return true;
- }
-
- return false;
- }
-
- private bool IsValidColumnWidth(ColumnDefinition columnDefinition, double horizontalChange)
- {
- var newWidth = columnDefinition.ActualWidth + horizontalChange;
-
- var minWidth = columnDefinition.MinWidth;
- if (!double.IsNaN(minWidth) && newWidth < minWidth)
- {
- return false;
- }
-
- var maxWidth = columnDefinition.MaxWidth;
- if (!double.IsNaN(maxWidth) && newWidth > maxWidth)
- {
- return false;
- }
-
- if (newWidth <= ActualWidth)
- {
- return false;
- }
-
- return true;
- }
-
- private bool SetRowHeight(RowDefinition rowDefinition, double verticalChange, GridUnitType unitType)
- {
- var newHeight = rowDefinition.ActualHeight + verticalChange;
-
- var minHeight = rowDefinition.MinHeight;
- if (!double.IsNaN(minHeight) && newHeight < minHeight)
- {
- newHeight = minHeight;
- }
-
- var maxWidth = rowDefinition.MaxHeight;
- if (!double.IsNaN(maxWidth) && newHeight > maxWidth)
- {
- newHeight = maxWidth;
- }
-
- if (newHeight > ActualHeight)
- {
- rowDefinition.Height = new GridLength(newHeight, unitType);
- return true;
- }
-
- return false;
- }
-
- private bool IsValidRowHeight(RowDefinition rowDefinition, double verticalChange)
- {
- var newHeight = rowDefinition.ActualHeight + verticalChange;
-
- var minHeight = rowDefinition.MinHeight;
- if (!double.IsNaN(minHeight) && newHeight < minHeight)
- {
- return false;
- }
-
- var maxHeight = rowDefinition.MaxHeight;
- if (!double.IsNaN(maxHeight) && newHeight > maxHeight)
- {
- return false;
- }
-
- if (newHeight <= ActualHeight)
- {
- return false;
- }
-
- return true;
- }
-
- // Return the targeted Column based on the resize behavior
- private int GetTargetedColumn()
- {
- var currentIndex = Grid.GetColumn(TargetControl);
- return GetTargetIndex(currentIndex);
- }
-
- // Return the sibling Row based on the resize behavior
- private int GetTargetedRow()
- {
- var currentIndex = Grid.GetRow(TargetControl);
- return GetTargetIndex(currentIndex);
- }
-
- // Return the sibling Column based on the resize behavior
- private int GetSiblingColumn()
- {
- var currentIndex = Grid.GetColumn(TargetControl);
- return GetSiblingIndex(currentIndex);
- }
-
- // Return the sibling Row based on the resize behavior
- private int GetSiblingRow()
- {
- var currentIndex = Grid.GetRow(TargetControl);
- return GetSiblingIndex(currentIndex);
- }
-
- // Gets index based on resize behavior for first targeted row/column
- private int GetTargetIndex(int currentIndex)
- {
- switch (_resizeBehavior)
- {
- case GridResizeBehavior.CurrentAndNext:
- return currentIndex;
- case GridResizeBehavior.PreviousAndNext:
- return currentIndex - 1;
- case GridResizeBehavior.PreviousAndCurrent:
- return currentIndex - 1;
- default:
- return -1;
- }
- }
-
- // Gets index based on resize behavior for second targeted row/column
- private int GetSiblingIndex(int currentIndex)
- {
- switch (_resizeBehavior)
- {
- case GridResizeBehavior.CurrentAndNext:
- return currentIndex + 1;
- case GridResizeBehavior.PreviousAndNext:
- return currentIndex + 1;
- case GridResizeBehavior.PreviousAndCurrent:
- return currentIndex;
- default:
- return -1;
- }
- }
-
- // Checks the control alignment and Width/Height to detect the control resize direction columns/rows
- private GridResizeDirection GetResizeDirection()
- {
- GridResizeDirection direction = ResizeDirection;
-
- if (direction == GridResizeDirection.Auto)
- {
- // When HorizontalAlignment is Left, Right or Center, resize Columns
- if (HorizontalAlignment != HorizontalAlignment.Stretch)
- {
- direction = GridResizeDirection.Columns;
- }
-
- // When VerticalAlignment is Top, Bottom or Center, resize Rows
- else if (VerticalAlignment != VerticalAlignment.Stretch)
- {
- direction = GridResizeDirection.Rows;
- }
-
- // Check Width vs Height
- else if (ActualWidth <= ActualHeight)
- {
- direction = GridResizeDirection.Columns;
- }
- else
- {
- direction = GridResizeDirection.Rows;
- }
- }
-
- return direction;
- }
-
- // Get the resize behavior (Which columns/rows should be resized) based on alignment and Direction
- private GridResizeBehavior GetResizeBehavior()
- {
- GridResizeBehavior resizeBehavior = ResizeBehavior;
-
- if (resizeBehavior == GridResizeBehavior.BasedOnAlignment)
- {
- if (_resizeDirection == GridResizeDirection.Columns)
- {
- switch (HorizontalAlignment)
- {
- case HorizontalAlignment.Left:
- resizeBehavior = GridResizeBehavior.PreviousAndCurrent;
- break;
- case HorizontalAlignment.Right:
- resizeBehavior = GridResizeBehavior.CurrentAndNext;
- break;
- default:
- resizeBehavior = GridResizeBehavior.PreviousAndNext;
- break;
- }
- }
-
- // resize direction is vertical
- else
- {
- switch (VerticalAlignment)
- {
- case VerticalAlignment.Top:
- resizeBehavior = GridResizeBehavior.PreviousAndCurrent;
- break;
- case VerticalAlignment.Bottom:
- resizeBehavior = GridResizeBehavior.CurrentAndNext;
- break;
- default:
- resizeBehavior = GridResizeBehavior.PreviousAndNext;
- break;
- }
- }
- }
-
- return resizeBehavior;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.Options.cs b/src/Notepads.Controls/GridSplitter/GridSplitter.Options.cs
deleted file mode 100644
index aab678ba4..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.Options.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- using Windows.UI.Core;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Media;
-
- ///
- /// Represents the control that redistributes space between columns or rows of a Grid control.
- ///
- public partial class GridSplitter
- {
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ElementProperty
- = DependencyProperty.Register(
- nameof(Element),
- typeof(UIElement),
- typeof(GridSplitter),
- new PropertyMetadata(default(UIElement), OnElementPropertyChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ResizeDirectionProperty
- = DependencyProperty.Register(
- nameof(ResizeDirection),
- typeof(GridResizeDirection),
- typeof(GridSplitter),
- new PropertyMetadata(GridResizeDirection.Auto));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ResizeBehaviorProperty
- = DependencyProperty.Register(
- nameof(ResizeBehavior),
- typeof(GridResizeBehavior),
- typeof(GridSplitter),
- new PropertyMetadata(GridResizeBehavior.BasedOnAlignment));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty GripperForegroundProperty
- = DependencyProperty.Register(
- nameof(GripperForeground),
- typeof(Brush),
- typeof(GridSplitter),
- new PropertyMetadata(default(Brush), OnGripperForegroundPropertyChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty ParentLevelProperty
- = DependencyProperty.Register(
- nameof(ParentLevel),
- typeof(int),
- typeof(GridSplitter),
- new PropertyMetadata(default(int)));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty GripperCursorProperty =
- DependencyProperty.RegisterAttached(
- nameof(GripperCursor),
- typeof(CoreCursorType?),
- typeof(GridSplitter),
- new PropertyMetadata(GripperCursorType.Default, OnGripperCursorPropertyChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty GripperCustomCursorResourceProperty =
- DependencyProperty.RegisterAttached(
- nameof(GripperCustomCursorResource),
- typeof(uint),
- typeof(GridSplitter),
- new PropertyMetadata(GripperCustomCursorDefaultResource, GripperCustomCursorResourcePropertyChanged));
-
- ///
- /// Identifies the dependency property.
- ///
- public static readonly DependencyProperty CursorBehaviorProperty =
- DependencyProperty.RegisterAttached(
- nameof(CursorBehavior),
- typeof(SplitterCursorBehavior),
- typeof(GridSplitter),
- new PropertyMetadata(SplitterCursorBehavior.ChangeOnSplitterHover, CursorBehaviorPropertyChanged));
-
- ///
- /// Gets or sets the visual content of this Grid Splitter
- ///
- public UIElement Element
- {
- get => (UIElement)GetValue(ElementProperty);
- set => SetValue(ElementProperty, value);
- }
-
- ///
- /// Gets or sets whether the Splitter resizes the Columns, Rows, or Both.
- ///
- public GridResizeDirection ResizeDirection
- {
- get => (GridResizeDirection)GetValue(ResizeDirectionProperty);
- set => SetValue(ResizeDirectionProperty, value);
- }
-
- ///
- /// Gets or sets which Columns or Rows the Splitter resizes.
- ///
- public GridResizeBehavior ResizeBehavior
- {
- get => (GridResizeBehavior)GetValue(ResizeBehaviorProperty);
- set => SetValue(ResizeBehaviorProperty, value);
- }
-
- ///
- /// Gets or sets the foreground color of grid splitter grip
- ///
- public Brush GripperForeground
- {
- get => (Brush)GetValue(GripperForegroundProperty);
- set => SetValue(GripperForegroundProperty, value);
- }
-
- ///
- /// Gets or sets the level of the parent grid to resize
- ///
- public int ParentLevel
- {
- get => (int)GetValue(ParentLevelProperty);
- set => SetValue(ParentLevelProperty, value);
- }
-
- ///
- /// Gets or sets the gripper Cursor type
- ///
- public GripperCursorType GripperCursor
- {
- get => (GripperCursorType)GetValue(GripperCursorProperty);
- set => SetValue(GripperCursorProperty, value);
- }
-
- ///
- /// Gets or sets the gripper Custom Cursor resource number
- ///
- public int GripperCustomCursorResource
- {
- get => (int)GetValue(GripperCustomCursorResourceProperty);
- set => SetValue(GripperCustomCursorResourceProperty, value);
- }
-
- ///
- /// Gets or sets splitter cursor on hover behavior
- ///
- public SplitterCursorBehavior CursorBehavior
- {
- get => (SplitterCursorBehavior)GetValue(CursorBehaviorProperty);
- set => SetValue(CursorBehaviorProperty, value);
- }
-
- private static void OnGripperForegroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var gridSplitter = (GridSplitter)d;
-
- if (gridSplitter._gripperDisplay == null)
- {
- return;
- }
-
- gridSplitter._gripperDisplay.Foreground = gridSplitter.GripperForeground;
- }
-
- private static void OnGripperCursorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var gridSplitter = (GridSplitter)d;
-
- if (gridSplitter._hoverWrapper == null)
- {
- return;
- }
-
- gridSplitter._hoverWrapper.GripperCursor = gridSplitter.GripperCursor;
- }
-
- private static void GripperCustomCursorResourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var gridSplitter = (GridSplitter)d;
-
- if (gridSplitter._hoverWrapper == null)
- {
- return;
- }
-
- gridSplitter._hoverWrapper.GripperCustomCursorResource = gridSplitter.GripperCustomCursorResource;
- }
-
- private static void CursorBehaviorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var gridSplitter = (GridSplitter)d;
-
- gridSplitter._hoverWrapper?.UpdateHoverElement(gridSplitter.CursorBehavior ==
- SplitterCursorBehavior.ChangeOnSplitterHover
- ? gridSplitter
- : gridSplitter.Element);
- }
-
- private static void OnElementPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var gridSplitter = (GridSplitter)d;
-
- gridSplitter._hoverWrapper?.UpdateHoverElement(gridSplitter.CursorBehavior ==
- SplitterCursorBehavior.ChangeOnSplitterHover
- ? gridSplitter
- : gridSplitter.Element);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.cs b/src/Notepads.Controls/GridSplitter/GridSplitter.cs
deleted file mode 100644
index e65946dc2..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- using Windows.UI.Core;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Automation;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Input;
-
- ///
- /// Represents the control that redistributes space between columns or rows of a Grid control.
- ///
- public partial class GridSplitter : Control
- {
- internal const int GripperCustomCursorDefaultResource = -1;
- internal static readonly CoreCursor ColumnsSplitterCursor = new CoreCursor(CoreCursorType.SizeWestEast, 1);
- internal static readonly CoreCursor RowSplitterCursor = new CoreCursor(CoreCursorType.SizeNorthSouth, 1);
-
- internal CoreCursor PreviousCursor { get; set; }
-
- private GridResizeDirection _resizeDirection;
- private GridResizeBehavior _resizeBehavior;
- private GripperHoverWrapper _hoverWrapper;
- private TextBlock _gripperDisplay;
-
- private bool _pressed = false;
- private bool _dragging = false;
- private bool _pointerEntered = false;
-
- ///
- /// Gets the target parent grid from level
- ///
- private FrameworkElement TargetControl
- {
- get
- {
- if (ParentLevel == 0)
- {
- return this;
- }
-
- var parent = Parent;
- for (int i = 2; i < ParentLevel; i++)
- {
- if (parent is FrameworkElement frameworkElement)
- {
- parent = frameworkElement.Parent;
- }
- }
-
- return parent as FrameworkElement;
- }
- }
-
- ///
- /// Gets GridSplitter Container Grid
- ///
- private Grid Resizable => TargetControl?.Parent as Grid;
-
- ///
- /// Gets the current Column definition of the parent Grid
- ///
- private ColumnDefinition CurrentColumn
- {
- get
- {
- if (Resizable == null)
- {
- return null;
- }
-
- var gridSplitterTargetedColumnIndex = GetTargetedColumn();
-
- if ((gridSplitterTargetedColumnIndex >= 0)
- && (gridSplitterTargetedColumnIndex < Resizable.ColumnDefinitions.Count))
- {
- return Resizable.ColumnDefinitions[gridSplitterTargetedColumnIndex];
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the Sibling Column definition of the parent Grid
- ///
- private ColumnDefinition SiblingColumn
- {
- get
- {
- if (Resizable == null)
- {
- return null;
- }
-
- var gridSplitterSiblingColumnIndex = GetSiblingColumn();
-
- if ((gridSplitterSiblingColumnIndex >= 0)
- && (gridSplitterSiblingColumnIndex < Resizable.ColumnDefinitions.Count))
- {
- return Resizable.ColumnDefinitions[gridSplitterSiblingColumnIndex];
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the current Row definition of the parent Grid
- ///
- private RowDefinition CurrentRow
- {
- get
- {
- if (Resizable == null)
- {
- return null;
- }
-
- var gridSplitterTargetedRowIndex = GetTargetedRow();
-
- if ((gridSplitterTargetedRowIndex >= 0)
- && (gridSplitterTargetedRowIndex < Resizable.RowDefinitions.Count))
- {
- return Resizable.RowDefinitions[gridSplitterTargetedRowIndex];
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the Sibling Row definition of the parent Grid
- ///
- private RowDefinition SiblingRow
- {
- get
- {
- if (Resizable == null)
- {
- return null;
- }
-
- var gridSplitterSiblingRowIndex = GetSiblingRow();
-
- if ((gridSplitterSiblingRowIndex >= 0)
- && (gridSplitterSiblingRowIndex < Resizable.RowDefinitions.Count))
- {
- return Resizable.RowDefinitions[gridSplitterSiblingRowIndex];
- }
-
- return null;
- }
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public GridSplitter()
- {
- DefaultStyleKey = typeof(GridSplitter);
- Loaded += GridSplitter_Loaded;
- string automationName = "GridSpliter";
- AutomationProperties.SetName(this, automationName);
- }
-
- ///
- protected override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
-
- // Unhook registered events
- Loaded -= GridSplitter_Loaded;
- PointerEntered -= GridSplitter_PointerEntered;
- PointerExited -= GridSplitter_PointerExited;
- PointerPressed -= GridSplitter_PointerPressed;
- PointerReleased -= GridSplitter_PointerReleased;
- ManipulationStarted -= GridSplitter_ManipulationStarted;
- ManipulationCompleted -= GridSplitter_ManipulationCompleted;
-
- _hoverWrapper?.UnhookEvents();
-
- // Register Events
- Loaded += GridSplitter_Loaded;
- PointerEntered += GridSplitter_PointerEntered;
- PointerExited += GridSplitter_PointerExited;
- PointerPressed += GridSplitter_PointerPressed;
- PointerReleased += GridSplitter_PointerReleased;
- ManipulationStarted += GridSplitter_ManipulationStarted;
- ManipulationCompleted += GridSplitter_ManipulationCompleted;
-
- _hoverWrapper?.UpdateHoverElement(Element);
-
- ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
- }
-
- private void GridSplitter_PointerReleased(object sender, PointerRoutedEventArgs e)
- {
- _pressed = false;
- VisualStateManager.GoToState(this, _pointerEntered ? "PointerOver" : "Normal", true);
- }
-
- private void GridSplitter_PointerPressed(object sender, PointerRoutedEventArgs e)
- {
- _pressed = true;
- VisualStateManager.GoToState(this, "Pressed", true);
- }
-
- private void GridSplitter_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- _pointerEntered = false;
-
- if (!_pressed && !_dragging)
- {
- VisualStateManager.GoToState(this, "Normal", true);
- }
- }
-
- private void GridSplitter_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- _pointerEntered = true;
-
- if (!_pressed && !_dragging)
- {
- VisualStateManager.GoToState(this, "PointerOver", true);
- }
- }
-
- private void GridSplitter_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
- {
- _dragging = false;
- _pressed = false;
- VisualStateManager.GoToState(this, _pointerEntered ? "PointerOver" : "Normal", true);
- }
-
- private void GridSplitter_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
- {
- _dragging = true;
- VisualStateManager.GoToState(this, "Pressed", true);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/GridSplitter/GridSplitter.xaml b/src/Notepads.Controls/GridSplitter/GridSplitter.xaml
deleted file mode 100644
index 02242fe7d..000000000
--- a/src/Notepads.Controls/GridSplitter/GridSplitter.xaml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Notepads.Controls/GridSplitter/GripperHoverWrapper.cs b/src/Notepads.Controls/GridSplitter/GripperHoverWrapper.cs
deleted file mode 100644
index d806e268a..000000000
--- a/src/Notepads.Controls/GridSplitter/GripperHoverWrapper.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter
-
-namespace Notepads.Controls
-{
- using Windows.UI.Core;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Input;
-
- internal class GripperHoverWrapper
- {
- private readonly GridSplitter.GridResizeDirection _gridSplitterDirection;
-
- private CoreCursor _splitterPreviousPointer;
- private CoreCursor _previousCursor;
- private GridSplitter.GripperCursorType _gripperCursor;
- private int _gripperCustomCursorResource;
- private bool _isDragging;
- private UIElement _element;
-
- internal GridSplitter.GripperCursorType GripperCursor
- {
- get => _gripperCursor;
- set => _gripperCursor = value;
- }
-
- internal int GripperCustomCursorResource
- {
- get => _gripperCustomCursorResource;
- set => _gripperCustomCursorResource = value;
- }
-
- ///
- /// Initializes a new instance of the class that add cursor change on hover functionality for GridSplitter.
- ///
- /// UI element to apply cursor change on hover
- /// GridSplitter resize direction
- /// GridSplitter gripper on hover cursor type
- /// GridSplitter gripper custom cursor resource number
- internal GripperHoverWrapper(UIElement element, GridSplitter.GridResizeDirection gridSplitterDirection, GridSplitter.GripperCursorType gripperCursor, int gripperCustomCursorResource)
- {
- _gridSplitterDirection = gridSplitterDirection;
- _gripperCursor = gripperCursor;
- _gripperCustomCursorResource = gripperCustomCursorResource;
- _element = element;
- UnhookEvents();
- _element.PointerEntered += Element_PointerEntered;
- _element.PointerExited += Element_PointerExited;
- }
-
- internal void UpdateHoverElement(UIElement element)
- {
- UnhookEvents();
- _element = element;
- _element.PointerEntered += Element_PointerEntered;
- _element.PointerExited += Element_PointerExited;
- }
-
- private void Element_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- if (_isDragging)
- {
- // if dragging don't update the curser just update the splitter cursor with the last window cursor,
- // because the splitter is still using the arrow cursor and will revert to original case when drag completes
- _splitterPreviousPointer = _previousCursor;
- }
- else
- {
- Window.Current.CoreWindow.PointerCursor = _previousCursor;
- }
- }
-
- private void Element_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- // if not dragging
- if (!_isDragging)
- {
- _previousCursor = _splitterPreviousPointer = Window.Current.CoreWindow.PointerCursor;
- UpdateDisplayCursor();
- }
-
- // if dragging
- else
- {
- _previousCursor = _splitterPreviousPointer;
- }
- }
-
- private void UpdateDisplayCursor()
- {
- if (_gripperCursor == GridSplitter.GripperCursorType.Default)
- {
- if (_gridSplitterDirection == GridSplitter.GridResizeDirection.Columns)
- {
- Window.Current.CoreWindow.PointerCursor = GridSplitter.ColumnsSplitterCursor;
- }
- else if (_gridSplitterDirection == GridSplitter.GridResizeDirection.Rows)
- {
- Window.Current.CoreWindow.PointerCursor = GridSplitter.RowSplitterCursor;
- }
- }
- else
- {
- var coreCursor = (CoreCursorType)((int)_gripperCursor);
- if (_gripperCursor == GridSplitter.GripperCursorType.Custom)
- {
- if (_gripperCustomCursorResource > GridSplitter.GripperCustomCursorDefaultResource)
- {
- Window.Current.CoreWindow.PointerCursor = new CoreCursor(coreCursor, (uint)_gripperCustomCursorResource);
- }
- }
- else
- {
- Window.Current.CoreWindow.PointerCursor = new CoreCursor(coreCursor, 1);
- }
- }
- }
-
- internal void SplitterManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
- {
- if (!(sender is GridSplitter splitter))
- {
- return;
- }
-
- _splitterPreviousPointer = splitter.PreviousCursor;
- _isDragging = true;
- }
-
- internal void SplitterManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
- {
- if (!(sender is GridSplitter splitter))
- {
- return;
- }
-
- Window.Current.CoreWindow.PointerCursor = splitter.PreviousCursor = _splitterPreviousPointer;
- _isDragging = false;
- }
-
- internal void UnhookEvents()
- {
- if (_element == null)
- {
- return;
- }
-
- _element.PointerEntered -= Element_PointerEntered;
- _element.PointerExited -= Element_PointerExited;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Notepads.Controls/Helpers/DispatcherQueueHelper.cs b/src/Notepads.Controls/Helpers/DispatcherQueueHelper.cs
deleted file mode 100644
index 5eb2f3478..000000000
--- a/src/Notepads.Controls/Helpers/DispatcherQueueHelper.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// Source: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/8464f8e5263686c1484732bdea86ebba3f30a075/Microsoft.Toolkit.Uwp/Helpers/DispatcherQueueHelper.cs
-
-namespace Notepads.Controls.Helpers
-{
- using System;
- using System.Threading.Tasks;
- using Windows.System;
-
- ///
- /// This class provides static methods helper for executing code in a DispatcherQueue.
- ///
- public static class DispatcherQueueHelper
- {
- ///
- /// Extension method for . Offering an actual awaitable with optional result that will be executed on the given dispatcher.
- ///
- /// DispatcherQueue of a thread to run .
- /// Function to be executed on the given dispatcher.
- /// DispatcherQueue execution priority, default is normal.
- /// An awaitable for the operation.
- /// If the current thread has UI access, will be invoked directly.
- public static Task ExecuteOnUIThreadAsync(this DispatcherQueue dispatcher, Action function, DispatcherQueuePriority priority = DispatcherQueuePriority.Normal)
- {
- if (function is null)
- {
- throw new ArgumentNullException(nameof(function));
- }
-
- /* Run the function directly when we have thread access.
- * Also reuse Task.CompletedTask in case of success,
- * to skip an unnecessary heap allocation for every invocation. */
-
- // Ignoring for now, but need to map the CurrentThreadID for all dispatcher queue code we have
- /*
- if (dispatcher.HasThreadAccess)
- {
- try
- {
- function();
-
- return Task.CompletedTask;
- }
- catch (Exception e)
- {
- return Task.FromException(e);
- }
- }
- */
-
- var taskCompletionSource = new TaskCompletionSource