[Add] Options to turn two finger scale, rotate and translate on and off

This commit is contained in:
XY Wang 2023-11-14 18:48:04 +08:00
parent 40a4b9905a
commit 6eb75e9775
3 changed files with 35 additions and 15 deletions

View File

@ -441,6 +441,7 @@
<GroupBox Header="手势">
<ui:SimpleStackPanel Spacing="12">
<ui:ToggleSwitch Name="ToggleSwitchEnableTwoFingerZoom" Header="允许双指缩放" FontFamily="Microsoft YaHei UI" IsOn="True" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableTwoFingerZoom_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchEnableTwoFingerTranslate" Header="允许双指移动" FontFamily="Microsoft YaHei UI" IsOn="True" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableTwoFingerTranslate_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchEnableTwoFingerRotation" Header="允许双指旋转" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableTwoFingerRotation_Toggled"/>
<TextBlock Text="允许选中墨迹后对墨迹进行双指或多指缩放操作(此设置不受“允许双指旋转”设置的影响)" TextWrapping="Wrap" Foreground="#666666"/>
<ui:ToggleSwitch Name="ToggleSwitchEnableTwoFingerRotationOnSelection" Header="允许双指旋转选中的墨迹" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableTwoFingerRotation_Toggled"/>

View File

@ -1878,9 +1878,9 @@ namespace Ink_Canvas
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
}
//设备两个及两个以上,将画笔功能关闭
if (dec.Count > 1 || isSingleFingerDragMode || !Settings.Gesture.IsEnableTwoFingerZoom)
if (dec.Count > 1 || isSingleFingerDragMode || !Settings.Gesture.IsEnableTwoFingerGesture)
{
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerZoom) return;
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
if (inkCanvas.EditingMode != InkCanvasEditingMode.None && inkCanvas.EditingMode != InkCanvasEditingMode.Select)
{
lastInkCanvasEditingMode = inkCanvas.EditingMode;
@ -1936,7 +1936,7 @@ namespace Ink_Canvas
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerZoom) return;
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
if ((dec.Count >= 2 && (Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode || StackPanelPPTControls.Visibility != Visibility.Visible || StackPanelPPTButtons.Visibility == Visibility.Collapsed)) || isSingleFingerDragMode)
{
ManipulationDelta md = e.DeltaManipulation;
@ -1952,12 +1952,12 @@ namespace Ink_Canvas
center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
// Update matrix to reflect translation/rotation
m.Translate(trans.X, trans.Y); // 移动
if (Settings.Gesture.IsEnableTwoFingerTranslate)
m.Translate(trans.X, trans.Y); // 移动
if (Settings.Gesture.IsEnableTwoFingerRotation)
{
m.RotateAt(rotate, center.X, center.Y); // 旋转
}
m.ScaleAt(scale.X, scale.Y, center.X, center.Y); // 缩放
if (Settings.Gesture.IsEnableTwoFingerZoom)
m.ScaleAt(scale.X, scale.Y, center.X, center.Y); // 缩放
StrokeCollection strokes = inkCanvas.GetSelectedStrokes();
if (strokes.Count != 0)
@ -1977,12 +1977,15 @@ namespace Ink_Canvas
}
}
try
if (Settings.Gesture.IsEnableTwoFingerZoom)
{
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
try
{
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
}
catch { }
}
catch { }
}
}
else
@ -1991,12 +1994,15 @@ namespace Ink_Canvas
{
stroke.Transform(m, false);
try
if (Settings.Gesture.IsEnableTwoFingerZoom)
{
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
try
{
stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y;
}
catch { }
}
catch { }
}
foreach (Circle circle in circles)
{
@ -3059,6 +3065,15 @@ namespace Ink_Canvas
SaveSettingsToFile();
}
private void ToggleSwitchEnableTwoFingerTranslate_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Gesture.IsEnableTwoFingerTranslate = ToggleSwitchEnableTwoFingerTranslate.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchEnableTwoFingerRotation_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;

View File

@ -53,8 +53,12 @@ namespace Ink_Canvas
public class Gesture
{
[JsonIgnore]
public bool IsEnableTwoFingerGesture => IsEnableTwoFingerZoom || IsEnableTwoFingerTranslate || IsEnableTwoFingerRotation;
[JsonProperty("isEnableTwoFingerZoom")]
public bool IsEnableTwoFingerZoom { get; set; } = true;
[JsonProperty("isEnableTwoFingerTranslate")]
public bool IsEnableTwoFingerTranslate { get; set; } = true;
[JsonProperty("isEnableTwoFingerRotation")]
public bool IsEnableTwoFingerRotation { get; set; } = false;
[JsonProperty("isEnableTwoFingerRotationOnSelection")]