Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c70f35714 | |||
| 7b4d13c16f | |||
| 0e561ad24e | |||
| d09d8223c9 | |||
| 6dafde9735 | |||
| a0f84bf017 | |||
| 7049c53889 | |||
| 7750fa799d | |||
| 5f828736de |
@@ -1 +1 @@
|
||||
1.4.7
|
||||
1.6.3
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.0.2.0")]
|
||||
[assembly: AssemblyFileVersion("5.0.2.0")]
|
||||
[assembly: AssemblyVersion("1.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.3.0")]
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
string localVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
string remoteAddress = proxy;
|
||||
remoteAddress += "https://github.com/CJKmkp/ICC-CE/blob/main/AutomaticUpdateVersionControl.txt";
|
||||
remoteAddress += "https://github.com/awesome-iwb/icc-ce/blob/main/AutomaticUpdateVersionControl.txt";
|
||||
string remoteVersion = await GetRemoteVersion(remoteAddress);
|
||||
|
||||
if (remoteVersion != null)
|
||||
@@ -85,10 +86,11 @@ namespace Ink_Canvas.Helpers
|
||||
return true;
|
||||
}
|
||||
|
||||
string downloadUrl = $"{proxy}https://github.com/ChangSakura/Ink-Canvas/releases/download/v{version}/Ink.Canvas.Annotation.V{version}.Setup.exe";
|
||||
string downloadUrl = $"{proxy}https://github.com/awesome-iwb/icc-ce/releases/download/{version}/InkCanvasForClass.CE.{version}.zip";
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
await DownloadFile(downloadUrl, $"{updatesFolderPath}\\Ink.Canvas.Annotation.V{version}.Setup.exe");
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
await DownloadFile(downloadUrl, zipFilePath);
|
||||
SaveDownloadStatus(true);
|
||||
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Setup file successfully downloaded.");
|
||||
@@ -96,7 +98,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading and installing update: {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading update: {ex.Message}", LogHelper.LogType.Error);
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
return false;
|
||||
@@ -155,21 +157,43 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
string setupFilePath = Path.Combine(updatesFolderPath, $"Ink.Canvas.Annotation.V{version}.Setup.exe");
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
|
||||
if (!File.Exists(setupFilePath))
|
||||
if (!File.Exists(zipFilePath))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Setup file not found: {setupFilePath}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP file not found: {zipFilePath}", LogHelper.LogType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string InstallCommand = $"\"{setupFilePath}\" /SILENT";
|
||||
if (isInSilence) InstallCommand += " /VERYSILENT";
|
||||
ExecuteCommandLine(InstallCommand);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
// 创建临时解压目录
|
||||
string extractPath = Path.Combine(updatesFolderPath, $"Extract_{version}");
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
Directory.CreateDirectory(extractPath);
|
||||
|
||||
// 解压ZIP文件
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Extracting ZIP file to: {extractPath}");
|
||||
ZipFile.ExtractToDirectory(zipFilePath, extractPath);
|
||||
|
||||
// 获取当前应用程序路径
|
||||
string currentAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Current application directory: {currentAppDir}");
|
||||
|
||||
// 复制解压的文件到应用程序目录
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Copying files to application directory");
|
||||
CopyDirectory(extractPath, currentAppDir);
|
||||
|
||||
// 清理临时文件
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
|
||||
// 重启应用程序
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Update completed, restarting application");
|
||||
RestartApplication();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -177,6 +201,49 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDir, string destinationDir)
|
||||
{
|
||||
// 创建目标目录(如果不存在)
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
// 复制所有文件
|
||||
foreach (string filePath in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destPath = Path.Combine(destinationDir, fileName);
|
||||
try
|
||||
{
|
||||
// 如果目标文件存在,先删除
|
||||
if (File.Exists(destPath))
|
||||
{
|
||||
File.Delete(destPath);
|
||||
}
|
||||
File.Copy(filePath, destPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error copying file {fileName}: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归复制所有子目录
|
||||
foreach (string subDirPath in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
string subDirName = Path.GetFileName(subDirPath);
|
||||
string destSubDir = Path.Combine(destinationDir, subDirName);
|
||||
CopyDirectory(subDirPath, destSubDir);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RestartApplication()
|
||||
{
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
Process.Start(appPath);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
private static void ExecuteCommandLine(string command)
|
||||
{
|
||||
|
||||
+400
-53
@@ -53,9 +53,72 @@
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen3" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen4" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_ChangeToPen5" Text=" " />
|
||||
<RoutedUICommand x:Key="HotKey_DrawLine" Text=" " />
|
||||
<RoutedUICommand x:Key="NothingWillHappened" Text=" " />
|
||||
</Window.Resources>
|
||||
<RoutedUICommand x:Key="HotKey_DrawLine" Text=" " />
|
||||
<RoutedUICommand x:Key="NothingWillHappened" Text=" " />
|
||||
|
||||
<!-- Navigation Button Style -->
|
||||
<Style x:Key="NavButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#27272a"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</Trigger>
|
||||
<!-- 使用多个DataTrigger替代动态绑定 -->
|
||||
<DataTrigger Binding="{Binding Tag}" Value="startup">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="canvas">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="gesture">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="inkrecognition">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="crashaction">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="ppt">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="advanced">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="automation">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="randomwindow">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="theme">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="shortcuts">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Tag}" Value="about">
|
||||
<Setter Property="Background" Value="#3b82f6"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<!--输入命令绑定-->
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Gesture="Escape" Command="{StaticResource KeyExit}" />
|
||||
@@ -109,13 +172,301 @@
|
||||
<!--// 设置界面 //-->
|
||||
<Grid Panel.ZIndex="999" x:Name="BorderSettingsMask" MouseDown="SettingsOverlayClick" IsHitTestVisible="False"
|
||||
Margin="0,0,0,0">
|
||||
<Border Name="BorderSettings" Background="#ee18181b" ui:ThemeManager.RequestedTheme="Dark" Width="440"
|
||||
<Border Name="BorderSettings" Background="#ee18181b" ui:ThemeManager.RequestedTheme="Dark" Width="490"
|
||||
HorizontalAlignment="Left" Margin="300,150,0,350" Visibility="Visible">
|
||||
<Grid>
|
||||
<ui:ScrollViewerEx Margin="0,80,0,50" VerticalScrollBarVisibility="Auto"
|
||||
PanningMode="VerticalOnly" ui:ThemeManager.RequestedTheme="Dark"
|
||||
ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback"
|
||||
Name="SettingsPanelScrollViewer">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Navigation Sidebar -->
|
||||
<Border Grid.Column="0" Background="#1e1e1e" BorderBrush="#27272a" BorderThickness="0,0,1,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 顶部Logo区域 -->
|
||||
<Border Grid.Row="0" Height="50" Background="#2d2d30" BorderBrush="#3f3f46" BorderThickness="0,0,0,1">
|
||||
<Image Width="30" Height="30" Source="/Resources/icc.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
</Border>
|
||||
|
||||
<!-- 主要导航按钮 -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel>
|
||||
<!-- Startup -->
|
||||
<Button Width="40" Height="40" Margin="0,10,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavStartup_Click" Tag="startup" ToolTip="启动设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M2.81,14.12L5.64,11.29L8.17,10.79C11.39,6.41 17.55,4.22 19.78,4.22C19.78,6.45 17.59,12.61 13.21,15.83L12.71,18.36L9.88,21.19L9.17,17.66C7.76,17.66 7.76,17.66 7.05,16.95C6.34,16.24 6.34,16.24 6.34,14.83L2.81,14.12M5.64,16.95L7.05,18.36L4.39,21.03H2.97V19.61L5.64,16.95M4.22,15.54L5.46,15.71L3,18.16V16.74L4.22,15.54M8.29,18.54L8.46,19.78L7.26,21H5.84L8.29,18.54M13,9.5A1.5,1.5 0 0,0 11.5,11A1.5,1.5 0 0,0 13,12.5A1.5,1.5 0 0,0 14.5,11A1.5,1.5 0 0,0 13,9.5Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Canvas -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavCanvas_Click" Tag="canvas" ToolTip="画布设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M19,1L17.74,3.75L15,5L17.74,6.26L19,9L20.25,6.26L23,5L20.25,3.75M9,4L6.5,9.5L1,12L6.5,14.5L9,20L11.5,14.5L17,12L11.5,9.5"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Gesture -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavGesture_Click" Tag="gesture" ToolTip="手势设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Ink Recognition -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavInkRecognition_Click" Tag="inkrecognition" ToolTip="墨迹识别">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Crash Action -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavCrashAction_Click" Tag="crashaction" ToolTip="崩溃处理">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- PPT -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavPPT_Click" Tag="ppt" ToolTip="PPT设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M2 2H22V4H2V2M2 8H22V10H2V8M2 14H22V16H2V14M2 20H22V22H2V20Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Advanced -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAdvanced_Click" Tag="advanced" ToolTip="高级设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Automation -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAutomation_Click" Tag="automation" ToolTip="自动化设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,0C8.96,0 6.21,1.23 4.22,3.22L5.63,4.63C7.24,3.01 9.5,2 12,2C14.5,2 16.76,3.01 18.36,4.63L19.77,3.22C17.79,1.23 15.04,0 12,0M7.05,6.05L8.46,7.46C9.37,6.56 10.62,6 12,6C13.38,6 14.63,6.56 15.54,7.46L16.95,6.05C15.68,4.78 13.93,4 12,4C10.07,4 8.32,4.78 7.05,6.05M12,15A2,2 0 0,1 10,13A2,2 0 0,1 12,11A2,2 0 0,1 14,13A2,2 0 0,1 12,15M15,9H9A1,1 0 0,0 8,10V22A1,1 0 0,0 9,23H15A1,1 0 0,0 16,22V10A1,1 0 0,0 15,9Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- Random Window -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavRandomWindow_Click" Tag="randomwindow" ToolTip="随机窗口设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M4,4V16H8.83L12,19.17L15.17,16H20V4H4M6,7H18V9H6V7M6,11H16V13H6V11Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- 新增:个性化设置 -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavTheme_Click" Tag="theme" ToolTip="个性化设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M12,18V6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,15.31L23.31,12L20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- 新增:快捷键设置 -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavShortcuts_Click" Tag="shortcuts" ToolTip="快捷键设置">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20,5H4A2,2 0 0,0 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7A2,2 0 0,0 20,5M20,17H4V7H20V17M5,8H7V10H5V8M8,8H10V10H8V8M11,8H13V10H11V8M14,8H16V10H14V8M17,8H19V10H17V8M5,11H7V13H5V11M8,11H10V13H8V11M11,11H13V13H11V11M14,11H16V13H14V11M17,11H19V13H17V11M8,14H16V16H8V14Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
|
||||
<!-- About -->
|
||||
<Button Width="40" Height="40" Margin="0,5,0,0" Style="{StaticResource NavButton}"
|
||||
Click="NavAbout_Click" Tag="about" ToolTip="关于">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<StackPanel Grid.Row="2" Margin="0,5,0,10">
|
||||
<Separator Background="#3f3f46" Margin="5,0,5,10"/>
|
||||
|
||||
<!-- 折叠侧边栏按钮 -->
|
||||
<Button Width="40" Height="40" Style="{StaticResource NavButton}"
|
||||
Click="CollapseNavSidebar_Click" ToolTip="折叠侧边栏">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Content Area -->
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Grid ClipToBounds="True" Grid.Row="0" Margin="0,0,0,0" Height="80" VerticalAlignment="Top">
|
||||
<Border Background="#18181b" CornerRadius="0" Margin="-1,-1,-1,0">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<!-- 显示侧边栏按钮 -->
|
||||
<Button Width="40" Height="40" Margin="10,0,0,0" Style="{StaticResource NavButton}"
|
||||
Click="ShowNavSidebar_Click" ToolTip="显示侧边栏">
|
||||
<Image Width="24" Height="24">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Button>
|
||||
<TextBlock Foreground="White" Margin="15,-2,0,0" Text="设置" FontWeight="Bold"
|
||||
FontSize="32" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<Canvas>
|
||||
<Image Canvas.Top="12" Canvas.Right="-16" Width="98" Height="98" Opacity="0.4">
|
||||
<Image.RenderTransform>
|
||||
<!-- giving the transform a name tells the framework not to freeze it -->
|
||||
<RotateTransform CenterX="49" CenterY="49" />
|
||||
</Image.RenderTransform>
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V257 H257 V0 H0 Z">
|
||||
<GeometryDrawing Brush="GhostWhite"
|
||||
Geometry="F0 M257,257z M0,0z M93.339,256.594L88.2444,215.634C85.4849,214.567 82.8846,213.287 80.4434,211.794 78.0023,210.301 75.6142,208.701 73.2793,206.994L35.3887,222.994 0.363831,162.194 33.1598,137.234C32.9476,135.741,32.8414,134.301,32.8414,132.914L32.8414,124.274C32.8414,122.887,32.9476,121.447,33.1598,119.954L0.363831,94.9941 35.3887,34.1941 73.2793,50.1941C75.6142,48.4874 78.0554,46.8874 80.6026,45.3941 83.1499,43.9007 85.6972,42.6207 88.2444,41.5541L93.339,0.594055 163.389,0.594055 168.483,41.5541C171.243,42.6207 173.843,43.9007 176.284,45.3941 178.725,46.8874 181.113,48.4874 183.448,50.1941L221.339,34.1941 256.364,94.9941 223.568,119.954C223.78,121.447,223.886,122.887,223.886,124.274L223.886,132.914C223.886,134.301,223.674,135.741,223.249,137.234L256.045,162.194 221.021,222.994 183.448,206.994C181.113,208.701 178.672,210.301 176.125,211.794 173.578,213.287 171.031,214.567 168.483,215.634L163.389,256.594 93.339,256.594z M160.523,160.274C151.82,169.021 141.312,173.394 129.001,173.394 116.477,173.394 105.916,169.021 97.3191,160.274 88.722,151.527 84.4235,140.967 84.4235,128.594 84.4235,116.221 88.722,105.661 97.3191,96.9141 105.916,88.1674 116.477,83.7941 129.001,83.7941 141.312,83.7941 151.82,88.1674 160.523,96.9141 169.226,105.661 173.578,116.221 173.578,128.594 173.578,140.967 169.226,151.527 160.523,160.274z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
<Image.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
|
||||
To="-360" Duration="0:0:3" RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Image.Triggers>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<ui:ScrollViewerEx Grid.Row="1" Margin="0,0,0,0" VerticalScrollBarVisibility="Auto"
|
||||
PanningMode="VerticalOnly" ui:ThemeManager.RequestedTheme="Dark"
|
||||
ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback"
|
||||
Name="SettingsPanelScrollViewer">
|
||||
<StackPanel Margin="20,20,20,20">
|
||||
|
||||
<Border Margin="0,0,0,10" Height="100" CornerRadius="5" BorderBrush="#a1a1aa"
|
||||
@@ -589,7 +940,17 @@
|
||||
<TextBlock Foreground="#fafafa" Text="{Binding ElementName=AutoStraightenLineThresholdSlider, Path=Value, StringFormat={}{0:0}}"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="16,0,0,0" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,当绘制的直线超过设定长度阈值时,将自动调整为完美直线。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"
|
||||
Visibility="{Binding ElementName=ToggleSwitchAutoStraightenLine, Path=IsOn, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<TextBlock Foreground="#fafafa" Text="灵敏度" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Slider Name="LineStraightenSensitivitySlider" Width="150" Minimum="0.05" Maximum="0.75"
|
||||
Value="0.10" TickFrequency="0.05" IsSnapToTickEnabled="True"
|
||||
ValueChanged="LineStraightenSensitivitySlider_ValueChanged" />
|
||||
<TextBlock Foreground="#fafafa" Text="{Binding ElementName=LineStraightenSensitivitySlider, Path=Value, StringFormat={}{0:F2}}"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="16,0,0,0" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock Text="# 开启后,当绘制的直线超过设定长度阈值时,将自动调整为完美直线。灵敏度范围0.05-0.75,越小要求越严格,弯曲的线条越不容易被拉直;值越大越容易识别为直线。" TextWrapping="Wrap" Foreground="#a1a1aa" />
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
|
||||
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
@@ -2071,7 +2432,7 @@
|
||||
<ui:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock FontSize="18" FontWeight="Bold" Text="Version:" />
|
||||
<TextBlock x:Name="AppVersionTextBlock" FontSize="18" FontWeight="Bold"
|
||||
Text="5.X.X.X" />
|
||||
Text="1.X.X.X" />
|
||||
</ui:SimpleStackPanel>
|
||||
<TextBlock
|
||||
Text="# 使用和分发本软件前,请您应当且务必知晓相关开源协议,且您应当知晓本软件基于 https://github.com/WXRIW/Ink-Canvas 修改而成。"
|
||||
@@ -2385,55 +2746,41 @@
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</ui:ScrollViewerEx>
|
||||
<Grid ClipToBounds="True" Margin="0,0,0,0" Height="80" VerticalAlignment="Top">
|
||||
<Border Background="#18181b" CornerRadius="0" Margin="-1,-1,-1,0">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Foreground="White" Margin="25,-2,0,0" Text="设置" FontWeight="Bold"
|
||||
FontSize="32" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<Canvas>
|
||||
<Image Canvas.Top="12" Canvas.Right="-16" Width="98" Height="98" Opacity="0.4">
|
||||
<Image.RenderTransform>
|
||||
<!-- giving the transform a name tells the framework not to freeze it -->
|
||||
<RotateTransform CenterX="49" CenterY="49" />
|
||||
</Image.RenderTransform>
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V257 H257 V0 H0 Z">
|
||||
<GeometryDrawing Brush="GhostWhite"
|
||||
Geometry="F0 M257,257z M0,0z M93.339,256.594L88.2444,215.634C85.4849,214.567 82.8846,213.287 80.4434,211.794 78.0023,210.301 75.6142,208.701 73.2793,206.994L35.3887,222.994 0.363831,162.194 33.1598,137.234C32.9476,135.741,32.8414,134.301,32.8414,132.914L32.8414,124.274C32.8414,122.887,32.9476,121.447,33.1598,119.954L0.363831,94.9941 35.3887,34.1941 73.2793,50.1941C75.6142,48.4874 78.0554,46.8874 80.6026,45.3941 83.1499,43.9007 85.6972,42.6207 88.2444,41.5541L93.339,0.594055 163.389,0.594055 168.483,41.5541C171.243,42.6207 173.843,43.9007 176.284,45.3941 178.725,46.8874 181.113,48.4874 183.448,50.1941L221.339,34.1941 256.364,94.9941 223.568,119.954C223.78,121.447,223.886,122.887,223.886,124.274L223.886,132.914C223.886,134.301,223.674,135.741,223.249,137.234L256.045,162.194 221.021,222.994 183.448,206.994C181.113,208.701 178.672,210.301 176.125,211.794 173.578,213.287 171.031,214.567 168.483,215.634L163.389,256.594 93.339,256.594z M160.523,160.274C151.82,169.021 141.312,173.394 129.001,173.394 116.477,173.394 105.916,169.021 97.3191,160.274 88.722,151.527 84.4235,140.967 84.4235,128.594 84.4235,116.221 88.722,105.661 97.3191,96.9141 105.916,88.1674 116.477,83.7941 129.001,83.7941 141.312,83.7941 151.82,88.1674 160.523,96.9141 169.226,105.661 173.578,116.221 173.578,128.594 173.578,140.967 169.226,151.527 160.523,160.274z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
<Image.Triggers>
|
||||
<EventTrigger RoutedEvent="Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
|
||||
To="-360" Duration="0:0:3" RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Image.Triggers>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
<Grid VerticalAlignment="Bottom" Height="50">
|
||||
<Button FontFamily="Microsoft YaHei UI"
|
||||
|
||||
<!-- 底部按钮区域 -->
|
||||
<Grid Grid.Row="2" VerticalAlignment="Bottom" Height="50">
|
||||
<Button FontFamily="Microsoft YaHei UI"
|
||||
Width="120" Margin="10"
|
||||
HorizontalAlignment="Right"
|
||||
Content="关闭"
|
||||
Click="BtnSettings_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
Click="BtnCloseSettings_Click">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center" Spacing="0">
|
||||
<Image RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Margin="0,0,6,0" Height="20" Width="20">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
|
||||
<GeometryDrawing Brush="White"
|
||||
Geometry="M19,6.41 L17.59,5 L12,10.59 L6.41,5 L5,6.41 L10.59,12 L5,17.59 L6.41,19 L12,13.41 L17.59,19 L19,17.59 L13.41,12 Z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Label FontSize="16" Foreground="#fafafa" VerticalAlignment="Center"
|
||||
FontFamily="Microsoft YaHei UI" FontWeight="Bold">
|
||||
关闭
|
||||
</Label>
|
||||
</ui:SimpleStackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid></Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
<!--// 黑/白 板幕布 //-->
|
||||
<Grid Name="GridBackgroundCoverHolder">
|
||||
<Grid Name="GridBackgroundCover" Visibility="Collapsed" Background="#1F1F1F">
|
||||
|
||||
+263
-46
@@ -18,6 +18,9 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -154,28 +157,9 @@ namespace Ink_Canvas {
|
||||
private void inkCanvas_EditingModeChanged(object sender, RoutedEventArgs e) {
|
||||
var inkCanvas1 = sender as InkCanvas;
|
||||
if (inkCanvas1 == null) return;
|
||||
// 修复"显示画笔光标"选项不可用的问题
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas1.UseCustomCursor = true;
|
||||
// 修复触屏和数位笔时光标不显示:强制显示光标,不再依赖鼠标或触控状态
|
||||
inkCanvas1.ForceCursor = true;
|
||||
|
||||
// 根据编辑模式设置不同的光标
|
||||
if (inkCanvas1.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Eraser.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
inkCanvas1.Cursor = new Cursor(sri.Stream);
|
||||
} else if (inkCanvas1.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
inkCanvas1.Cursor = new Cursor(sri.Stream);
|
||||
} else if (inkCanvas1.EditingMode == InkCanvasEditingMode.Select) {
|
||||
inkCanvas1.Cursor = Cursors.Cross;
|
||||
}
|
||||
} else {
|
||||
inkCanvas1.UseCustomCursor = false;
|
||||
inkCanvas1.ForceCursor = false;
|
||||
}
|
||||
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas1);
|
||||
|
||||
if (inkCanvas1.EditingMode == InkCanvasEditingMode.Ink) forcePointEraser = !forcePointEraser;
|
||||
}
|
||||
@@ -355,54 +339,287 @@ namespace Ink_Canvas {
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
// 添加一个辅助方法,根据当前编辑模式设置光标
|
||||
private void SetCursorBasedOnEditingMode(InkCanvas canvas)
|
||||
{
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
canvas.UseCustomCursor = true;
|
||||
canvas.ForceCursor = true;
|
||||
|
||||
// 根据编辑模式设置不同的光标
|
||||
if (canvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
canvas.Cursor = Cursors.Cross;
|
||||
} else if (canvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
canvas.Cursor = new Cursor(sri.Stream);
|
||||
} else if (canvas.EditingMode == InkCanvasEditingMode.Select) {
|
||||
canvas.Cursor = Cursors.Cross;
|
||||
}
|
||||
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
} else {
|
||||
canvas.UseCustomCursor = false;
|
||||
canvas.ForceCursor = false;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标输入
|
||||
private void inkCanvas_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
inkCanvas.Cursor = Cursors.Arrow;
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 手写笔输入
|
||||
private void inkCanvas_StylusDown(object sender, StylusDownEventArgs e)
|
||||
{
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
inkCanvas.Cursor = new Cursor(sri.Stream);
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 触摸输入,不隐藏光标
|
||||
private void inkCanvas_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
// 修改:根据用户设置决定是否强制显示自定义光标
|
||||
if (Settings.Canvas.IsShowCursor)
|
||||
{
|
||||
inkCanvas.ForceCursor = true;
|
||||
// 确保鼠标光标对触摸可见
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
// 新增:当处于套索选择模式时保持光标可见
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
||||
inkCanvas.Cursor = Cursors.Cross;
|
||||
}
|
||||
else
|
||||
{
|
||||
inkCanvas.ForceCursor = false;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
// 触摸结束,恢复光标
|
||||
private void inkCanvas_TouchUp(object sender, TouchEventArgs e)
|
||||
{
|
||||
// 修改:根据当前模式和设置恢复光标状态
|
||||
// 使用辅助方法设置光标
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
|
||||
// 确保光标可见
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
// 确保鼠标光标对触摸可见
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
} else {
|
||||
inkCanvas.ForceCursor = false;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Definations and Loading
|
||||
|
||||
#region Navigation Sidebar Methods
|
||||
|
||||
// 侧边栏导航按钮事件处理
|
||||
private void NavStartup_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到启动设置页面
|
||||
ShowSettingsSection("startup");
|
||||
}
|
||||
|
||||
private void NavCanvas_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到画布设置页面
|
||||
ShowSettingsSection("canvas");
|
||||
}
|
||||
|
||||
private void NavGesture_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到手势设置页面
|
||||
ShowSettingsSection("gesture");
|
||||
}
|
||||
|
||||
private void NavInkRecognition_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到墨迹识别设置页面
|
||||
ShowSettingsSection("inkrecognition");
|
||||
}
|
||||
|
||||
private void NavCrashAction_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到崩溃处理设置页面
|
||||
ShowSettingsSection("crashaction");
|
||||
}
|
||||
|
||||
private void NavPPT_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到PPT设置页面
|
||||
ShowSettingsSection("ppt");
|
||||
}
|
||||
|
||||
private void NavAdvanced_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到高级设置页面
|
||||
ShowSettingsSection("advanced");
|
||||
}
|
||||
|
||||
private void NavAutomation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到自动化设置页面
|
||||
ShowSettingsSection("automation");
|
||||
}
|
||||
|
||||
private void NavRandomWindow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到随机窗口设置页面
|
||||
ShowSettingsSection("randomwindow");
|
||||
}
|
||||
|
||||
private void NavAbout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到关于页面
|
||||
ShowSettingsSection("about");
|
||||
}
|
||||
|
||||
// 新增:个性化设置
|
||||
private void NavTheme_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到个性化设置页面
|
||||
ShowSettingsSection("theme");
|
||||
}
|
||||
|
||||
// 新增:快捷键设置
|
||||
private void NavShortcuts_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换到快捷键设置页面
|
||||
ShowSettingsSection("shortcuts");
|
||||
// 如果设置部分尚未快捷键
|
||||
MessageBox.Show("设置功能正在开发中", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void BtnCloseSettings_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 关闭设置面板
|
||||
BorderSettings.Visibility = Visibility.Collapsed;
|
||||
BorderSettingsMask.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
// 新增:折叠侧边栏
|
||||
private void CollapseNavSidebar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 折叠/展开侧边栏
|
||||
var columnDefinitions = ((Grid)BorderSettings.Child).ColumnDefinitions;
|
||||
if (columnDefinitions[0].Width.Value == 50)
|
||||
{
|
||||
// 折叠侧边栏
|
||||
columnDefinitions[0].Width = new GridLength(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 展开侧边栏
|
||||
columnDefinitions[0].Width = new GridLength(50);
|
||||
}
|
||||
}
|
||||
|
||||
// 新增:显示侧边栏
|
||||
private void ShowNavSidebar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 确保侧边栏展开
|
||||
var columnDefinitions = ((Grid)BorderSettings.Child).ColumnDefinitions;
|
||||
columnDefinitions[0].Width = new GridLength(50);
|
||||
}
|
||||
|
||||
// 辅助方法:显示指定的设置部分
|
||||
private void ShowSettingsSection(string sectionTag)
|
||||
{
|
||||
// 显示设置面板
|
||||
BorderSettings.Visibility = Visibility.Visible;
|
||||
BorderSettingsMask.IsHitTestVisible = true;
|
||||
|
||||
// 获取SettingsPanelScrollViewer中的所有GroupBox
|
||||
var stackPanel = SettingsPanelScrollViewer.Content as StackPanel;
|
||||
if (stackPanel == null) return;
|
||||
|
||||
// 首先隐藏所有GroupBox
|
||||
foreach (var child in stackPanel.Children)
|
||||
{
|
||||
if (child is GroupBox groupBox)
|
||||
{
|
||||
groupBox.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据传入的sectionTag显示相应的设置部分
|
||||
switch (sectionTag.ToLower())
|
||||
{
|
||||
case "startup":
|
||||
// 显示启动设置
|
||||
ShowGroupBoxByHeader(stackPanel, "启动");
|
||||
break;
|
||||
case "canvas":
|
||||
// 显示画板和墨迹设置
|
||||
ShowGroupBoxByHeader(stackPanel, "画板和墨迹");
|
||||
break;
|
||||
case "gesture":
|
||||
// 显示手势设置
|
||||
ShowGroupBoxByHeader(stackPanel, "手势");
|
||||
break;
|
||||
case "inkrecognition":
|
||||
// 显示墨迹纠正设置
|
||||
ShowGroupBoxByHeader(stackPanel, "墨迹纠正");
|
||||
if (GroupBoxInkRecognition != null)
|
||||
GroupBoxInkRecognition.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "crashaction":
|
||||
// 显示崩溃后操作设置
|
||||
ShowGroupBoxByHeader(stackPanel, "崩溃后操作");
|
||||
break;
|
||||
case "ppt":
|
||||
// 显示PPT联动设置
|
||||
ShowGroupBoxByHeader(stackPanel, "PPT联动");
|
||||
break;
|
||||
case "advanced":
|
||||
// 显示高级设置
|
||||
// 这里可能需要根据实际情况调整
|
||||
break;
|
||||
case "automation":
|
||||
// 显示自动化设置
|
||||
// 这里可能需要根据实际情况调整
|
||||
break;
|
||||
case "randomwindow":
|
||||
// 显示随机窗口设置
|
||||
if (GroupBoxRandWindow != null)
|
||||
GroupBoxRandWindow.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "theme":
|
||||
// 显示主题设置
|
||||
if (GroupBoxAppearanceNewUI != null)
|
||||
GroupBoxAppearanceNewUI.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "shortcuts":
|
||||
// 显示快捷键设置
|
||||
// 快捷键设置部分可能尚未实现
|
||||
break;
|
||||
case "about":
|
||||
// 显示关于页面
|
||||
ShowGroupBoxByHeader(stackPanel, "关于");
|
||||
break;
|
||||
default:
|
||||
// 默认显示第一个GroupBox
|
||||
if (stackPanel.Children.Count > 0 && stackPanel.Children[0] is GroupBox firstGroupBox)
|
||||
{
|
||||
firstGroupBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 滚动到顶部
|
||||
SettingsPanelScrollViewer.ScrollToTop();
|
||||
}
|
||||
|
||||
// 根据Header文本查找并显示GroupBox
|
||||
private void ShowGroupBoxByHeader(StackPanel parent, string headerText)
|
||||
{
|
||||
foreach (var child in parent.Children)
|
||||
{
|
||||
if (child is GroupBox groupBox)
|
||||
{
|
||||
// 查找GroupBox的Header
|
||||
if (groupBox.Header is TextBlock headerTextBlock &&
|
||||
headerTextBlock.Text != null &&
|
||||
headerTextBlock.Text.Contains(headerText))
|
||||
{
|
||||
groupBox.Visibility = Visibility.Visible;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Navigation Sidebar Methods
|
||||
}
|
||||
}
|
||||
@@ -749,6 +749,13 @@ namespace Ink_Canvas {
|
||||
Settings.Canvas.LineEndpointSnappingThreshold = (int)e.NewValue;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void LineStraightenSensitivitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.InkToShape.LineStraightenSensitivity = e.NewValue;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -578,6 +578,9 @@ namespace Ink_Canvas {
|
||||
ToggleCheckboxEnableInkToShapeRectangle.IsChecked = Settings.InkToShape.IsInkToShapeRectangle;
|
||||
|
||||
ToggleCheckboxEnableInkToShapeRounded.IsChecked = Settings.InkToShape.IsInkToShapeRounded;
|
||||
|
||||
// 初始化直线拉直灵敏度
|
||||
LineStraightenSensitivitySlider.Value = Settings.InkToShape.LineStraightenSensitivity;
|
||||
} else {
|
||||
Settings.InkToShape = new InkToShape();
|
||||
}
|
||||
|
||||
@@ -452,6 +452,7 @@ namespace Ink_Canvas {
|
||||
// 触摸移动时保持自定义光标显示
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true; // 确保使用自定义光标
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
|
||||
@@ -484,6 +485,12 @@ namespace Ink_Canvas {
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(boundsWidth * k * eraserMultiplier,
|
||||
boundsWidth * k * eraserMultiplier);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
||||
|
||||
// 立即应用光标设置
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
inkCanvas.Cursor = Cursors.Cross;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible && inkCanvas.Strokes.Count == 0 &&
|
||||
@@ -1669,9 +1676,24 @@ namespace Ink_Canvas {
|
||||
|
||||
private void MainWindow_OnMouseMove(object sender, MouseEventArgs e) {
|
||||
if (e.StylusDevice == null) {
|
||||
// 鼠标移动时保持光标可见
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
|
||||
// 如果用户设置了显示光标,则确保光标显示正确
|
||||
if (Settings.Canvas.IsShowCursor && inkCanvas != null) {
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
}
|
||||
} else {
|
||||
System.Windows.Forms.Cursor.Hide();
|
||||
// 只有当用户未设置显示光标时才隐藏
|
||||
if (!Settings.Canvas.IsShowCursor) {
|
||||
System.Windows.Forms.Cursor.Hide();
|
||||
} else if (inkCanvas != null) {
|
||||
// 如果用户设置了显示光标,则确保光标显示正确
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private StrokeCollection newStrokes = new StrokeCollection();
|
||||
private List<Circle> circles = new List<Circle>();
|
||||
private const double SNAP_THRESHOLD = 15.0; // Distance threshold for endpoint snapping
|
||||
private const double LINE_STRAIGHTEN_THRESHOLD = 0.10; // 降低阈值,让直线检测更严格
|
||||
|
||||
private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e) {
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
@@ -20,108 +22,146 @@ namespace Ink_Canvas {
|
||||
try {
|
||||
inkCanvas.Opacity = 1;
|
||||
|
||||
// 直线自动拉直功能
|
||||
if (Settings.Canvas.AutoStraightenLine && e.Stroke.StylusPoints.Count > 1 && drawingShapeMode == 0 && penType == 0) {
|
||||
// 获取起点和终点
|
||||
StylusPoint startPoint = e.Stroke.StylusPoints[0];
|
||||
StylusPoint endPoint = e.Stroke.StylusPoints[e.Stroke.StylusPoints.Count - 1];
|
||||
|
||||
// 计算直线长度
|
||||
double length = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
|
||||
|
||||
// 判断是否需要拉直
|
||||
if (length >= Settings.Canvas.AutoStraightenLineThreshold) {
|
||||
// 判断是否符合直线特征(计算点到直线的最大距离)
|
||||
double maxDistance = 0;
|
||||
for (int i = 1; i < e.Stroke.StylusPoints.Count - 1; i++) {
|
||||
StylusPoint point = e.Stroke.StylusPoints[i];
|
||||
double distance = DistanceFromPointToLine(point, startPoint, endPoint);
|
||||
maxDistance = Math.Max(maxDistance, distance);
|
||||
// 应用屏蔽压感功能 - 如果启用,所有笔画都使用统一粗细
|
||||
if (Settings.Canvas.DisablePressure) {
|
||||
var uniformPoints = new StylusPointCollection();
|
||||
foreach (StylusPoint point in e.Stroke.StylusPoints) {
|
||||
StylusPoint newPoint = new StylusPoint(point.X, point.Y, 0.5f); // 统一压感值为0.5
|
||||
uniformPoints.Add(newPoint);
|
||||
}
|
||||
e.Stroke.StylusPoints = uniformPoints;
|
||||
}
|
||||
// 应用压感触屏模式 - 如果启用并且检测到触屏输入
|
||||
else if (Settings.Canvas.EnablePressureTouchMode) {
|
||||
bool isTouchInput = true;
|
||||
foreach (StylusPoint point in e.Stroke.StylusPoints) {
|
||||
// 检测是否为压感笔输入(压感笔的PressureFactor不等于0.5或0)
|
||||
if ((point.PressureFactor > 0.501 || point.PressureFactor < 0.5) && point.PressureFactor != 0) {
|
||||
isTouchInput = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// 如果最大距离小于线长的15%,认为是直线
|
||||
if (maxDistance < length * 0.15) {
|
||||
// 创建新的直线点集合
|
||||
StylusPointCollection newPoints = new StylusPointCollection();
|
||||
|
||||
// 直线端点吸附功能
|
||||
if (Settings.Canvas.LineEndpointSnapping) {
|
||||
bool startPointSnapped = false;
|
||||
bool endPointSnapped = false;
|
||||
|
||||
// 获取画布上的所有笔画
|
||||
StrokeCollection allStrokes = inkCanvas.Strokes;
|
||||
|
||||
// 排除当前笔画
|
||||
StrokeCollection otherStrokes = new StrokeCollection();
|
||||
foreach (Stroke stroke in allStrokes) {
|
||||
if (stroke != e.Stroke) {
|
||||
otherStrokes.Add(stroke);
|
||||
}
|
||||
|
||||
// 如果是触屏输入,则应用模拟压感
|
||||
if (isTouchInput) {
|
||||
switch (Settings.Canvas.InkStyle) {
|
||||
case 1:
|
||||
if (penType == 0)
|
||||
try {
|
||||
var stylusPoints = new StylusPointCollection();
|
||||
var n = e.Stroke.StylusPoints.Count - 1;
|
||||
|
||||
for (var i = 0; i <= n; i++) {
|
||||
var speed = GetPointSpeed(e.Stroke.StylusPoints[Math.Max(i - 1, 0)].ToPoint(),
|
||||
e.Stroke.StylusPoints[i].ToPoint(),
|
||||
e.Stroke.StylusPoints[Math.Min(i + 1, n)].ToPoint());
|
||||
var point = new StylusPoint();
|
||||
if (speed >= 0.25)
|
||||
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1.5) - 0.3) / 1.2);
|
||||
else if (speed >= 0.05)
|
||||
point.PressureFactor = (float)0.5;
|
||||
else
|
||||
point.PressureFactor = (float)(0.5 + 0.4 * (0.05 - speed) / 0.05);
|
||||
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
}
|
||||
|
||||
// 查找最近的端点
|
||||
double minStartDistance = Settings.Canvas.LineEndpointSnappingThreshold;
|
||||
double minEndDistance = Settings.Canvas.LineEndpointSnappingThreshold;
|
||||
StylusPoint nearestToStart = startPoint;
|
||||
StylusPoint nearestToEnd = endPoint;
|
||||
|
||||
foreach (Stroke stroke in otherStrokes) {
|
||||
// 只考虑直线(只有两个点的笔画)
|
||||
if (stroke.StylusPoints.Count == 2) {
|
||||
StylusPoint strokeStart = stroke.StylusPoints[0];
|
||||
StylusPoint strokeEnd = stroke.StylusPoints[1];
|
||||
|
||||
// 计算当前笔画起点到其他笔画端点的距离
|
||||
double distanceToStrokeStart = Distance(startPoint, strokeStart);
|
||||
double distanceToStrokeEnd = Distance(startPoint, strokeEnd);
|
||||
|
||||
// 如果距离小于阈值且小于当前最小距离,更新最近点
|
||||
if (distanceToStrokeStart < minStartDistance) {
|
||||
minStartDistance = distanceToStrokeStart;
|
||||
nearestToStart = strokeStart;
|
||||
startPointSnapped = true;
|
||||
catch { }
|
||||
break;
|
||||
case 0:
|
||||
if (penType == 0)
|
||||
try {
|
||||
var stylusPoints = new StylusPointCollection();
|
||||
var n = e.Stroke.StylusPoints.Count - 1;
|
||||
var pressure = 0.1;
|
||||
var x = 10;
|
||||
if (n == 1) return;
|
||||
if (n >= x) {
|
||||
for (var i = 0; i < n - x; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)0.5;
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
|
||||
for (var i = n - x; i <= n; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)((0.5 - pressure) * (n - i) / x + pressure);
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
}
|
||||
if (distanceToStrokeEnd < minStartDistance) {
|
||||
minStartDistance = distanceToStrokeEnd;
|
||||
nearestToStart = strokeEnd;
|
||||
startPointSnapped = true;
|
||||
}
|
||||
|
||||
// 计算当前笔画终点到其他笔画端点的距离
|
||||
double distanceEndToStrokeStart = Distance(endPoint, strokeStart);
|
||||
double distanceEndToStrokeEnd = Distance(endPoint, strokeEnd);
|
||||
|
||||
// 如果距离小于阈值且小于当前最小距离,更新最近点
|
||||
if (distanceEndToStrokeStart < minEndDistance) {
|
||||
minEndDistance = distanceEndToStrokeStart;
|
||||
nearestToEnd = strokeStart;
|
||||
endPointSnapped = true;
|
||||
}
|
||||
if (distanceEndToStrokeEnd < minEndDistance) {
|
||||
minEndDistance = distanceEndToStrokeEnd;
|
||||
nearestToEnd = strokeEnd;
|
||||
endPointSnapped = true;
|
||||
else {
|
||||
for (var i = 0; i <= n; i++) {
|
||||
var point = new StylusPoint();
|
||||
|
||||
point.PressureFactor = (float)(0.4 * (n - i) / n + pressure);
|
||||
point.X = e.Stroke.StylusPoints[i].X;
|
||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||
stylusPoints.Add(point);
|
||||
}
|
||||
}
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
}
|
||||
|
||||
// 应用吸附结果
|
||||
newPoints.Add(startPointSnapped ? nearestToStart : startPoint);
|
||||
newPoints.Add(endPointSnapped ? nearestToEnd : endPoint);
|
||||
} else {
|
||||
// 不启用吸附,直接使用原始端点
|
||||
newPoints.Add(startPoint);
|
||||
newPoints.Add(endPoint);
|
||||
}
|
||||
|
||||
// 替换原有笔迹
|
||||
e.Stroke.StylusPoints = newPoints;
|
||||
catch { }
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.InkToShape.IsInkToShapeEnabled && drawingShapeMode == 0 && !isInMultiTouchMode && penType == 0) {
|
||||
// Apply line straightening and endpoint snapping if ink-to-shape is enabled
|
||||
if (Settings.InkToShape.IsInkToShapeEnabled) {
|
||||
// Check if this stroke could be a straight line
|
||||
if (IsPotentialStraightLine(e.Stroke)) {
|
||||
// Get start and end points of the stroke
|
||||
Point startPoint = e.Stroke.StylusPoints[0].ToPoint();
|
||||
Point endPoint = e.Stroke.StylusPoints[e.Stroke.StylusPoints.Count - 1].ToPoint();
|
||||
|
||||
// Try to snap endpoints to existing strokes
|
||||
bool snapped = false;
|
||||
if (Settings.InkToShape.IsInkToShapeRectangle || Settings.InkToShape.IsInkToShapeTriangle) {
|
||||
Point[] snappedPoints = GetSnappedEndpoints(startPoint, endPoint);
|
||||
if (snappedPoints != null) {
|
||||
startPoint = snappedPoints[0];
|
||||
endPoint = snappedPoints[1];
|
||||
snapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create straight line stroke
|
||||
if (snapped || ShouldStraightenLine(e.Stroke)) {
|
||||
StylusPointCollection straightLinePoints = CreateStraightLine(startPoint, endPoint);
|
||||
Stroke straightStroke = new Stroke(straightLinePoints) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
|
||||
// Replace the original stroke with the straightened one
|
||||
SetNewBackupOfStroke();
|
||||
_currentCommitType = CommitReason.ShapeRecognition;
|
||||
inkCanvas.Strokes.Remove(e.Stroke);
|
||||
inkCanvas.Strokes.Add(straightStroke);
|
||||
_currentCommitType = CommitReason.UserInput;
|
||||
|
||||
// We can't modify e.Stroke directly, but we need to update newStrokes
|
||||
// to ensure proper shape recognition for the straightened line
|
||||
if (newStrokes.Contains(e.Stroke)) {
|
||||
newStrokes.Remove(e.Stroke);
|
||||
newStrokes.Add(straightStroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.InkToShape.IsInkToShapeEnabled && !Environment.Is64BitProcess) {
|
||||
void InkToShapeProcess() {
|
||||
try {
|
||||
newStrokes.Add(e.Stroke);
|
||||
@@ -422,27 +462,13 @@ namespace Ink_Canvas {
|
||||
InkToShapeProcess();
|
||||
}
|
||||
|
||||
// 如果启用了屏蔽压感功能,强制所有点的压感值为0.5
|
||||
if (Settings.Canvas.DisablePressure) {
|
||||
var stylusPoints = new StylusPointCollection();
|
||||
foreach (var point in e.Stroke.StylusPoints) {
|
||||
var newPoint = new StylusPoint(point.X, point.Y, 0.5f);
|
||||
stylusPoints.Add(newPoint);
|
||||
}
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
return; // 跳过后续的压感处理
|
||||
}
|
||||
|
||||
// 检查是否是压感笔书写,如果启用了压感触屏模式则跳过此检查
|
||||
if (!Settings.Canvas.EnablePressureTouchMode) {
|
||||
foreach (var stylusPoint in e.Stroke.StylusPoints)
|
||||
//LogHelper.WriteLogToFile(stylusPoint.PressureFactor.ToString(), LogHelper.LogType.Info);
|
||||
// 检查是否是压感笔书写
|
||||
//if (stylusPoint.PressureFactor != 0.5 && stylusPoint.PressureFactor != 0)
|
||||
if ((stylusPoint.PressureFactor > 0.501 || stylusPoint.PressureFactor < 0.5) &&
|
||||
stylusPoint.PressureFactor != 0)
|
||||
return;
|
||||
}
|
||||
foreach (var stylusPoint in e.Stroke.StylusPoints)
|
||||
//LogHelper.WriteLogToFile(stylusPoint.PressureFactor.ToString(), LogHelper.LogType.Info);
|
||||
// 检查是否是压感笔书写
|
||||
//if (stylusPoint.PressureFactor != 0.5 && stylusPoint.PressureFactor != 0)
|
||||
if ((stylusPoint.PressureFactor > 0.501 || stylusPoint.PressureFactor < 0.5) &&
|
||||
stylusPoint.PressureFactor != 0)
|
||||
return;
|
||||
|
||||
try {
|
||||
if (e.Stroke.StylusPoints.Count > 3) {
|
||||
@@ -538,6 +564,203 @@ namespace Ink_Canvas {
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
|
||||
// New method: Checks if a stroke is potentially a straight line
|
||||
private bool IsPotentialStraightLine(Stroke stroke) {
|
||||
// 确保有足够的点来进行线条分析
|
||||
if (stroke.StylusPoints.Count < 5)
|
||||
return false;
|
||||
|
||||
Point start = stroke.StylusPoints.First().ToPoint();
|
||||
Point end = stroke.StylusPoints.Last().ToPoint();
|
||||
double lineLength = GetDistance(start, end);
|
||||
|
||||
// 线条必须足够长才考虑拉直,至少30像素
|
||||
if (lineLength < 30)
|
||||
return false;
|
||||
|
||||
// 获取用户设置的灵敏度值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
// 快速检查使用略宽松的阈值
|
||||
double quickThreshold = Math.Min(sensitivity * 1.5, 0.20);
|
||||
|
||||
// 快速检查:计算几个关键点与直线的距离
|
||||
if (stroke.StylusPoints.Count >= 10) {
|
||||
// 取中点和1/4、3/4位置的点,快速检查偏差
|
||||
int quarterIdx = stroke.StylusPoints.Count / 4;
|
||||
int midIdx = stroke.StylusPoints.Count / 2;
|
||||
int threeQuarterIdx = quarterIdx * 3;
|
||||
|
||||
Point quarterPoint = stroke.StylusPoints[quarterIdx].ToPoint();
|
||||
Point midPoint = stroke.StylusPoints[midIdx].ToPoint();
|
||||
Point threeQuarterPoint = stroke.StylusPoints[threeQuarterIdx].ToPoint();
|
||||
|
||||
double quarterDeviation = DistanceFromLineToPoint(start, end, quarterPoint);
|
||||
double midDeviation = DistanceFromLineToPoint(start, end, midPoint);
|
||||
double threeQuarterDeviation = DistanceFromLineToPoint(start, end, threeQuarterPoint);
|
||||
|
||||
// 如果任一点偏离太大,直接排除
|
||||
double quickRelativeThreshold = lineLength * quickThreshold;
|
||||
if (quarterDeviation > quickRelativeThreshold ||
|
||||
midDeviation > quickRelativeThreshold ||
|
||||
threeQuarterDeviation > quickRelativeThreshold) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Determines if a stroke should be straightened into a line
|
||||
private bool ShouldStraightenLine(Stroke stroke) {
|
||||
// Basic implementation: check if points roughly follow a straight line
|
||||
Point start = stroke.StylusPoints.First().ToPoint();
|
||||
Point end = stroke.StylusPoints.Last().ToPoint();
|
||||
|
||||
// Calculate max deviation from the straight line between start and end
|
||||
double maxDeviation = 0;
|
||||
double lineLength = GetDistance(start, end);
|
||||
|
||||
// 如果线条太短,不进行拉直处理
|
||||
if (lineLength < 50) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取用户设置的灵敏度值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 计算点与直线的偏差
|
||||
double totalDeviation = 0;
|
||||
int pointCount = 0;
|
||||
|
||||
// Calculate deviation for each point
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
maxDeviation = Math.Max(maxDeviation, deviation);
|
||||
totalDeviation += deviation;
|
||||
pointCount++;
|
||||
}
|
||||
|
||||
// 计算平均偏差
|
||||
double avgDeviation = totalDeviation / pointCount;
|
||||
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查中点偏离情况 - 针对弧形线条特别有效
|
||||
if (stroke.StylusPoints.Count > 10) {
|
||||
int midIndex = stroke.StylusPoints.Count / 2;
|
||||
Point midPoint = stroke.StylusPoints[midIndex].ToPoint();
|
||||
double midDeviation = DistanceFromLineToPoint(start, end, midPoint);
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Creates a straight line stroke between two points
|
||||
private StylusPointCollection CreateStraightLine(Point start, Point end) {
|
||||
StylusPointCollection points = new StylusPointCollection();
|
||||
|
||||
// Create a more natural pressure profile for the line
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
points.Add(new StylusPoint(start.X, start.Y));
|
||||
points.Add(new StylusPoint(end.X, end.Y));
|
||||
} else {
|
||||
points.Add(new StylusPoint(start.X, start.Y, 0.4f));
|
||||
|
||||
// Add a middle point with higher pressure
|
||||
Point midPoint = new Point((start.X + end.X) / 2, (start.Y + end.Y) / 2);
|
||||
points.Add(new StylusPoint(midPoint.X, midPoint.Y, 0.8f));
|
||||
|
||||
points.Add(new StylusPoint(end.X, end.Y, 0.4f));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
// New method: Gets distance from point to a line defined by two points
|
||||
private double DistanceFromLineToPoint(Point lineStart, Point lineEnd, Point point) {
|
||||
// Calculate distance from point to line defined by lineStart and lineEnd
|
||||
double lineLength = GetDistance(lineStart, lineEnd);
|
||||
if (lineLength == 0) return GetDistance(point, lineStart);
|
||||
|
||||
// Calculate the cross product to get the perpendicular distance
|
||||
double distance = Math.Abs((lineEnd.Y - lineStart.Y) * point.X -
|
||||
(lineEnd.X - lineStart.X) * point.Y +
|
||||
lineEnd.X * lineStart.Y - lineEnd.Y * lineStart.X) / lineLength;
|
||||
return distance;
|
||||
}
|
||||
|
||||
// New method: Attempts to snap endpoints to existing stroke endpoints
|
||||
private Point[] GetSnappedEndpoints(Point start, Point end) {
|
||||
bool startSnapped = false;
|
||||
bool endSnapped = false;
|
||||
Point snappedStart = start;
|
||||
Point snappedEnd = end;
|
||||
|
||||
// Check all strokes in canvas for potential snap points
|
||||
foreach (Stroke stroke in inkCanvas.Strokes) {
|
||||
if (stroke.StylusPoints.Count == 0) continue;
|
||||
|
||||
// Get stroke endpoints
|
||||
Point strokeStart = stroke.StylusPoints.First().ToPoint();
|
||||
Point strokeEnd = stroke.StylusPoints.Last().ToPoint();
|
||||
|
||||
// Check if start point should snap to an endpoint
|
||||
if (!startSnapped) {
|
||||
if (GetDistance(start, strokeStart) < SNAP_THRESHOLD) {
|
||||
snappedStart = strokeStart;
|
||||
startSnapped = true;
|
||||
} else if (GetDistance(start, strokeEnd) < SNAP_THRESHOLD) {
|
||||
snappedStart = strokeEnd;
|
||||
startSnapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if end point should snap to an endpoint
|
||||
if (!endSnapped) {
|
||||
if (GetDistance(end, strokeStart) < SNAP_THRESHOLD) {
|
||||
snappedEnd = strokeStart;
|
||||
endSnapped = true;
|
||||
} else if (GetDistance(end, strokeEnd) < SNAP_THRESHOLD) {
|
||||
snappedEnd = strokeEnd;
|
||||
endSnapped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If both endpoints are snapped, we're done
|
||||
if (startSnapped && endSnapped) break;
|
||||
}
|
||||
|
||||
// Return snapped points if any snapping occurred
|
||||
if (startSnapped || endSnapped) {
|
||||
return new Point[] { snappedStart, snappedEnd };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SetNewBackupOfStroke() {
|
||||
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
||||
var whiteboardIndex = CurrentWhiteboardIndex;
|
||||
@@ -656,31 +879,5 @@ namespace Ink_Canvas {
|
||||
public StylusPoint GetCenterPoint(StylusPoint point1, StylusPoint point2) {
|
||||
return new StylusPoint((point1.X + point2.X) / 2, (point1.Y + point2.Y) / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算点到直线的距离
|
||||
/// </summary>
|
||||
/// <param name="point">点</param>
|
||||
/// <param name="lineStart">直线起点</param>
|
||||
/// <param name="lineEnd">直线终点</param>
|
||||
/// <returns>距离</returns>
|
||||
private double DistanceFromPointToLine(StylusPoint point, StylusPoint lineStart, StylusPoint lineEnd) {
|
||||
double lineLength = Math.Sqrt(Math.Pow(lineEnd.X - lineStart.X, 2) + Math.Pow(lineEnd.Y - lineStart.Y, 2));
|
||||
if (lineLength == 0) return 0;
|
||||
|
||||
double area = Math.Abs(
|
||||
(lineEnd.X - lineStart.X) * (lineStart.Y - point.Y) -
|
||||
(lineStart.X - point.X) * (lineEnd.Y - lineStart.Y)
|
||||
);
|
||||
|
||||
return area / lineLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算两点之间的距离
|
||||
/// </summary>
|
||||
private double Distance(StylusPoint p1, StylusPoint p2) {
|
||||
return Math.Sqrt(Math.Pow(p2.X - p1.X, 2) + Math.Pow(p2.Y - p1.Y, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("5.0.5.1")]
|
||||
[assembly: AssemblyFileVersion("5.0.5.1")]
|
||||
[assembly: AssemblyVersion("1.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.3.0")]
|
||||
@@ -409,6 +409,8 @@ namespace Ink_Canvas
|
||||
public bool IsInkToShapeRectangle { get; set; } = true;
|
||||
[JsonProperty("isInkToShapeRounded")]
|
||||
public bool IsInkToShapeRounded { get; set; } = true;
|
||||
[JsonProperty("lineStraightenSensitivity")]
|
||||
public double LineStraightenSensitivity { get; set; } = 0.10; // 直线检测灵敏度,值越小越严格(0.05-0.75)
|
||||
}
|
||||
|
||||
public class RandSettings {
|
||||
|
||||
@@ -373,15 +373,6 @@ E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.g.cs
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\GeneratedInternalTypeHelper.g.cs
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass_MarkupCompile.cache
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass_MarkupCompile.lref
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\MainWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CountdownTimerWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CycleProcessBar.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\HasNewUpdateWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\NamesInputWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\OperatingGuideWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\RandWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\YesOrNoNotificationWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.g.resources
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Ink_Canvas.Properties.Resources.resources
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.csproj.GenerateResource.cache
|
||||
@@ -391,3 +382,12 @@ E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.sourc
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanva.0F57E7D5.Up2Date
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.exe
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\InkCanvasForClass.exe.config
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\App.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\MainWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CountdownTimerWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\CycleProcessBar.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\HasNewUpdateWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\NamesInputWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\OperatingGuideWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\RandWindow.baml
|
||||
E:\ICC CE\ICC CE main\ICC-CE\Ink Canvas\obj\Debug\net472\Windows\YesOrNoNotificationWindow.baml
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+3649
-3520
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user