[update] 套索选择和矩形选择

This commit is contained in:
Dubi906w 2024-08-07 21:56:58 +08:00
parent 16086741e8
commit 066b943adb
10 changed files with 480 additions and 50 deletions

View File

@ -15,6 +15,7 @@ namespace Ink_Canvas.Helpers
private VisualCollection _children; private VisualCollection _children;
private DrawingVisual _layer = new DrawingVisual(); private DrawingVisual _layer = new DrawingVisual();
private Pen defaultPen = new Pen(); private Pen defaultPen = new Pen();
private Pen lassoPen = new Pen();
public RectangleSelectionViewer() public RectangleSelectionViewer()
{ {
@ -24,6 +25,13 @@ namespace Ink_Canvas.Helpers
defaultPen.Thickness = 2; defaultPen.Thickness = 2;
defaultPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235)); defaultPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
defaultPen.DashStyle = DashStyles.Dash; defaultPen.DashStyle = DashStyles.Dash;
lassoPen.Thickness = 6;
lassoPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
lassoPen.DashStyle = new DashStyle(new double[]{0,2},0);
lassoPen.DashCap = PenLineCap.Round;
lassoPen.StartLineCap = PenLineCap.Round;
lassoPen.EndLineCap = PenLineCap.Round;
} }
protected override int VisualChildrenCount => _children.Count; protected override int VisualChildrenCount => _children.Count;
@ -40,6 +48,25 @@ namespace Ink_Canvas.Helpers
context.Close(); context.Close();
} }
public void DrawLassoLine(PointCollection pts) {
DrawingContext context = _layer.RenderOpen();
if (pts.Count > 2) {
StreamGeometry geometry = new StreamGeometry();
var _pts = pts.Clone();
_pts.RemoveAt(0);
using (StreamGeometryContext ctx = geometry.Open()) {
ctx.BeginFigure(pts[0], true , false);
ctx.PolyLineTo(_pts,true, true);
}
context.DrawGeometry(new SolidColorBrush(Colors.Transparent), lassoPen, geometry);
} else if (pts.Count == 2) {
context.DrawLine(defaultPen, pts[0], pts[1]);
} else if (pts.Count == 1) {
context.DrawLine(defaultPen, pts[0], pts[0]);
}
context.Close();
}
public void ClearDrawing() { public void ClearDrawing() {
DrawingContext context = _layer.RenderOpen(); DrawingContext context = _layer.RenderOpen();
context.Close(); context.Close();

View File

@ -567,6 +567,7 @@
<None Remove="Resources\PresentationExample\sidebar-dark.png" /> <None Remove="Resources\PresentationExample\sidebar-dark.png" />
<None Remove="Resources\PresentationExample\sidebar-white.png" /> <None Remove="Resources\PresentationExample\sidebar-white.png" />
<None Remove="Resources\PresentationExample\toolbar.png" /> <None Remove="Resources\PresentationExample\toolbar.png" />
<None Remove="Resources\qrcodes.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\Icons-png\idt.png" /> <Resource Include="Resources\Icons-png\idt.png" />
@ -579,6 +580,7 @@
<Resource Include="Resources\PresentationExample\sidebar-dark.png" /> <Resource Include="Resources\PresentationExample\sidebar-dark.png" />
<Resource Include="Resources\PresentationExample\sidebar-white.png" /> <Resource Include="Resources\PresentationExample\sidebar-white.png" />
<Resource Include="Resources\PresentationExample\toolbar.png" /> <Resource Include="Resources\PresentationExample\toolbar.png" />
<Resource Include="Resources\qrcodes.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Properties\Settings.Designer.cs"> <Compile Update="Properties\Settings.Designer.cs">

View File

@ -22,7 +22,7 @@
Closed="Window_Closed" Closed="Window_Closed"
PreviewKeyDown="Main_Grid_PreviewKeyDown" PreviewKeyDown="Main_Grid_PreviewKeyDown"
PreviewKeyUp="Main_Grid_PreviewKeyUp" PreviewKeyUp="Main_Grid_PreviewKeyUp"
Height="12000" Width="1440" Height="18000" Width="1440"
FontFamily="Microsoft YaHei UI" FontFamily="Microsoft YaHei UI"
MouseWheel="Window_MouseWheel" MouseWheel="Window_MouseWheel"
Foreground="Black" Foreground="Black"
@ -6016,6 +6016,8 @@
StrokeThickness="1" Margin="0,4,0,4" /> StrokeThickness="1" Margin="0,4,0,4" />
<TextBlock Margin="0,0,0,8" Text="选择" FontWeight="Bold" Foreground="#fafafa" <TextBlock Margin="0,0,0,8" Text="选择" FontWeight="Bold" Foreground="#fafafa"
FontSize="20" /> FontSize="20" />
<TextBlock Text="# 使用左键点击墨迹可以直接选中墨迹;使用右键可以始终触发矩形或套索框选模式,而不会选中被鼠标按下的墨迹。" TextWrapping="Wrap"
Foreground="#a1a1aa" />
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="墨迹选择模式" VerticalAlignment="Center" <TextBlock Foreground="#fafafa" Text="墨迹选择模式" VerticalAlignment="Center"
FontSize="14" Margin="0,0,6,0" /> FontSize="14" Margin="0,0,6,0" />
@ -6041,11 +6043,92 @@
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</Border> </Border>
<ComboBox Name="ComboBoxSelectionMethod" FontFamily="Microsoft YaHei UI" <ComboBox Name="ComboBoxSelectionMethod" FontFamily="Microsoft YaHei UI"
SelectedIndex="0"> SelectedIndex="0" SelectionChanged="ComboBoxSelectionMethod_SelectionChanged">
<ComboBoxItem Content="矩形框选" FontFamily="Microsoft YaHei UI" />
<ComboBoxItem Content="套索圈选" FontFamily="Microsoft YaHei UI" /> <ComboBoxItem Content="套索圈选" FontFamily="Microsoft YaHei UI" />
<ComboBoxItem Content="矩形框选" FontFamily="Microsoft YaHei UI" />
</ComboBox> </ComboBox>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="将墨迹缩放应用于触笔笔尖"
VerticalAlignment="Center" FontSize="14" Margin="0,0,6,0" />
<Border Height="20" CornerRadius="3" Background="#1e3a8a" Margin="0,0,12,0"
Padding="4,0">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="3"
VerticalAlignment="Center">
<Image Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#dbeafe"
Geometry="F0 M24,24z M0,0z M18.75,4C18.75,3.58579 18.4142,3.25 18,3.25 17.5858,3.25 17.25,3.58579 17.25,4 17.25,4.33152 17.1183,4.64946 16.8839,4.88388 16.6495,5.1183 16.3315,5.25 16,5.25 15.5858,5.25 15.25,5.58579 15.25,6 15.25,6.41421 15.5858,6.75 16,6.75 16.3315,6.75 16.6495,6.8817 16.8839,7.11612 17.1183,7.35054 17.25,7.66848 17.25,8 17.25,8.41421 17.5858,8.75 18,8.75 18.4142,8.75 18.75,8.41421 18.75,8 18.75,7.66848 18.8817,7.35054 19.1161,7.11612 19.3505,6.8817 19.6685,6.75 20,6.75 20.4142,6.75 20.75,6.41421 20.75,6 20.75,5.58579 20.4142,5.25 20,5.25 19.6685,5.25 19.3505,5.1183 19.1161,4.88388 18.8817,4.64946 18.75,4.33152 18.75,4z M9.75,6C9.75,5.58579 9.41421,5.25 9,5.25 8.58579,5.25 8.25,5.58579 8.25,6 8.25,7.39239 7.69688,8.72774 6.71231,9.71231 5.72774,10.6969 4.39239,11.25 3,11.25 2.58579,11.25 2.25,11.5858 2.25,12 2.25,12.4142 2.58579,12.75 3,12.75 4.39239,12.75 5.72774,13.3031 6.71231,14.2877 7.69688,15.2723 8.25,16.6076 8.25,18 8.25,18.4142 8.58579,18.75 9,18.75 9.41421,18.75 9.75,18.4142 9.75,18 9.75,16.6076 10.3031,15.2723 11.2877,14.2877 12.2723,13.3031 13.6076,12.75 15,12.75 15.4142,12.75 15.75,12.4142 15.75,12 15.75,11.5858 15.4142,11.25 15,11.25 13.6076,11.25 12.2723,10.6969 11.2877,9.71231 10.3031,8.72774 9.75,7.39239 9.75,6z M18.75,16C18.75,15.5858 18.4142,15.25 18,15.25 17.5858,15.25 17.25,15.5858 17.25,16 17.25,16.3315 17.1183,16.6495 16.8839,16.8839 16.6495,17.1183 16.3315,17.25 16,17.25 15.5858,17.25 15.25,17.5858 15.25,18 15.25,18.4142 15.5858,18.75 16,18.75 16.3315,18.75 16.6495,18.8817 16.8839,19.1161 17.1183,19.3505 17.25,19.6685 17.25,20 17.25,20.4142 17.5858,20.75 18,20.75 18.4142,20.75 18.75,20.4142 18.75,20 18.75,19.6685 18.8817,19.3505 19.1161,19.1161 19.3505,18.8817 19.6685,18.75 20,18.75 20.4142,18.75 20.75,18.4142 20.75,18 20.75,17.5858 20.4142,17.25 20,17.25 19.6685,17.25 19.3505,17.1183 19.1161,16.8839 18.8817,16.6495 18.75,16.3315 18.75,16z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Foreground="#dbeafe" Text="新功能" FontSize="12"
VerticalAlignment="Center">
</TextBlock>
</ui:SimpleStackPanel>
</Border>
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchApplyScaleToStylusTip"
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold" Toggled="ToggleSwitchApplyScaleToStylusTip_OnToggled" />
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="仅命中全部包含的墨迹"
VerticalAlignment="Center" FontSize="14" Margin="0,0,6,0" />
<Border Height="20" CornerRadius="3" Background="#1e3a8a" Margin="0,0,12,0"
Padding="4,0">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="3"
VerticalAlignment="Center">
<Image Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#dbeafe"
Geometry="F0 M24,24z M0,0z M18.75,4C18.75,3.58579 18.4142,3.25 18,3.25 17.5858,3.25 17.25,3.58579 17.25,4 17.25,4.33152 17.1183,4.64946 16.8839,4.88388 16.6495,5.1183 16.3315,5.25 16,5.25 15.5858,5.25 15.25,5.58579 15.25,6 15.25,6.41421 15.5858,6.75 16,6.75 16.3315,6.75 16.6495,6.8817 16.8839,7.11612 17.1183,7.35054 17.25,7.66848 17.25,8 17.25,8.41421 17.5858,8.75 18,8.75 18.4142,8.75 18.75,8.41421 18.75,8 18.75,7.66848 18.8817,7.35054 19.1161,7.11612 19.3505,6.8817 19.6685,6.75 20,6.75 20.4142,6.75 20.75,6.41421 20.75,6 20.75,5.58579 20.4142,5.25 20,5.25 19.6685,5.25 19.3505,5.1183 19.1161,4.88388 18.8817,4.64946 18.75,4.33152 18.75,4z M9.75,6C9.75,5.58579 9.41421,5.25 9,5.25 8.58579,5.25 8.25,5.58579 8.25,6 8.25,7.39239 7.69688,8.72774 6.71231,9.71231 5.72774,10.6969 4.39239,11.25 3,11.25 2.58579,11.25 2.25,11.5858 2.25,12 2.25,12.4142 2.58579,12.75 3,12.75 4.39239,12.75 5.72774,13.3031 6.71231,14.2877 7.69688,15.2723 8.25,16.6076 8.25,18 8.25,18.4142 8.58579,18.75 9,18.75 9.41421,18.75 9.75,18.4142 9.75,18 9.75,16.6076 10.3031,15.2723 11.2877,14.2877 12.2723,13.3031 13.6076,12.75 15,12.75 15.4142,12.75 15.75,12.4142 15.75,12 15.75,11.5858 15.4142,11.25 15,11.25 13.6076,11.25 12.2723,10.6969 11.2877,9.71231 10.3031,8.72774 9.75,7.39239 9.75,6z M18.75,16C18.75,15.5858 18.4142,15.25 18,15.25 17.5858,15.25 17.25,15.5858 17.25,16 17.25,16.3315 17.1183,16.6495 16.8839,16.8839 16.6495,17.1183 16.3315,17.25 16,17.25 15.5858,17.25 15.25,17.5858 15.25,18 15.25,18.4142 15.5858,18.75 16,18.75 16.3315,18.75 16.6495,18.8817 16.8839,19.1161 17.1183,19.3505 17.25,19.6685 17.25,20 17.25,20.4142 17.5858,20.75 18,20.75 18.4142,20.75 18.75,20.4142 18.75,20 18.75,19.6685 18.8817,19.3505 19.1161,19.1161 19.3505,18.8817 19.6685,18.75 20,18.75 20.4142,18.75 20.75,18.4142 20.75,18 20.75,17.5858 20.4142,17.25 20,17.25 19.6685,17.25 19.3505,17.1183 19.1161,16.8839 18.8817,16.6495 18.75,16.3315 18.75,16z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Foreground="#dbeafe" Text="新功能" FontSize="12"
VerticalAlignment="Center">
</TextBlock>
</ui:SimpleStackPanel>
</Border>
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchOnlyHitTestFullyContainedStrokes"
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold" Toggled="ToggleSwitchOnlyHitTestFullyContainedStrokes_OnToggled" />
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="允许点选命中被锁定的墨迹"
VerticalAlignment="Center" FontSize="14" Margin="0,0,6,0" />
<Border Height="20" CornerRadius="3" Background="#1e3a8a" Margin="0,0,12,0"
Padding="4,0">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="3"
VerticalAlignment="Center">
<Image Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#dbeafe"
Geometry="F0 M24,24z M0,0z M18.75,4C18.75,3.58579 18.4142,3.25 18,3.25 17.5858,3.25 17.25,3.58579 17.25,4 17.25,4.33152 17.1183,4.64946 16.8839,4.88388 16.6495,5.1183 16.3315,5.25 16,5.25 15.5858,5.25 15.25,5.58579 15.25,6 15.25,6.41421 15.5858,6.75 16,6.75 16.3315,6.75 16.6495,6.8817 16.8839,7.11612 17.1183,7.35054 17.25,7.66848 17.25,8 17.25,8.41421 17.5858,8.75 18,8.75 18.4142,8.75 18.75,8.41421 18.75,8 18.75,7.66848 18.8817,7.35054 19.1161,7.11612 19.3505,6.8817 19.6685,6.75 20,6.75 20.4142,6.75 20.75,6.41421 20.75,6 20.75,5.58579 20.4142,5.25 20,5.25 19.6685,5.25 19.3505,5.1183 19.1161,4.88388 18.8817,4.64946 18.75,4.33152 18.75,4z M9.75,6C9.75,5.58579 9.41421,5.25 9,5.25 8.58579,5.25 8.25,5.58579 8.25,6 8.25,7.39239 7.69688,8.72774 6.71231,9.71231 5.72774,10.6969 4.39239,11.25 3,11.25 2.58579,11.25 2.25,11.5858 2.25,12 2.25,12.4142 2.58579,12.75 3,12.75 4.39239,12.75 5.72774,13.3031 6.71231,14.2877 7.69688,15.2723 8.25,16.6076 8.25,18 8.25,18.4142 8.58579,18.75 9,18.75 9.41421,18.75 9.75,18.4142 9.75,18 9.75,16.6076 10.3031,15.2723 11.2877,14.2877 12.2723,13.3031 13.6076,12.75 15,12.75 15.4142,12.75 15.75,12.4142 15.75,12 15.75,11.5858 15.4142,11.25 15,11.25 13.6076,11.25 12.2723,10.6969 11.2877,9.71231 10.3031,8.72774 9.75,7.39239 9.75,6z M18.75,16C18.75,15.5858 18.4142,15.25 18,15.25 17.5858,15.25 17.25,15.5858 17.25,16 17.25,16.3315 17.1183,16.6495 16.8839,16.8839 16.6495,17.1183 16.3315,17.25 16,17.25 15.5858,17.25 15.25,17.5858 15.25,18 15.25,18.4142 15.5858,18.75 16,18.75 16.3315,18.75 16.6495,18.8817 16.8839,19.1161 17.1183,19.3505 17.25,19.6685 17.25,20 17.25,20.4142 17.5858,20.75 18,20.75 18.4142,20.75 18.75,20.4142 18.75,20 18.75,19.6685 18.8817,19.3505 19.1161,19.1161 19.3505,18.8817 19.6685,18.75 20,18.75 20.4142,18.75 20.75,18.4142 20.75,18 20.75,17.5858 20.4142,17.25 20,17.25 19.6685,17.25 19.3505,17.1183 19.1161,16.8839 18.8817,16.6495 18.75,16.3315 18.75,16z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Foreground="#dbeafe" Text="新功能" FontSize="12"
VerticalAlignment="Center">
</TextBlock>
</ui:SimpleStackPanel>
</Border>
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchAllowClickToSelectLockedStroke"
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold" Toggled="ToggleSwitchAllowClickToSelectLockedStroke_OnToggled" />
</ui:SimpleStackPanel>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</GroupBox> </GroupBox>
<GroupBox Name="SettingsGestureGroupBox"> <GroupBox Name="SettingsGestureGroupBox">
@ -8416,6 +8499,22 @@
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</GroupBox> </GroupBox>
<GroupBox Name="SettingsDonationGroupBox">
<GroupBox.Header>
<Canvas Height="56">
<TextBlock Text="Donation" Foreground="#fafafa" Opacity="0.1"
FontSize="20" Canvas.Top="30" Canvas.Left="16" />
<TextBlock Margin="0,12,0,0" Text="赞助" FontWeight="Bold" Foreground="#fafafa"
FontSize="26" Canvas.Top="0" />
</Canvas>
</GroupBox.Header>
<ui:SimpleStackPanel Spacing="6">
<TextBlock
Text="# InkCanvasForClass 项目非常需要您的帮助,您的捐款是我们继续开发的动力,同时您也可以成为 Golden Sponsor。"
TextWrapping="Wrap" Foreground="#a1a1aa" />
<Image Margin="-12,-4,-12,00" Source="./Resources/qrcodes.png"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Name="SettingsAboutGroupBox" Margin="0,0,0,100"> <GroupBox Name="SettingsAboutGroupBox" Margin="0,0,0,100">
<GroupBox.Header> <GroupBox.Header>
<Canvas Height="56"> <Canvas Height="56">
@ -8831,6 +8930,23 @@
</Image> </Image>
</Grid> </Grid>
</Border> </Border>
<Border Name="SettingsDonationJumpToGroupBoxButton"
MouseDown="SettingsJumpToGroupBox_MouseDown" BorderBrush="#3b82f6"
BorderThickness="0,0,0,0" Width="50" Height="50">
<Grid>
<Image Height="28" Width="28">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="White" Geometry="F0 M24,24z M0,0z M8.26884,2.99217C9.45176,2.50219 10.7196,2.25 12,2.25 13.2804,2.25 14.5482,2.50219 15.7312,2.99217 16.9141,3.48216 17.9889,4.20034 18.8943,5.10571 19.7997,6.01108 20.5178,7.08591 21.0078,8.26884 21.4978,9.45176 21.75,10.7196 21.75,12 21.75,13.2804 21.4978,14.5482 21.0078,15.7312 20.5178,16.9141 19.7997,17.9889 18.8943,18.8943 17.9889,19.7997 16.9141,20.5178 15.7312,21.0078 14.5482,21.4978 13.2804,21.75 12,21.75 10.7196,21.75 9.45176,21.4978 8.26884,21.0078 7.08591,20.5178 6.01108,19.7997 5.10571,18.8943 4.20034,17.9889 3.48216,16.9141 2.99217,15.7312 2.50219,14.5482 2.25,13.2804 2.25,12 2.25,10.7196 2.50219,9.45176 2.99217,8.26884 3.48216,7.08591 4.20034,6.01108 5.10571,5.10571 6.01108,4.20034 7.08591,3.48216 8.26884,2.99217z M12,3.75C10.9166,3.75 9.8438,3.96339 8.84286,4.37799 7.84193,4.7926 6.93245,5.40029 6.16637,6.16637 5.40029,6.93245 4.79259,7.84193 4.37799,8.84286 3.96339,9.8438 3.75,10.9166 3.75,12 3.75,13.0834 3.96339,14.1562 4.37799,15.1571 4.79259,16.1581 5.40029,17.0675 6.16637,17.8336 6.93245,18.5997 7.84193,19.2074 8.84286,19.622 9.8438,20.0366 10.9166,20.25 12,20.25 13.0834,20.25 14.1562,20.0366 15.1571,19.622 16.1581,19.2074 17.0675,18.5997 17.8336,17.8336 18.5997,17.0675 19.2074,16.1581 19.622,15.1571 20.0366,14.1562 20.25,13.0834 20.25,12 20.25,10.9166 20.0366,9.8438 19.622,8.84286 19.2074,7.84193 18.5997,6.93245 17.8336,6.16637 17.0675,5.40029 16.1581,4.7926 15.1571,4.37799 14.1562,3.96339 13.0834,3.75 12,3.75z M8.25,12C8.25,11.5858,8.58579,11.25,9,11.25L10.2653,11.25 8.37596,8.41603C8.1462,8.07138 8.23933,7.60573 8.58397,7.37596 8.92862,7.1462 9.39427,7.23933 9.62404,7.58397L12,11.1479 14.376,7.58397C14.6057,7.23933 15.0714,7.1462 15.416,7.37596 15.7607,7.60573 15.8538,8.07138 15.624,8.41603L13.7347,11.25 15,11.25C15.4142,11.25 15.75,11.5858 15.75,12 15.75,12.4142 15.4142,12.75 15,12.75L12.75,12.75 12.75,14.25 15,14.25C15.4142,14.25 15.75,14.5858 15.75,15 15.75,15.4142 15.4142,15.75 15,15.75L12.75,15.75 12.75,17C12.75,17.4142 12.4142,17.75 12,17.75 11.5858,17.75 11.25,17.4142 11.25,17L11.25,15.75 9,15.75C8.58579,15.75 8.25,15.4142 8.25,15 8.25,14.5858 8.58579,14.25 9,14.25L11.25,14.25 11.25,12.75 9,12.75C8.58579,12.75,8.25,12.4142,8.25,12z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</Grid>
</Border>
<Border Name="SettingsAboutJumpToGroupBoxButton" MouseDown="SettingsJumpToGroupBox_MouseDown" <Border Name="SettingsAboutJumpToGroupBoxButton" MouseDown="SettingsJumpToGroupBox_MouseDown"
BorderBrush="#3b82f6" BorderThickness="0,0,0,0" Width="50" Height="50"> BorderBrush="#3b82f6" BorderThickness="0,0,0,0" Width="50" Height="50">
<Grid> <Grid>

View File

@ -1,4 +1,5 @@
using iNKORE.UI.WPF.Modern.Controls; using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.Office.Interop.PowerPoint;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -14,7 +15,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D; using System.Windows.Media.Media3D;
using System.Windows.Resources; using System.Windows.Resources;
using Ink_Canvas.Popups;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using Application = System.Windows.Application;
using Matrix = System.Windows.Media.Matrix; using Matrix = System.Windows.Media.Matrix;
using Point = System.Windows.Point; using Point = System.Windows.Point;
@ -190,8 +193,6 @@ namespace Ink_Canvas {
private void ImageRotate_MouseUp(object sender, MouseButtonEventArgs e) { private void ImageRotate_MouseUp(object sender, MouseButtonEventArgs e) {
if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return; if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
Trace.WriteLine("12323112323232323231123123");
MatrixStrokes((m, cent) => { MatrixStrokes((m, cent) => {
m.RotateAt((((Border)sender).Name=="BorderImageRotate45"?45:90) * (StrokesRotateClockwise == 0 ? 1 : -1), cent.X, cent.Y); m.RotateAt((((Border)sender).Name=="BorderImageRotate45"?45:90) * (StrokesRotateClockwise == 0 ? 1 : -1), cent.X, cent.Y);
return m; return m;
@ -282,8 +283,11 @@ namespace Ink_Canvas {
private StrokeCollection StrokesSelectionClone = new StrokeCollection(); private StrokeCollection StrokesSelectionClone = new StrokeCollection();
private bool isRectangleSelectionMouseDown = false; private bool isRectangleSelectionMouseDown = false;
// 矩形框选
private Point rectangleSelection_FirstPoint = new Point(0, 0); private Point rectangleSelection_FirstPoint = new Point(0, 0);
private Point rectangleSelection_LastPoint = new Point(0, 0); private Point rectangleSelection_LastPoint = new Point(0, 0);
// 套索框选
private PointCollection rectangleSelection_LassoPoints = new PointCollection();
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) { private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
isGridInkCanvasSelectionCoverMouseDown = true; isGridInkCanvasSelectionCoverMouseDown = true;
@ -297,39 +301,52 @@ namespace Ink_Canvas {
private void RectangleSelectionHitTestBorder_MouseDown(object sender, MouseButtonEventArgs e) { private void RectangleSelectionHitTestBorder_MouseDown(object sender, MouseButtonEventArgs e) {
var pt = e.GetPosition(Main_Grid); var pt = e.GetPosition(Main_Grid);
var nt = inkCanvas.Strokes.HitTest(pt, 8); var nt = inkCanvas.Strokes.HitTest(pt, 8);
if (nt.Count > 0) { if (nt.Count > 0 && !(e.RightButton == MouseButtonState.Pressed)) {
if (nt.Count > 1) { if (nt.Count > 1) {
var nodia = nt.HitTest(pt); var nodia = nt.HitTest(pt);
if (nodia.Count > 0) { if (nodia.Count > 0) {
if (nodia[nodia.Count - 1].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return;
inkCanvas.Select(new StrokeCollection() {nodia[nodia.Count-1]}); inkCanvas.Select(new StrokeCollection() {nodia[nodia.Count-1]});
} else { } else {
if (nt[0].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return;
inkCanvas.Select(new StrokeCollection() { nt[0] }); inkCanvas.Select(new StrokeCollection() { nt[0] });
} }
} else if (nt.Count == 1) { } else if (nt.Count == 1) {
if (nt[0].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return;
inkCanvas.Select(nt); inkCanvas.Select(nt);
} }
} else { } else {
RectangleSelectionHitTestBorder.CaptureMouse(); RectangleSelectionHitTestBorder.CaptureMouse();
isRectangleSelectionMouseDown = true; isRectangleSelectionMouseDown = true;
rectangleSelection_FirstPoint = pt; if (Settings.Canvas.SelectionMethod == 1) {
rectangleSelection_FirstPoint = pt;
} else {
rectangleSelection_LassoPoints.Clear();
rectangleSelection_LassoPoints.Add(pt);
}
} }
} }
private void RectangleSelectionHitTestBorder_MouseMove(object sender, MouseEventArgs e) { private void RectangleSelectionHitTestBorder_MouseMove(object sender, MouseEventArgs e) {
var pt = e.GetPosition(Main_Grid); var pt = e.GetPosition(Main_Grid);
if (!isRectangleSelectionMouseDown) return; if (!isRectangleSelectionMouseDown) return;
rectangleSelection_LastPoint = pt; if (Settings.Canvas.SelectionMethod == 1) {
RectangleSelection.DrawSelectionBox(new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint)); rectangleSelection_LastPoint = pt;
RectangleSelection.DrawSelectionBox(new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint));
} else {
rectangleSelection_LassoPoints.Add(pt);
RectangleSelection.DrawLassoLine(rectangleSelection_LassoPoints);
}
} }
private void RectangleSelectionHitTestBorder_MouseUp(object sender, MouseButtonEventArgs e) { private void RectangleSelectionHitTestBorder_MouseUp(object sender, MouseButtonEventArgs e) {
if (!isRectangleSelectionMouseDown) return;
RectangleSelectionHitTestBorder.ReleaseMouseCapture(); RectangleSelectionHitTestBorder.ReleaseMouseCapture();
isRectangleSelectionMouseDown = false; isRectangleSelectionMouseDown = false;
var pt = e.GetPosition(Main_Grid); var pt = e.GetPosition(Main_Grid);
rectangleSelection_LastPoint = pt;
var ilh = inkCanvas.Strokes.GetIncrementalLassoHitTester(1); var ilh = inkCanvas.Strokes.GetIncrementalLassoHitTester(Settings.Canvas.OnlyHitTestFullyContainedStrokes ? 100 : 1);
var rct = new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint);
void func(object s, LassoSelectionChangedEventArgs _e) { void func(object s, LassoSelectionChangedEventArgs _e) {
var _ilh = s as IncrementalLassoHitTester; var _ilh = s as IncrementalLassoHitTester;
@ -339,13 +356,21 @@ namespace Ink_Canvas {
} }
ilh.SelectionChanged += func; ilh.SelectionChanged += func;
ilh.AddPoints(new Point[] {
rct.TopLeft, if (Settings.Canvas.SelectionMethod == 1) {
rct.TopRight, rectangleSelection_LastPoint = pt;
rct.BottomRight, var rct = new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint);
rct.BottomLeft, ilh.AddPoints(new Point[] {
rct.TopLeft rct.TopLeft,
}); rct.TopRight,
rct.BottomRight,
rct.BottomLeft,
rct.TopLeft
});
} else {
rectangleSelection_LassoPoints.Add(pt);
ilh.AddPoints(rectangleSelection_LassoPoints);
}
RectangleSelection.ClearDrawing(); RectangleSelection.ClearDrawing();
} }
@ -366,6 +391,7 @@ namespace Ink_Canvas {
private Point? resizingLastPoint = null; private Point? resizingLastPoint = null;
private void StrokeSelectionBorderHandle_MouseDown(object sender, MouseButtonEventArgs e) { private void StrokeSelectionBorderHandle_MouseDown(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
// lock // lock
isLockedStrokeSelectionHandle = true; isLockedStrokeSelectionHandle = true;
@ -416,6 +442,7 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionBorderHandle_MouseUp(object sender, MouseButtonEventArgs e) { private void StrokeSelectionBorderHandle_MouseUp(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
// resize strokes and preview strokes // resize strokes and preview strokes
@ -448,7 +475,7 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionBorderHandle_MouseMove(object sender, MouseEventArgs e) { private void StrokeSelectionBorderHandle_MouseMove(object sender, MouseEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
var bd = (Border)sender; var bd = (Border)sender;
@ -555,6 +582,7 @@ namespace Ink_Canvas {
private bool isProgramChangeStrokesSelection = false; private bool isProgramChangeStrokesSelection = false;
private void StrokeSelectionBorder_MouseUp(object sender, MouseButtonEventArgs e) { private void StrokeSelectionBorder_MouseUp(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return;
// release capture // release capture
@ -620,6 +648,7 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionBorder_MouseDown(object sender, MouseButtonEventArgs e) { private void StrokeSelectionBorder_MouseDown(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || isLockedStrokeSelectionMove) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || isLockedStrokeSelectionMove) return;
// record first move point // record first move point
@ -643,6 +672,7 @@ namespace Ink_Canvas {
private StrokeCollection clonedStrokes; private StrokeCollection clonedStrokes;
private void StrokeSelectionBorder_MouseMove(object sender, MouseEventArgs e) { private void StrokeSelectionBorder_MouseMove(object sender, MouseEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return;
// record last move point // record last move point
@ -699,6 +729,7 @@ namespace Ink_Canvas {
private bool isLockedStrokeSelectionRotate = false; private bool isLockedStrokeSelectionRotate = false;
private void StrokeSelectionRotateHandle_MouseUp(object sender, MouseButtonEventArgs e) { private void StrokeSelectionRotateHandle_MouseUp(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return;
// unlock // unlock
@ -758,6 +789,7 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionRotateHandle_MouseDown(object sender, MouseButtonEventArgs e) { private void StrokeSelectionRotateHandle_MouseDown(object sender, MouseButtonEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
// lock // lock
@ -773,6 +805,7 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionRotateHandle_MouseMove(object sender, MouseEventArgs e) { private void StrokeSelectionRotateHandle_MouseMove(object sender, MouseEventArgs e) {
if (isStrokeSelectionBorderLocked) return;
if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return;
// record last point // record last point
@ -898,10 +931,18 @@ namespace Ink_Canvas {
} }
private void StrokeSelectionBorder_MouseEnter(object sender, MouseEventArgs e) { private void StrokeSelectionBorder_MouseEnter(object sender, MouseEventArgs e) {
if (isStrokeSelectionBorderLocked) {
StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250));
return;
};
StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(17, 96, 165, 250)); StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(17, 96, 165, 250));
} }
private void StrokeSelectionBorder_MouseLeave(object sender, MouseEventArgs e) { private void StrokeSelectionBorder_MouseLeave(object sender, MouseEventArgs e) {
if (isStrokeSelectionBorderLocked) {
StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250));
return;
};
StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250)); StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250));
} }
@ -972,7 +1013,7 @@ namespace Ink_Canvas {
if (isPreview) { if (isPreview) {
InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
} else { } else {
strokes.Transform(matrix, false); strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip);
} }
} }
@ -984,7 +1025,7 @@ namespace Ink_Canvas {
if (isPreview) { if (isPreview) {
InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
} else { } else {
strokes.Transform(matrix, false); strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip);
} }
} }
@ -1020,7 +1061,7 @@ namespace Ink_Canvas {
if (isPreview) { if (isPreview) {
InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
} else { } else {
strokes.Transform(matrix, false); strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip);
} }
return strokes.GetBounds(); return strokes.GetBounds();
@ -1109,7 +1150,6 @@ namespace Ink_Canvas {
} }
private void updateBorderStrokeSelectionControlLocation() { private void updateBorderStrokeSelectionControlLocation() {
if (currentMode == 0) BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到白板"; if (currentMode == 0) BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到白板";
else BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到新页"; else BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到新页";
@ -1159,11 +1199,22 @@ namespace Ink_Canvas {
} }
} }
private bool isStrokeSelectionBorderLocked = false;
private void UpdateSelectionBorderHandlesLockStatus(bool isLocked) { private void UpdateSelectionBorderHandlesLockStatus(bool isLocked) {
var _v = !isLocked ? Visibility.Visible : Visibility.Collapsed; var _v = !isLocked ? Visibility.Visible : Visibility.Collapsed;
foreach (var hd in StrokeSelectionBorderHandles) hd.Visibility = _v; foreach (var hd in StrokeSelectionBorderHandles) hd.Visibility = _v;
StrokeSelectionRotateHandleConnectLine.Visibility = _v; StrokeSelectionRotateHandleConnectLine.Visibility = _v;
StrokeSelectionBorder.IsHitTestVisible = !isLocked; isStrokeSelectionBorderLocked = isLocked;
if (isLocked) {
StrokeSelectionCursorArea.ForceCursor = false;
StrokeSelectionCursorArea.Cursor = Cursors.Arrow;
} else {
StrokeSelectionCursorArea.ForceCursor = true;
StreamResourceInfo sri_move = Application.GetResourceStream(
new Uri("Resources/Cursors/cursor-move.cur", UriKind.Relative));
StrokeSelectionCursorArea.Cursor = new Cursor(sri_move.Stream);
}
} }
private void BorderStrokeSelectionLock_MouseUp(object sender, MouseButtonEventArgs e) { private void BorderStrokeSelectionLock_MouseUp(object sender, MouseButtonEventArgs e) {
@ -1280,6 +1331,37 @@ namespace Ink_Canvas {
} }
SelectionPopupV2.IsOpen = false; SelectionPopupV2.IsOpen = false;
}; };
SelectionV2.ApplyScaleToStylusTip = Settings.Canvas.ApplyScaleToStylusTip;
SelectionV2.OnlyHitTestFullyContainedStrokes = Settings.Canvas.OnlyHitTestFullyContainedStrokes;
SelectionV2.AllowClickToSelectLockedStroke = Settings.Canvas.AllowClickToSelectLockedStroke;
SelectionV2.SelectionModeSelected = (SelectionPopup.SelectionMode)Settings.Canvas.SelectionMethod;
SelectionV2.ApplyScaleToStylusTipChanged += (sender, args) => {
if (!isLoaded) return;
Settings.Canvas.ApplyScaleToStylusTip = SelectionV2.ApplyScaleToStylusTip;
ToggleSwitchApplyScaleToStylusTip.IsOn = SelectionV2.ApplyScaleToStylusTip;
SaveSettingsToFile();
};
SelectionV2.OnlyHitTestFullyContainedStrokesChanged += (sender, args) => {
if (!isLoaded) return;
Settings.Canvas.OnlyHitTestFullyContainedStrokes = SelectionV2.OnlyHitTestFullyContainedStrokes;
ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn = SelectionV2.OnlyHitTestFullyContainedStrokes;
SaveSettingsToFile();
};
SelectionV2.AllowClickToSelectLockedStrokeChanged += (sender, args) => {
if (!isLoaded) return;
Settings.Canvas.AllowClickToSelectLockedStroke = SelectionV2.AllowClickToSelectLockedStroke;
ToggleSwitchAllowClickToSelectLockedStroke.IsOn = SelectionV2.AllowClickToSelectLockedStroke;
SaveSettingsToFile();
};
SelectionV2.SelectionModeChanged += (sender, args) => {
if (!isLoaded) return;
Settings.Canvas.SelectionMethod = (int)args.NowMode;
ComboBoxSelectionMethod.SelectedIndex = (int)args.NowMode;
SaveSettingsToFile();
};
SelectionV2.SelectionPopupShouldCloseEvent += (sender, args) => {
SelectionPopupV2.IsOpen = false;
};
} }
#endregion #endregion

View File

@ -23,6 +23,9 @@ using System.Threading;
using System.Timers; using System.Timers;
using Ink_Canvas.Popups; using Ink_Canvas.Popups;
using Ookii.Dialogs.Wpf; using Ookii.Dialogs.Wpf;
using Microsoft.Office.Interop.PowerPoint;
using Application = System.Windows.Application;
using Point = System.Windows.Point;
namespace Ink_Canvas { namespace Ink_Canvas {
public partial class MainWindow : Window { public partial class MainWindow : Window {
@ -936,14 +939,41 @@ namespace Ink_Canvas {
} }
private void ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged_Toggled(object sender, private void ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged_Toggled(object sender,
RoutedEventArgs e) RoutedEventArgs e) {
{
if (!isLoaded) return; if (!isLoaded) return;
Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged = Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged =
ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged.IsOn; ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged.IsOn;
SaveSettingsToFile(); SaveSettingsToFile();
} }
private void ToggleSwitchApplyScaleToStylusTip_OnToggled(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
Settings.Canvas.ApplyScaleToStylusTip = ToggleSwitchApplyScaleToStylusTip.IsOn;
SelectionV2.ApplyScaleToStylusTip = ToggleSwitchApplyScaleToStylusTip.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchOnlyHitTestFullyContainedStrokes_OnToggled(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
Settings.Canvas.OnlyHitTestFullyContainedStrokes = ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn;
SelectionV2.OnlyHitTestFullyContainedStrokes = ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchAllowClickToSelectLockedStroke_OnToggled(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
Settings.Canvas.AllowClickToSelectLockedStroke = ToggleSwitchAllowClickToSelectLockedStroke.IsOn;
SelectionV2.AllowClickToSelectLockedStroke = ToggleSwitchAllowClickToSelectLockedStroke.IsOn;
SaveSettingsToFile();
}
private void ComboBoxSelectionMethod_SelectionChanged(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
Settings.Canvas.SelectionMethod = ComboBoxSelectionMethod.SelectedIndex;
SelectionV2.SelectionModeSelected = (SelectionPopup.SelectionMode)ComboBoxSelectionMethod.SelectedIndex;
SaveSettingsToFile();
}
#endregion #endregion
#region Automation #region Automation
@ -1580,6 +1610,10 @@ namespace Ink_Canvas {
Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged = false; Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged = false;
Settings.Canvas.UseDefaultBackgroundColorForEveryNewAddedBlackboardPage = false; Settings.Canvas.UseDefaultBackgroundColorForEveryNewAddedBlackboardPage = false;
Settings.Canvas.UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage = false; Settings.Canvas.UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage = false;
Settings.Canvas.SelectionMethod = 0;
Settings.Canvas.ApplyScaleToStylusTip = false;
Settings.Canvas.OnlyHitTestFullyContainedStrokes = false;
Settings.Canvas.AllowClickToSelectLockedStroke = false;
Settings.Gesture.AutoSwitchTwoFingerGesture = true; Settings.Gesture.AutoSwitchTwoFingerGesture = true;
Settings.Gesture.IsEnableTwoFingerTranslate = true; Settings.Gesture.IsEnableTwoFingerTranslate = true;
@ -1967,6 +2001,7 @@ namespace Ink_Canvas {
SettingsStorageGroupBox, SettingsStorageGroupBox,
SettingsSnapshotGroupBox, SettingsSnapshotGroupBox,
SettingsRandWindowGroupBox, SettingsRandWindowGroupBox,
SettingsDonationGroupBox,
SettingsAboutGroupBox SettingsAboutGroupBox
}; };
@ -1982,6 +2017,7 @@ namespace Ink_Canvas {
SettingsStorageJumpToGroupBoxButton, SettingsStorageJumpToGroupBoxButton,
SettingsSnapshotJumpToGroupBoxButton, SettingsSnapshotJumpToGroupBoxButton,
SettingsRandWindowJumpToGroupBoxButton, SettingsRandWindowJumpToGroupBoxButton,
SettingsDonationJumpToGroupBoxButton,
SettingsAboutJumpToGroupBoxButton SettingsAboutJumpToGroupBoxButton
}; };
} }

View File

@ -122,6 +122,8 @@ namespace Ink_Canvas {
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error); LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
} }
#region Startup
if (Settings.Startup != null) { if (Settings.Startup != null) {
if (isStartup) { if (isStartup) {
if (Settings.Automation.AutoDelSavedFiles) { if (Settings.Automation.AutoDelSavedFiles) {
@ -171,7 +173,10 @@ namespace Ink_Canvas {
Settings.Startup = new Startup(); Settings.Startup = new Startup();
} }
// Appearance #endregion
#region Appearance
if (Settings.Appearance != null) { if (Settings.Appearance != null) {
if (!Settings.Appearance.IsEnableDisPlayNibModeToggler) { if (!Settings.Appearance.IsEnableDisPlayNibModeToggler) {
NibModeSimpleStackPanel.Visibility = Visibility.Collapsed; NibModeSimpleStackPanel.Visibility = Visibility.Collapsed;
@ -328,7 +333,10 @@ namespace Ink_Canvas {
Settings.Appearance = new Appearance(); Settings.Appearance = new Appearance();
} }
// PowerPointSettings #endregion
#region PowerPointSettings
if (Settings.PowerPointSettings != null) { if (Settings.PowerPointSettings != null) {
@ -431,7 +439,10 @@ namespace Ink_Canvas {
Settings.PowerPointSettings = new PowerPointSettings(); Settings.PowerPointSettings = new PowerPointSettings();
} }
// Gesture #endregion
#region Gesture
if (Settings.Gesture != null) { if (Settings.Gesture != null) {
ToggleSwitchEnableMultiTouchMode.IsOn = Settings.Gesture.IsEnableMultiTouchMode; ToggleSwitchEnableMultiTouchMode.IsOn = Settings.Gesture.IsEnableMultiTouchMode;
@ -499,7 +510,10 @@ namespace Ink_Canvas {
Settings.Gesture = new Gesture(); Settings.Gesture = new Gesture();
} }
// Canvas #endregion
#region Canvas
if (Settings.Canvas != null) { if (Settings.Canvas != null) {
drawingAttributes.Height = Settings.Canvas.InkWidth; drawingAttributes.Height = Settings.Canvas.InkWidth;
drawingAttributes.Width = Settings.Canvas.InkWidth; drawingAttributes.Width = Settings.Canvas.InkWidth;
@ -621,7 +635,10 @@ namespace Ink_Canvas {
Settings.Canvas = new Canvas(); Settings.Canvas = new Canvas();
} }
// Advanced #endregion
#region Advanced
if (Settings.Advanced != null) { if (Settings.Advanced != null) {
TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier; TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier;
FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth; FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth;
@ -664,7 +681,10 @@ namespace Ink_Canvas {
Settings.Advanced = new Advanced(); Settings.Advanced = new Advanced();
} }
// InkToShape #endregion
#region Ink Recognition
if (Settings.InkToShape != null) { if (Settings.InkToShape != null) {
ToggleSwitchEnableInkToShape.IsOn = Settings.InkToShape.IsInkToShapeEnabled; ToggleSwitchEnableInkToShape.IsOn = Settings.InkToShape.IsInkToShapeEnabled;
@ -683,15 +703,22 @@ namespace Ink_Canvas {
Settings.InkToShape = new InkToShape(); Settings.InkToShape = new InkToShape();
} }
// RandSettings #endregion
if (Settings.RandSettings != null) { } else {
Settings.RandSettings = new RandSettings(); #region RandSettings
if (Settings.RandSettings != null) {
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn; ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency; RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents; RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
} else {
Settings.RandSettings = new RandSettings();
} }
// Automation #endregion
#region Automation
if (Settings.Automation != null) { if (Settings.Automation != null) {
StartOrStoptimerCheckAutoFold(); StartOrStoptimerCheckAutoFold();
ToggleSwitchAutoFoldInEasiNote.IsOn = Settings.Automation.IsAutoFoldInEasiNote; ToggleSwitchAutoFoldInEasiNote.IsOn = Settings.Automation.IsAutoFoldInEasiNote;
@ -783,6 +810,23 @@ namespace Ink_Canvas {
Settings.Automation = new Automation(); Settings.Automation = new Automation();
} }
#endregion
#region Snapshot
if (Settings.Snapshot != null) {
ToggleSwitchScreenshotUsingMagnificationAPI.IsOn = Settings.Snapshot.ScreenshotUsingMagnificationAPI;
ToggleSwitchCopyScreenshotToClipboard.IsOn = Settings.Snapshot.CopyScreenshotToClipboard;
ToggleSwitchHideMainWinWhenScreenshot.IsOn = Settings.Snapshot.HideMainWinWhenScreenshot;
ToggleSwitchAttachInkWhenScreenshot.IsOn = Settings.Snapshot.AttachInkWhenScreenshot;
ToggleSwitchOnlySnapshotMaximizeWindow.IsOn = Settings.Snapshot.OnlySnapshotMaximizeWindow;
ScreenshotFileName.Text = Settings.Snapshot.ScreenshotFileName;
} else {
Settings.Snapshot = new Snapshot();
}
#endregion
// auto align // auto align
if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) { if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
ViewboxFloatingBarMarginAnimation(60); ViewboxFloatingBarMarginAnimation(60);

View File

@ -15,7 +15,7 @@
<modern:SimpleStackPanel Spacing="4" Margin="8,0" Height="40" VerticalAlignment="Top" Orientation="Horizontal"> <modern:SimpleStackPanel Spacing="4" Margin="8,0" Height="40" VerticalAlignment="Top" Orientation="Horizontal">
<Border x:Name="LassoTabButton" VerticalAlignment="Bottom" <Border x:Name="LassoTabButton" VerticalAlignment="Bottom"
Background="#223b82f6" Height="34" Width="96" Background="#223b82f6" Height="34" Width="96"
CornerRadius="6"> CornerRadius="6" MouseDown="SelectionModeTabButton_MouseDown">
<Grid> <Grid>
<modern:SimpleStackPanel <modern:SimpleStackPanel
x:Name="LassoTabButtonIndicator" x:Name="LassoTabButtonIndicator"
@ -55,7 +55,7 @@
</Border> </Border>
<Border x:Name="RectangleTabButton" VerticalAlignment="Bottom" <Border x:Name="RectangleTabButton" VerticalAlignment="Bottom"
Background="#223b82f6" Height="34" Width="96" Background="#223b82f6" Height="34" Width="96"
CornerRadius="6"> CornerRadius="6" MouseDown="SelectionModeTabButton_MouseDown">
<Grid> <Grid>
<modern:SimpleStackPanel <modern:SimpleStackPanel
x:Name="RectangleTabButtonIndicator" x:Name="RectangleTabButtonIndicator"
@ -169,9 +169,9 @@
</Button> </Button>
</Grid> </Grid>
<modern:SimpleStackPanel Spacing="-4" Orientation="Vertical" Margin="11,4,0,0"> <modern:SimpleStackPanel Spacing="-4" Orientation="Vertical" Margin="11,4,0,0">
<CheckBox Content="将墨迹缩放应用于触笔笔尖" IsChecked="True"></CheckBox> <CheckBox Name="cb1" Checked="cb1cked" Unchecked="cb1cked" Content="将墨迹缩放应用于触笔笔尖" IsChecked="True"></CheckBox>
<CheckBox Content="仅命中全部包含的墨迹" IsChecked="True"></CheckBox> <CheckBox Name="cb2" Checked="cb2cked" Unchecked="cb2cked" Content="仅命中全部包含的墨迹" IsChecked="True"></CheckBox>
<CheckBox Content="允许点选命中被锁定的墨迹" IsChecked="True"></CheckBox> <CheckBox Name="cb3" Checked="cb3cked" Unchecked="cb3cked" Content="允许点选命中被锁定的墨迹" IsChecked="True"></CheckBox>
</modern:SimpleStackPanel> </modern:SimpleStackPanel>
</modern:SimpleStackPanel> </modern:SimpleStackPanel>
</Grid> </Grid>

View File

@ -1,4 +1,5 @@
using System; using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -12,11 +13,25 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using static Ink_Canvas.Popups.ColorPalette;
namespace Ink_Canvas.Popups { namespace Ink_Canvas.Popups {
public partial class SelectionPopup : UserControl { public partial class SelectionPopup : UserControl {
public SelectionPopup() { public SelectionPopup() {
InitializeComponent(); InitializeComponent();
SelectionModeTabButtonBorders = new Border[] {
LassoTabButton, RectangleTabButton
};
SelectionModeTabButtonIndicators = new SimpleStackPanel[] {
LassoTabButtonIndicator, RectangleTabButtonIndicator
};
SelectionModeTabButtonIcons = new GeometryDrawing[] {
LassoTabButtonIcon, RectangleTabButtonIcon
};
SelectionModeTabButtonTexts = new TextBlock[] {
LassoTabButtonText, RectangleTabButtonText
};
UpdateSelectionModeButtonsCheckedDisplayStatus();
} }
private bool isCloseButtonDown = false; private bool isCloseButtonDown = false;
@ -24,6 +39,102 @@ namespace Ink_Canvas.Popups {
public event EventHandler<RoutedEventArgs> SelectAllEvent; public event EventHandler<RoutedEventArgs> SelectAllEvent;
public event EventHandler<RoutedEventArgs> UnSelectEvent; public event EventHandler<RoutedEventArgs> UnSelectEvent;
public event EventHandler<RoutedEventArgs> ReverseSelectEvent; public event EventHandler<RoutedEventArgs> ReverseSelectEvent;
public event EventHandler<RoutedEventArgs> ApplyScaleToStylusTipChanged;
public event EventHandler<RoutedEventArgs> OnlyHitTestFullyContainedStrokesChanged;
public event EventHandler<RoutedEventArgs> AllowClickToSelectLockedStrokeChanged;
public bool ApplyScaleToStylusTip {
get => cb1.IsChecked??false;
set {
isProgramicallyChangeCheckBox = true;
cb1.IsChecked = value;
isProgramicallyChangeCheckBox = false;
}
}
public bool OnlyHitTestFullyContainedStrokes {
get => cb2.IsChecked ?? false;
set {
isProgramicallyChangeCheckBox = true;
cb2.IsChecked = value;
isProgramicallyChangeCheckBox = false;
}
}
public bool AllowClickToSelectLockedStroke {
get => cb3.IsChecked ?? false;
set {
isProgramicallyChangeCheckBox = true;
cb3.IsChecked = value;
isProgramicallyChangeCheckBox = false;
}
}
public Border[] SelectionModeTabButtonBorders;
public SimpleStackPanel[] SelectionModeTabButtonIndicators;
public GeometryDrawing[] SelectionModeTabButtonIcons;
public TextBlock[] SelectionModeTabButtonTexts;
public enum SelectionMode {
LassoMode,
RectangleMode
}
private SelectionMode _selectionModeSelected = SelectionMode.LassoMode;
public SelectionMode SelectionModeSelected {
get => _selectionModeSelected;
set {
_selectionModeSelected = value;
UpdateSelectionModeButtonsCheckedDisplayStatus();
}
}
public event EventHandler<SelectionModeChangedEventArgs> SelectionModeChanged;
public class SelectionModeChangedEventArgs : EventArgs
{
public SelectionMode PreviousMode { get; set; }
public SelectionMode NowMode { get; set; }
}
private void UpdateSelectionModeButtonsCheckedDisplayStatus() {
foreach (var bd in SelectionModeTabButtonBorders) {
bd.Background = new SolidColorBrush(Colors.Transparent);
}
foreach (var indicator in SelectionModeTabButtonIndicators) {
indicator.Visibility = Visibility.Hidden;
}
foreach (var gd in SelectionModeTabButtonIcons) {
gd.Brush = new SolidColorBrush(Color.FromRgb(63, 63, 70));
}
foreach (var text in SelectionModeTabButtonTexts) {
text.Foreground = new SolidColorBrush(Color.FromRgb(63, 63, 70));
text.FontWeight = FontWeights.Normal;
}
SelectionModeTabButtonBorders[(int)_selectionModeSelected].Background = new SolidColorBrush(Color.FromArgb(34, 59, 130, 246));
SelectionModeTabButtonIndicators[(int)_selectionModeSelected].Visibility = Visibility.Visible;
SelectionModeTabButtonIcons[(int)_selectionModeSelected].Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
SelectionModeTabButtonTexts[(int)_selectionModeSelected].Foreground = new SolidColorBrush(Color.FromRgb(37, 99, 235));
SelectionModeTabButtonTexts[(int)_selectionModeSelected].FontWeight = FontWeights.Bold;
}
private bool isProgramicallyChangeCheckBox = false;
private void cb1cked(object sender, RoutedEventArgs e) {
if (isProgramicallyChangeCheckBox) return;
ApplyScaleToStylusTipChanged?.Invoke(null,new RoutedEventArgs());
}
private void cb2cked(object sender, RoutedEventArgs e) {
if (isProgramicallyChangeCheckBox) return;
OnlyHitTestFullyContainedStrokesChanged?.Invoke(null,new RoutedEventArgs());
}
private void cb3cked(object sender, RoutedEventArgs e) {
if (isProgramicallyChangeCheckBox) return;
AllowClickToSelectLockedStrokeChanged?.Invoke(null,new RoutedEventArgs());
}
private void CloseButtonBorder_MouseDown(object sender, MouseButtonEventArgs e) { private void CloseButtonBorder_MouseDown(object sender, MouseButtonEventArgs e) {
isCloseButtonDown = true; isCloseButtonDown = true;
@ -35,6 +146,17 @@ namespace Ink_Canvas.Popups {
CloseButtonBorder.Background = new SolidColorBrush(Colors.Transparent); CloseButtonBorder.Background = new SolidColorBrush(Colors.Transparent);
} }
private void SelectionModeTabButton_MouseDown(object sender, MouseButtonEventArgs e) {
var pre = _selectionModeSelected;
_selectionModeSelected = (SelectionMode)Array.IndexOf(SelectionModeTabButtonBorders, (Border)sender);
UpdateSelectionModeButtonsCheckedDisplayStatus();
SelectionModeChanged?.Invoke(this, new SelectionModeChangedEventArgs() {
PreviousMode = pre,
NowMode = _selectionModeSelected,
});
}
private void CloseButtonBorder_MouseUp(object sender, MouseButtonEventArgs e) { private void CloseButtonBorder_MouseUp(object sender, MouseButtonEventArgs e) {
if (!isCloseButtonDown) return; if (!isCloseButtonDown) return;

View File

@ -75,30 +75,31 @@ namespace Ink_Canvas
public bool FitToCurve { get; set; } = true; public bool FitToCurve { get; set; } = true;
[JsonProperty("clearCanvasAndClearTimeMachine")] [JsonProperty("clearCanvasAndClearTimeMachine")]
public bool ClearCanvasAndClearTimeMachine { get; set; } = false; public bool ClearCanvasAndClearTimeMachine { get; set; } = false;
[Obsolete("已经使用多背景色“blackboardBackgroundColor”替换该选项")] [Obsolete("已经使用多背景色“blackboardBackgroundColor”替换该选项")]
[JsonProperty("usingWhiteboard")] [JsonProperty("usingWhiteboard")]
public bool UsingWhiteboard { get; set; } public bool UsingWhiteboard { get; set; }
[JsonProperty("hyperbolaAsymptoteOption")] [JsonProperty("hyperbolaAsymptoteOption")]
public OptionalOperation HyperbolaAsymptoteOption { get; set; } = OptionalOperation.Ask; public OptionalOperation HyperbolaAsymptoteOption { get; set; } = OptionalOperation.Ask;
[JsonProperty("blackboardBackgroundColor")] [JsonProperty("blackboardBackgroundColor")]
public BlackboardBackgroundColorEnum BlackboardBackgroundColor { get; set; } = public BlackboardBackgroundColorEnum BlackboardBackgroundColor { get; set; } =
BlackboardBackgroundColorEnum.White; BlackboardBackgroundColorEnum.White;
[JsonProperty("blackboardBackgroundPattern")] [JsonProperty("blackboardBackgroundPattern")]
public BlackboardBackgroundPatternEnum BlackboardBackgroundPattern { get; set; } = public BlackboardBackgroundPatternEnum BlackboardBackgroundPattern { get; set; } =
BlackboardBackgroundPatternEnum.None; BlackboardBackgroundPatternEnum.None;
[JsonProperty("useDefaultBackgroundColorForEveryNewAddedBlackboardPage")] [JsonProperty("useDefaultBackgroundColorForEveryNewAddedBlackboardPage")]
public bool UseDefaultBackgroundColorForEveryNewAddedBlackboardPage { get; set; } = false; public bool UseDefaultBackgroundColorForEveryNewAddedBlackboardPage { get; set; } = false;
[JsonProperty("useDefaultBackgroundPatternForEveryNewAddedBlackboardPage")] [JsonProperty("useDefaultBackgroundPatternForEveryNewAddedBlackboardPage")]
public bool UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage { get; set; } = false; public bool UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage { get; set; } = false;
[JsonProperty("isEnableAutoConvertInkColorWhenBackgroundChanged")] [JsonProperty("isEnableAutoConvertInkColorWhenBackgroundChanged")]
public bool IsEnableAutoConvertInkColorWhenBackgroundChanged { get; set; } = false; public bool IsEnableAutoConvertInkColorWhenBackgroundChanged { get; set; } = false;
[JsonProperty("ApplyScaleToStylusTip")]
public bool ApplyScaleToStylusTip { get; set; } = false;
[JsonProperty("onlyHitTestFullyContainedStrokes")]
public bool OnlyHitTestFullyContainedStrokes { get; set; } = false;
[JsonProperty("allowClickToSelectLockedStroke")]
public bool AllowClickToSelectLockedStroke { get; set; } = false;
[JsonProperty("selectionMethod")]
public int SelectionMethod { get; set; } = 0;
} }
public enum OptionalOperation public enum OptionalOperation

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB