[feat] 新增橡皮模式

Fix #79
This commit is contained in:
kengwang 2023-07-15 15:28:10 +08:00
parent b2b8f56477
commit bb65a7888b
No known key found for this signature in database
GPG Key ID: 9ED4CB8A0CF42B18
3 changed files with 44 additions and 3 deletions

View File

@ -414,6 +414,12 @@
</ComboBox>
<ui:ToggleSwitch Header="手指模式" IsOn="{Binding ElementName=ToggleSwitchModeFinger, Path=IsOn}" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关"/>
<TextBlock Text="此选项仅适用于可获取触摸面积的屏幕" TextWrapping="Wrap" Foreground="#666666"/>
<TextBlock Text="橡皮模式" FontFamily="Microsoft YaHei UI" FontSize="14"/>
<ComboBox Name="ComboBoxEraserType" FontFamily="Microsoft YaHei UI" SelectedIndex="0" SelectionChanged="ComboBoxEraserType_OnSelectionChanged">
<ComboBoxItem Content="交叉切换" FontFamily="Microsoft YaHei UI"/>
<ComboBoxItem Content="面积擦" FontFamily="Microsoft YaHei UI"/>
<ComboBoxItem Content="笔画擦" FontFamily="Microsoft YaHei UI"/>
</ComboBox>
<TextBlock Text="橡皮大小" FontFamily="Microsoft YaHei UI" FontSize="14"/>
<ComboBox Name="ComboBoxEraserSize" FontFamily="Microsoft YaHei UI" SelectedIndex="2" SelectionChanged="ComboBoxEraserSize_SelectionChanged">
<ComboBoxItem Content="小" FontFamily="Microsoft YaHei UI"/>

View File

@ -906,6 +906,19 @@ namespace Ink_Canvas
BtnSwitchTheme.Content = "深色";
BtnSwitchTheme_Click(null, null);
}
switch (Settings.Canvas.EraserType)
{
case 1:
forcePointEraser = true;
break;
case 2:
forcePointEraser = false;
break;
}
ComboBoxEraserType.SelectedIndex = Settings.Canvas.EraserType;
if (Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
{
ToggleSwitchAutoSaveScreenShotInPowerPoint.IsOn = true;
@ -1014,10 +1027,22 @@ namespace Ink_Canvas
{
forceEraser = true;
forcePointEraser = !forcePointEraser;
inkCanvas.EditingMode = forcePointEraser ? InkCanvasEditingMode.EraseByPoint : InkCanvasEditingMode.EraseByStroke;
switch (Settings.Canvas.EraserType)
{
case 1:
forcePointEraser = true;
break;
case 2:
forcePointEraser = false;
break;
}
inkCanvas.EditingMode =
forcePointEraser ? InkCanvasEditingMode.EraseByPoint : InkCanvasEditingMode.EraseByStroke;
inkCanvas.EraserShape = forcePointEraser ? new EllipseStylusShape(50, 50) : new EllipseStylusShape(5, 5);
drawingShapeMode = 0;
GeometryDrawingEraser.Brush = forcePointEraser ? new SolidColorBrush(Color.FromRgb(0x23, 0xA9, 0xF2)) : new SolidColorBrush(Color.FromRgb(0x66, 0x66, 0x66));
GeometryDrawingEraser.Brush = forcePointEraser
? new SolidColorBrush(Color.FromRgb(0x23, 0xA9, 0xF2))
: new SolidColorBrush(Color.FromRgb(0x66, 0x66, 0x66));
ImageEraser.Visibility = Visibility.Collapsed;
inkCanvas_EditingModeChanged(inkCanvas, null);
CancelSingleFingerDragMode();
@ -2830,6 +2855,14 @@ namespace Ink_Canvas
Settings.Canvas.EraserSize = ComboBoxEraserSize.SelectedIndex;
SaveSettingsToFile();
}
private void ComboBoxEraserType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!isLoaded) return;
Settings.Canvas.EraserType = ComboBoxEraserType.SelectedIndex;
SaveSettingsToFile();
}
private void InkWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
@ -7296,6 +7329,7 @@ namespace Ink_Canvas
#endregion
}
#region Test for pen

View File

@ -32,7 +32,8 @@ namespace Ink_Canvas
public int InkStyle { get; set; } = 0;
[JsonProperty("eraserSize")]
public int EraserSize { get; set; } = 2;
[JsonProperty("eraserType")]
public int EraserType { get; set; } = 0; // 0 - 图标切换模式 1 - 面积擦 2 - 线条擦
[JsonProperty("hideStrokeWhenSelecting")]
public bool HideStrokeWhenSelecting { get; set; } = true;