Compare commits

...

10 Commits

Author SHA1 Message Date
CJK_mkp c42c6c8dfe Merge pull request #37 from awesome-iwb/beta
ICC CE 1.6.7 (ICC CE Beta 1.6.14)
2025-06-19 14:38:19 +08:00
CJKmkp 316d568cbc 更新版本号 2025-06-19 14:33:01 +08:00
CJKmkp 0b72b1f1b3 fix:设置窗口关闭导致的无法点击 2025-06-19 14:32:16 +08:00
CJKmkp 25b52def92 fix:直线拉直及端点吸附 2025-06-19 14:30:24 +08:00
CJK_mkp ab67ea48f0 Merge pull request #36 from awesome-iwb/beta
ICC CE 1.6.6 (ICC CE Beta 1.6.13)
2025-06-19 12:00:20 +08:00
CJK_mkp 912c1b91e4 更新版本号 2025-06-19 11:56:36 +08:00
CJK_mkp d4f1d21634 improve:静默更新 2025-06-19 11:47:16 +08:00
CJK_mkp 6c0e7c2e64 fix:触屏类问题及设置内点击问题 2025-06-19 11:25:15 +08:00
CJK_mkp e054a50b55 Merge pull request #35 from awesome-iwb/beta
Update AutomaticUpdateVersionControl.txt
2025-06-18 23:09:27 +08:00
CJK_mkp ff005e6398 Update AutomaticUpdateVersionControl.txt 2025-06-18 23:08:47 +08:00
17 changed files with 481 additions and 219 deletions
+1 -1
View File
@@ -1 +1 @@
1.6.4
1.6.7
+2 -2
View File
@@ -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("1.6.5")]
[assembly: AssemblyFileVersion("1.6.5")]
[assembly: AssemblyVersion("1.6.7")]
[assembly: AssemblyFileVersion("1.6.7")]
+36 -11
View File
@@ -411,6 +411,7 @@ namespace Ink_Canvas.Helpers
LogHelper.WriteLogToFile($"AutoUpdate | Current application directory: {currentAppDir}");
LogHelper.WriteLogToFile($"AutoUpdate | Current process ID: {currentProcessId}");
LogHelper.WriteLogToFile($"AutoUpdate | Silent update mode: {isInSilence}");
// 创建批处理文件来执行更新操作
string batchFilePath = Path.Combine(Path.GetTempPath(), "UpdateICC_" + Guid.NewGuid().ToString().Substring(0, 8) + ".bat");
@@ -468,21 +469,45 @@ namespace Ink_Canvas.Helpers
// 启动更新后的应用程序
batchContent.AppendLine($"echo echo Update completed successfully! >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo :: 检查应用程序是否已经在运行 >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo tasklist /FI \"IMAGENAME eq Ink Canvas.exe\" | find /i \"Ink Canvas.exe\" > nul >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo if %%ERRORLEVEL%% neq 0 ( >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo echo 启动应用程序... >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo start \"\" \"{appPath}\" >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo ) else ( >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo echo 应用程序已经在运行,不再重复启动 >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
// 根据是否为静默更新模式决定是否自动启动应用程序
if (isInSilence)
{
// 静默更新模式下,自动启动应用程序
batchContent.AppendLine($"echo echo 自动启动应用程序... >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo start \"\" \"{appPath}\" >> \"{updateBatPath}\"");
}
else
{
// 非静默模式下,检查应用程序是否已经在运行
batchContent.AppendLine($"echo :: 检查应用程序是否已经在运行 >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo tasklist /FI \"IMAGENAME eq Ink Canvas.exe\" | find /i \"Ink Canvas.exe\" > nul >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo if %%ERRORLEVEL%% neq 0 ( >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo echo 启动应用程序... >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo start \"\" \"{appPath}\" >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo ) else ( >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo echo 应用程序已经在运行,不再重复启动 >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
}
batchContent.AppendLine($"echo exit /b 0 >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo goto EXIT >> \"{updateBatPath}\"");
// 错误退出处理
batchContent.AppendLine($"echo :ERROR_EXIT >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo start \"\" cmd /c \"echo Update failed! ^& pause\" >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo exit /b 1 >> \"{updateBatPath}\"");
if (isInSilence)
{
// 静默模式下,不显示错误提示
batchContent.AppendLine($"echo :ERROR_EXIT >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo echo Update failed! >> \"%temp%\\icc_update_error.log\" >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo exit /b 1 >> \"{updateBatPath}\"");
}
else
{
// 非静默模式下,显示错误提示
batchContent.AppendLine($"echo :ERROR_EXIT >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo start \"\" cmd /c \"echo Update failed! ^& pause\" >> \"{updateBatPath}\"");
batchContent.AppendLine($"echo exit /b 1 >> \"{updateBatPath}\"");
}
// 删除批处理文件自身
batchContent.AppendLine($"echo :EXIT >> \"{updateBatPath}\"");
+1 -1
View File
@@ -170,7 +170,7 @@
<Grid x:Name="Main_Grid">
<!--// 设置界面 //-->
<Grid Panel.ZIndex="999" x:Name="BorderSettingsMask" MouseDown="SettingsOverlayClick" IsHitTestVisible="False"
<Grid Panel.ZIndex="999" x:Name="BorderSettingsMask" MouseDown="SettingsOverlayClick" IsHitTestVisible="True"
Margin="0,0,0,0">
<Border Name="BorderSettings" Background="#ee18181b" ui:ThemeManager.RequestedTheme="Dark" Width="490"
HorizontalAlignment="Left" Margin="300,150,0,350" Visibility="Visible">
+45 -3
View File
@@ -363,9 +363,35 @@ namespace Ink_Canvas {
HasNewUpdateWindow updateWindow = new HasNewUpdateWindow(currentVersion, AvailableLatestVersion, releaseDate, releaseNotes);
bool? dialogResult = updateWindow.ShowDialog();
// 声明下载结果变量
bool isDownloadSuccessful;
// 如果窗口被关闭但没有点击按钮,视为"稍后更新"
if (dialogResult != true) {
LogHelper.WriteLogToFile("AutoUpdate | Update dialog closed without selection");
// 更新自动更新设置并保存
Settings.Startup.IsAutoUpdate = updateWindow.IsAutoUpdateEnabled;
Settings.Startup.IsAutoUpdateWithSilence = updateWindow.IsSilentUpdateEnabled;
SaveSettingsToFile();
// 如果启用了静默更新,则自动下载更新
if (Settings.Startup.IsAutoUpdateWithSilence) {
LogHelper.WriteLogToFile("AutoUpdate | Silent update enabled, downloading update automatically");
// 静默下载更新
isDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFileAndSaveStatus(AvailableLatestVersion);
if (isDownloadSuccessful) {
LogHelper.WriteLogToFile("AutoUpdate | Update downloaded successfully, will install when application closes");
// 启动检查定时器
timerCheckAutoUpdateWithSilence.Start();
} else {
LogHelper.WriteLogToFile("AutoUpdate | Silent update download failed", LogHelper.LogType.Error);
}
}
return;
}
@@ -374,9 +400,6 @@ namespace Ink_Canvas {
Settings.Startup.IsAutoUpdateWithSilence = updateWindow.IsSilentUpdateEnabled;
SaveSettingsToFile();
// 声明下载结果变量
bool isDownloadSuccessful;
// 根据用户选择处理更新
switch (updateWindow.Result) {
case HasNewUpdateWindow.UpdateResult.UpdateNow:
@@ -480,7 +503,22 @@ namespace Ink_Canvas {
canvas.Cursor = Cursors.Cross;
}
// 确保光标可见,无论是鼠标、触控还是手写笔
System.Windows.Forms.Cursor.Show();
// 强制应用光标设置
canvas.ForceCursor = true;
// 确保手写笔模式下也能显示光标
if (Tablet.TabletDevices.Count > 0) {
foreach (TabletDevice device in Tablet.TabletDevices) {
if (device.Type == TabletDeviceType.Stylus) {
// 手写笔设备存在,强制显示光标
System.Windows.Forms.Cursor.Show();
break;
}
}
}
} else {
canvas.UseCustomCursor = false;
canvas.ForceCursor = false;
@@ -608,7 +646,9 @@ namespace Ink_Canvas {
{
// 关闭设置面板
BorderSettings.Visibility = Visibility.Collapsed;
// 设置蒙版为不可点击,并清除背景
BorderSettingsMask.IsHitTestVisible = false;
BorderSettingsMask.Background = null; // 确保清除蒙层背景
}
// 新增:折叠侧边栏
@@ -641,7 +681,9 @@ namespace Ink_Canvas {
{
// 显示设置面板
BorderSettings.Visibility = Visibility.Visible;
// 设置蒙版为可点击,并添加半透明背景
BorderSettingsMask.IsHitTestVisible = true;
BorderSettingsMask.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(1, 0, 0, 0));
// 获取SettingsPanelScrollViewer中的所有GroupBox
var stackPanel = SettingsPanelScrollViewer.Content as StackPanel;
+4 -36
View File
@@ -36,42 +36,10 @@ namespace Ink_Canvas {
} else {
forceEraser = true;
forcePointEraser = true;
double k = 1;
if (Settings.Canvas.EraserShapeType == 0) {
switch (BoardComboBoxEraserSize.SelectedIndex)
{
case 0:
k = 0.5;
break;
case 1:
k = 0.8;
break;
case 3:
k = 1.25;
break;
case 4:
k = 1.8;
break;
}
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
} else if (Settings.Canvas.EraserShapeType == 1) {
switch (BoardComboBoxEraserSize.SelectedIndex)
{
case 0:
k = 0.7;
break;
case 1:
k = 0.9;
break;
case 3:
k = 1.2;
break;
case 4:
k = 1.6;
break;
}
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
}
// 使用统一的方法应用橡皮擦形状,确保一致性
ApplyCurrentEraserShape();
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
drawingShapeMode = 0;
+56 -40
View File
@@ -282,6 +282,7 @@ namespace Ink_Canvas {
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
if (BorderSettings.Visibility == Visibility.Visible) {
// 设置蒙版为不可点击,并移除背景
BorderSettingsMask.IsHitTestVisible = false;
BorderSettingsMask.Background = null;
var sb = new Storyboard();
@@ -403,6 +404,11 @@ namespace Ink_Canvas {
System.Windows.Controls.Canvas.SetLeft(FloatingbarSelectionBG, 28 * 5);
break;
}
case "shape": {
// 对图形模式进行特殊处理,不修改按钮UI状态
// 只隐藏相关面板,但保持图形绘制模式
break;
}
}
@@ -1422,44 +1428,9 @@ namespace Ink_Canvas {
forceEraser = true;
forcePointEraser = true;
if (Settings.Canvas.EraserShapeType == 0) {
double k = 1;
switch (Settings.Canvas.EraserSize) {
case 0:
k = 0.5;
break;
case 1:
k = 0.8;
break;
case 3:
k = 1.25;
break;
case 4:
k = 1.8;
break;
}
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
}
else if (Settings.Canvas.EraserShapeType == 1) {
double k = 1;
switch (Settings.Canvas.EraserSize) {
case 0:
k = 0.7;
break;
case 1:
k = 0.9;
break;
case 3:
k = 1.2;
break;
case 4:
k = 1.6;
break;
}
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
}
// 即使手掌触发过面积擦,也强制应用当前的EraserShapeType设置
ApplyCurrentEraserShape();
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
if (EraserSizePanel.Visibility == Visibility.Collapsed) {
@@ -1498,6 +1469,33 @@ namespace Ink_Canvas {
inkCanvas_EditingModeChanged(inkCanvas, null);
CancelSingleFingerDragMode();
}
// 新增方法,根据当前设置应用橡皮擦形状
public void ApplyCurrentEraserShape() {
double k = 1;
switch (Settings.Canvas.EraserSize) {
case 0:
k = Settings.Canvas.EraserShapeType == 0 ? 0.5 : 0.7;
break;
case 1:
k = Settings.Canvas.EraserShapeType == 0 ? 0.8 : 0.9;
break;
case 3:
k = Settings.Canvas.EraserShapeType == 0 ? 1.25 : 1.2;
break;
case 4:
k = Settings.Canvas.EraserShapeType == 0 ? 1.8 : 1.6;
break;
}
if (Settings.Canvas.EraserShapeType == 0) {
// 圆形擦
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
} else if (Settings.Canvas.EraserShapeType == 1) {
// 矩形黑板擦
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
}
}
private void EraserIconByStrokes_Click(object sender, RoutedEventArgs e) {
@@ -1549,7 +1547,8 @@ namespace Ink_Canvas {
private void DrawShapePromptToPen() {
if (isLongPressSelected == true) {
HideSubPanels("pen");
// 如果是长按选中的状态,只隐藏面板,不切换到笔模式
HideSubPanels("shape");
}
else {
if (StackPanelCanvasControls.Visibility == Visibility.Visible)
@@ -1629,7 +1628,23 @@ namespace Ink_Canvas {
private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) {
if (isOpeningOrHidingSettingsPane == true) return;
BtnSettings_Click(null, null);
// 获取点击的位置
Point clickPoint = e.GetPosition(BorderSettingsMask);
// 获取BorderSettings的位置和大小
Point settingsPosition = BorderSettings.TranslatePoint(new Point(0, 0), BorderSettingsMask);
Rect settingsRect = new Rect(
settingsPosition.X,
settingsPosition.Y,
BorderSettings.ActualWidth,
BorderSettings.ActualHeight
);
// 如果点击位置不在设置界面内部,才关闭设置界面
if (!settingsRect.Contains(clickPoint)) {
BtnSettings_Click(null, null);
}
}
private bool isOpeningOrHidingSettingsPane = false;
@@ -1639,6 +1654,7 @@ namespace Ink_Canvas {
HideSubPanels();
}
else {
// 设置蒙版为可点击,并添加半透明背景
BorderSettingsMask.IsHitTestVisible = true;
BorderSettingsMask.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0));
SettingsPanelScrollViewer.ScrollToTop();
+45 -75
View File
@@ -792,46 +792,17 @@ namespace Ink_Canvas {
ComboBoxEraserSizeFloatingBar.SelectedIndex = s.SelectedIndex;
ComboBoxEraserSize.SelectedIndex = s.SelectedIndex;
}
if (Settings.Canvas.EraserShapeType == 0) {
double k = 1;
switch (s.SelectedIndex) {
case 0:
k = 0.5;
break;
case 1:
k = 0.8;
break;
case 3:
k = 1.25;
break;
case 4:
k = 1.8;
break;
}
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
} else if (Settings.Canvas.EraserShapeType == 1) {
double k = 1;
switch (s.SelectedIndex) {
case 0:
k = 0.7;
break;
case 1:
k = 0.9;
break;
case 3:
k = 1.2;
break;
case 4:
k = 1.6;
break;
}
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
// 使用统一的方法应用橡皮擦形状
ApplyCurrentEraserShape();
// 确保当前处于橡皮擦模式时能立即看到效果
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
// 先切换一下模式,再切回来,确保橡皮擦形状得到刷新
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
SaveSettingsToFile();
}
@@ -840,23 +811,11 @@ namespace Ink_Canvas {
Settings.Canvas.EraserShapeType = 0;
SaveSettingsToFile();
CheckEraserTypeTab();
double k = 1;
switch (ComboBoxEraserSizeFloatingBar.SelectedIndex) {
case 0:
k = 0.5;
break;
case 1:
k = 0.8;
break;
case 3:
k = 1.25;
break;
case 4:
k = 1.8;
break;
}
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
// 使用统一的方法应用橡皮擦形状
ApplyCurrentEraserShape();
// 确保当前处于橡皮擦模式时能立即看到效果
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
@@ -866,23 +825,11 @@ namespace Ink_Canvas {
Settings.Canvas.EraserShapeType = 1;
SaveSettingsToFile();
CheckEraserTypeTab();
double k = 1;
switch (ComboBoxEraserSizeFloatingBar.SelectedIndex) {
case 0:
k = 0.7;
break;
case 1:
k = 0.9;
break;
case 3:
k = 1.2;
break;
case 4:
k = 1.6;
break;
}
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
// 使用统一的方法应用橡皮擦形状
ApplyCurrentEraserShape();
// 确保当前处于橡皮擦模式时能立即看到效果
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
@@ -1347,29 +1294,52 @@ namespace Ink_Canvas {
BoardToggleSwitchEnableMultiTouchMode.IsOn = ToggleSwitchEnableMultiTouchMode.IsOn;
else
ToggleSwitchEnableMultiTouchMode.IsOn = BoardToggleSwitchEnableMultiTouchMode.IsOn;
if (ToggleSwitchEnableMultiTouchMode.IsOn) {
if (!isInMultiTouchMode) {
// 保存当前编辑模式和绘图工具状态
InkCanvasEditingMode currentEditingMode = inkCanvas.EditingMode;
int currentDrawingShapeMode = drawingShapeMode;
bool currentForceEraser = forceEraser;
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
inkCanvas.TouchDown -= Main_Grid_TouchDown;
// 先设为None再设回原来的模式,避免可能的事件冲突
inkCanvas.EditingMode = InkCanvasEditingMode.None;
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.Children.Clear();
isInMultiTouchMode = true;
// 恢复到之前的编辑状态
inkCanvas.EditingMode = currentEditingMode;
drawingShapeMode = currentDrawingShapeMode;
forceEraser = currentForceEraser;
}
} else {
if (isInMultiTouchMode) {
// 保存当前编辑模式和绘图工具状态
InkCanvasEditingMode currentEditingMode = inkCanvas.EditingMode;
int currentDrawingShapeMode = drawingShapeMode;
bool currentForceEraser = forceEraser;
inkCanvas.StylusDown -= MainWindow_StylusDown;
inkCanvas.StylusMove -= MainWindow_StylusMove;
inkCanvas.StylusUp -= MainWindow_StylusUp;
inkCanvas.TouchDown -= MainWindow_TouchDown;
inkCanvas.TouchDown += Main_Grid_TouchDown;
// 先设为None再设回原来的模式,避免可能的事件冲突
inkCanvas.EditingMode = InkCanvasEditingMode.None;
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
inkCanvas.Children.Clear();
isInMultiTouchMode = false;
// 恢复到之前的编辑状态
inkCanvas.EditingMode = currentEditingMode;
drawingShapeMode = currentDrawingShapeMode;
forceEraser = currentForceEraser;
}
}
@@ -519,6 +519,8 @@ namespace Ink_Canvas {
// 初始化直线自动拉直相关设置
ToggleSwitchAutoStraightenLine.IsOn = Settings.Canvas.AutoStraightenLine;
AutoStraightenLineThresholdSlider.Value = Settings.Canvas.AutoStraightenLineThreshold;
// 直线拉直灵敏度也在这里初始化,即使它存储在InkToShape中
LineStraightenSensitivitySlider.Value = Settings.InkToShape.LineStraightenSensitivity;
// 初始化直线端点吸附相关设置
ToggleSwitchLineEndpointSnapping.IsOn = Settings.Canvas.LineEndpointSnapping;
@@ -588,8 +590,7 @@ namespace Ink_Canvas {
ToggleCheckboxEnableInkToShapeRounded.IsChecked = Settings.InkToShape.IsInkToShapeRounded;
// 初始化直线拉直灵敏度
LineStraightenSensitivitySlider.Value = Settings.InkToShape.LineStraightenSensitivity;
// 直线拉直灵敏度在Canvas部分已经初始化,这里不再重复
} else {
Settings.InkToShape = new InkToShape();
}
+106 -8
View File
@@ -113,7 +113,16 @@ namespace Ink_Canvas {
private Task<bool> CheckIsDrawingShapesInMultiTouchMode() {
if (isInMultiTouchMode) {
ToggleSwitchEnableMultiTouchMode.IsOn = false;
// 不关闭多指书写模式,而是保存状态,暂时禁用多指书写相关的事件处理
// 不再调用 ToggleSwitchEnableMultiTouchMode.IsOn = false;
// 暂时禁用多指书写事件处理,以避免冲突
inkCanvas.StylusDown -= MainWindow_StylusDown;
inkCanvas.StylusMove -= MainWindow_StylusMove;
inkCanvas.StylusUp -= MainWindow_StylusUp;
inkCanvas.TouchDown -= MainWindow_TouchDown;
// 记录已暂时禁用多指书写模式,但实际上多指书写开关仍然为打开状态
lastIsInMultiTouchMode = true;
}
@@ -129,6 +138,14 @@ namespace Ink_Canvas {
inkCanvas.IsManipulationEnabled = true;
CancelSingleFingerDragMode();
}
else {
// 即使不是长按,也设置必要的绘图状态
forceEraser = true;
drawingShapeMode = 1;
inkCanvas.EditingMode = InkCanvasEditingMode.None;
inkCanvas.IsManipulationEnabled = true;
isLongPressSelected = true; // 设置为选中状态,避免抬笔后切换回笔模式
}
lastMouseDownSender = null;
if (isLongPressSelected) {
@@ -189,6 +206,14 @@ namespace Ink_Canvas {
inkCanvas.IsManipulationEnabled = true;
CancelSingleFingerDragMode();
}
else {
// 即使不是长按,也设置必要的绘图状态
forceEraser = true;
drawingShapeMode = 2;
inkCanvas.EditingMode = InkCanvasEditingMode.None;
inkCanvas.IsManipulationEnabled = true;
isLongPressSelected = true; // 设置为选中状态,避免抬笔后切换回笔模式
}
lastMouseDownSender = null;
if (isLongPressSelected) {
@@ -276,6 +301,7 @@ namespace Ink_Canvas {
drawingShapeMode = 3;
inkCanvas.EditingMode = InkCanvasEditingMode.None;
inkCanvas.IsManipulationEnabled = true;
isLongPressSelected = true; // 设置为选中状态,避免抬笔后切换回笔模式
CancelSingleFingerDragMode();
DrawShapePromptToPen();
}
@@ -435,7 +461,12 @@ namespace Ink_Canvas {
if (isLastTouchEraser) return;
//EraserContainer.Background = null;
//ImageEraser.Visibility = Visibility.Visible;
if (isWaitUntilNextTouchDown) return;
// 修复触屏状态下几何绘制功能不可用的问题
// 在几何绘制模式下,即使isWaitUntilNextTouchDown为true,也应该处理触摸移动事件
// 只有当多点触控时才需要等待下一次触摸
if (isWaitUntilNextTouchDown && dec.Count > 1) return;
if (dec.Count > 1) {
isWaitUntilNextTouchDown = true;
try {
@@ -447,6 +478,11 @@ namespace Ink_Canvas {
}
return;
}
// 在几何绘制模式下,确保处理单点触控的移动事件
Point touchPoint = e.GetTouchPoint(inkCanvas).Position;
MouseTouchMove(touchPoint);
return; // 处理完几何绘制后直接返回,不执行后面的代码
}
// 触摸移动时保持自定义光标显示
@@ -1346,8 +1382,34 @@ namespace Ink_Canvas {
ViewboxFloatingBar.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
// 在几何绘制模式下,确保正确处理触摸抬起事件
if (drawingShapeMode != 0) {
// 如果是几何绘制模式,确保将临时绘制的图形添加到永久图形中
if (lastTempStroke != null) {
// 将临时笔画添加到历史记录中
var strokes = new StrokeCollection();
strokes.Add(lastTempStroke);
timeMachine.CommitStrokeUserInputHistory(strokes);
// 清除临时笔画引用,以便下次绘制
lastTempStroke = null;
}
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0) {
// 将临时笔画集合添加到历史记录中
timeMachine.CommitStrokeUserInputHistory(lastTempStrokeCollection);
// 清除临时笔画集合引用,以便下次绘制
lastTempStrokeCollection = new StrokeCollection();
}
// 如果不是长按选中的状态,则需要在抬起手指后重置isWaitUntilNextTouchDown
if (!isLongPressSelected && dec.Count == 0) {
isWaitUntilNextTouchDown = false;
}
}
inkCanvas_MouseUp(sender, null);
if (dec.Count == 0) isWaitUntilNextTouchDown = false;
// 修改此处逻辑,在长按选择图形模式下保持isWaitUntilNextTouchDown
if (dec.Count == 0 && !isLongPressSelected) isWaitUntilNextTouchDown = false;
}
private Stroke lastTempStroke = null;
@@ -1537,17 +1599,37 @@ namespace Ink_Canvas {
}
if (lastIsInMultiTouchMode) {
ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 不再重新启用开关,而是恢复多指书写相关的事件处理
// ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 恢复多指书写事件处理
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
lastIsInMultiTouchMode = false;
}
}
// 修改此处逻辑,确保在正确的情况下才切换回笔模式
if (drawingShapeMode != 9 && drawingShapeMode != 0 && drawingShapeMode != 24 && drawingShapeMode != 25) {
if (isLongPressSelected) { }
if (isLongPressSelected) {
// 如果是长按选中的情况,保持图形模式,不做任何切换
isWaitUntilNextTouchDown = true; // 保持当前绘图模式直到下一次触摸
}
else {
BtnPen_Click(null, null); //画完一次还原到笔模式
if (lastIsInMultiTouchMode) {
ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 不再重新启用开关,而是恢复多指书写相关的事件处理
// ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 恢复多指书写事件处理
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
lastIsInMultiTouchMode = false;
}
}
@@ -1573,7 +1655,15 @@ namespace Ink_Canvas {
else {
BtnPen_Click(null, null); //画完还原到笔模式
if (lastIsInMultiTouchMode) {
ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 不再重新启用开关,而是恢复多指书写相关的事件处理
// ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 恢复多指书写事件处理
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
lastIsInMultiTouchMode = false;
}
@@ -1619,7 +1709,15 @@ namespace Ink_Canvas {
BtnPen_Click(null, null); //画完还原到笔模式
if (lastIsInMultiTouchMode) {
ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 不再重新启用开关,而是恢复多指书写相关的事件处理
// ToggleSwitchEnableMultiTouchMode.IsOn = true;
// 恢复多指书写事件处理
inkCanvas.StylusDown += MainWindow_StylusDown;
inkCanvas.StylusMove += MainWindow_StylusMove;
inkCanvas.StylusUp += MainWindow_StylusUp;
inkCanvas.TouchDown += MainWindow_TouchDown;
lastIsInMultiTouchMode = false;
}
}
@@ -13,7 +13,6 @@ 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) {
@@ -120,25 +119,34 @@ namespace Ink_Canvas {
// 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)) {
// 检查是否启用了直线自动拉直功能
if (Settings.Canvas.AutoStraightenLine && 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;
// 只有在启用端点吸附时才尝试吸附
if (Settings.Canvas.LineEndpointSnapping) {
// 只有在启用了形状识别(矩形或三角形)时才执行端点吸附
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)) {
// 独立检查是否应该拉直线条,无论端点吸附是否启用或成功
bool shouldStraighten = ShouldStraightenLine(e.Stroke);
// 如果满足任一条件(吸附成功或应该拉直),则创建直线
// 这里的条件是"或"关系,只要有一个条件满足就会创建直线
if (snapped || shouldStraighten) {
StylusPointCollection straightLinePoints = CreateStraightLine(startPoint, endPoint);
Stroke straightStroke = new Stroke(straightLinePoints) {
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
@@ -574,8 +582,8 @@ namespace Ink_Canvas {
Point end = stroke.StylusPoints.Last().ToPoint();
double lineLength = GetDistance(start, end);
// 线条必须足够长才考虑拉直,至少30像素
if (lineLength < 30)
// 线条必须足够长才考虑拉直,使用设置中的阈值
if (lineLength < Settings.Canvas.AutoStraightenLineThreshold)
return false;
// 获取用户设置的灵敏度值
@@ -620,8 +628,8 @@ namespace Ink_Canvas {
double maxDeviation = 0;
double lineLength = GetDistance(start, end);
// 如果线条太短,不进行拉直处理
if (lineLength < 50) {
// 如果线条太短,不进行拉直处理,使用设置中的阈值
if (lineLength < Settings.Canvas.AutoStraightenLineThreshold) {
return false;
}
@@ -732,11 +740,19 @@ namespace Ink_Canvas {
// New method: Attempts to snap endpoints to existing stroke endpoints
private Point[] GetSnappedEndpoints(Point start, Point end) {
// 如果端点吸附功能关闭,直接返回null
// 这里不再返回原始点,因为调用此方法的地方会判断返回值是否为null
if (!Settings.Canvas.LineEndpointSnapping)
return null;
bool startSnapped = false;
bool endSnapped = false;
Point snappedStart = start;
Point snappedEnd = end;
// 使用设置中的吸附距离阈值
double snapThreshold = Settings.Canvas.LineEndpointSnappingThreshold;
// Check all strokes in canvas for potential snap points
foreach (Stroke stroke in inkCanvas.Strokes) {
if (stroke.StylusPoints.Count == 0) continue;
@@ -747,10 +763,10 @@ namespace Ink_Canvas {
// Check if start point should snap to an endpoint
if (!startSnapped) {
if (GetDistance(start, strokeStart) < SNAP_THRESHOLD) {
if (GetDistance(start, strokeStart) < snapThreshold) {
snappedStart = strokeStart;
startSnapped = true;
} else if (GetDistance(start, strokeEnd) < SNAP_THRESHOLD) {
} else if (GetDistance(start, strokeEnd) < snapThreshold) {
snappedStart = strokeEnd;
startSnapped = true;
}
@@ -758,10 +774,10 @@ namespace Ink_Canvas {
// Check if end point should snap to an endpoint
if (!endSnapped) {
if (GetDistance(end, strokeStart) < SNAP_THRESHOLD) {
if (GetDistance(end, strokeStart) < snapThreshold) {
snappedEnd = strokeStart;
endSnapped = true;
} else if (GetDistance(end, strokeEnd) < SNAP_THRESHOLD) {
} else if (GetDistance(end, strokeEnd) < snapThreshold) {
snappedEnd = strokeEnd;
endSnapped = true;
}
+94 -13
View File
@@ -6,6 +6,9 @@ using System.Runtime.CompilerServices;
using System.Timers;
using System.Windows;
using MessageBox = System.Windows.MessageBox;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace Ink_Canvas {
public class TimeViewModel : INotifyPropertyChanged {
@@ -302,24 +305,102 @@ namespace Ink_Canvas {
}
private void timerCheckAutoUpdateWithSilence_Elapsed(object sender, ElapsedEventArgs e) {
Dispatcher.Invoke(() => {
try {
if (!Topmost || inkCanvas.Strokes.Count > 0) return;
}
catch (Exception ex) {
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
}
});
// 停止计时器,避免重复触发
timerCheckAutoUpdateWithSilence.Stop();
try {
if (AutoUpdateWithSilenceTimeComboBox.CheckIsInSilencePeriod(
Settings.Startup.AutoUpdateWithSilenceStartTime,
Settings.Startup.AutoUpdateWithSilenceEndTime)) {
// 检查是否有可用的更新
if (string.IsNullOrEmpty(AvailableLatestVersion)) {
LogHelper.WriteLogToFile("AutoUpdate | No available update version found");
return;
}
// 检查是否启用了静默更新
if (!Settings.Startup.IsAutoUpdateWithSilence) {
LogHelper.WriteLogToFile("AutoUpdate | Silent update is disabled");
return;
}
// 检查更新文件是否已下载
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
string statusFilePath = Path.Combine(updatesFolderPath, $"DownloadV{AvailableLatestVersion}Status.txt");
if (!File.Exists(statusFilePath) || File.ReadAllText(statusFilePath).Trim().ToLower() != "true") {
LogHelper.WriteLogToFile("AutoUpdate | Update file not downloaded yet");
// 尝试下载更新文件
Task.Run(async () => {
bool isDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFileAndSaveStatus(AvailableLatestVersion);
if (isDownloadSuccessful) {
LogHelper.WriteLogToFile("AutoUpdate | Update downloaded successfully, will check again for installation");
// 重新启动计时器,下次检查时安装
timerCheckAutoUpdateWithSilence.Start();
} else {
LogHelper.WriteLogToFile("AutoUpdate | Failed to download update", LogHelper.LogType.Error);
}
});
return;
}
// 检查是否在静默更新时间段内
bool isInSilencePeriod = AutoUpdateWithSilenceTimeComboBox.CheckIsInSilencePeriod(
Settings.Startup.AutoUpdateWithSilenceStartTime,
Settings.Startup.AutoUpdateWithSilenceEndTime);
if (!isInSilencePeriod) {
LogHelper.WriteLogToFile("AutoUpdate | Not in silence update time period");
// 重新启动计时器,稍后再检查
timerCheckAutoUpdateWithSilence.Start();
return;
}
// 检查应用程序状态,确保可以安全更新
bool canSafelyUpdate = false;
Dispatcher.Invoke(() => {
try {
// 检查是否处于桌面模式(Topmost为true)且没有墨迹内容
if (Topmost && inkCanvas.Strokes.Count == 0) {
// 检查是否有未保存的内容或正在进行的操作
if (!isHidingSubPanelsWhenInking) {
canSafelyUpdate = true;
LogHelper.WriteLogToFile("AutoUpdate | Application is in a safe state for update");
} else {
LogHelper.WriteLogToFile("AutoUpdate | Application is currently performing operations");
}
} else {
LogHelper.WriteLogToFile("AutoUpdate | Application has unsaved content or is not in desktop mode");
}
}
catch (Exception ex) {
LogHelper.WriteLogToFile($"AutoUpdate | Error checking application state: {ex.Message}", LogHelper.LogType.Error);
}
});
if (canSafelyUpdate) {
LogHelper.WriteLogToFile("AutoUpdate | Installing update now");
// 设置为用户主动退出,避免被看门狗判定为崩溃
App.IsAppExitByUser = true;
// 执行更新安装
AutoUpdateHelper.InstallNewVersionApp(AvailableLatestVersion, true);
timerCheckAutoUpdateWithSilence.Stop();
// 关闭应用程序
Dispatcher.Invoke(() => {
Application.Current.Shutdown();
});
} else {
LogHelper.WriteLogToFile("AutoUpdate | Cannot safely update now, will try again later");
// 重新启动计时器,稍后再检查
timerCheckAutoUpdateWithSilence.Start();
}
}
catch (Exception ex) {
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
LogHelper.WriteLogToFile($"AutoUpdate | Error in silent update check: {ex.Message}", LogHelper.LogType.Error);
// 出错时重新启动计时器,稍后再检查
timerCheckAutoUpdateWithSilence.Start();
}
}
}
+48 -3
View File
@@ -91,6 +91,24 @@ namespace Ink_Canvas {
ViewboxFloatingBar.IsHitTestVisible = false;
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
// 确保手写笔模式下显示光标
if (Settings.Canvas.IsShowCursor) {
inkCanvas.ForceCursor = true;
inkCanvas.UseCustomCursor = true;
// 根据当前编辑模式设置不同的光标
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
inkCanvas.Cursor = Cursors.Cross;
} else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
if (sri != null)
inkCanvas.Cursor = new Cursor(sri.Stream);
}
// 强制显示光标
System.Windows.Forms.Cursor.Show();
}
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
@@ -137,6 +155,13 @@ namespace Ink_Canvas {
}
catch { }
// 确保手写笔移动时光标保持可见
if (Settings.Canvas.IsShowCursor) {
inkCanvas.ForceCursor = true;
inkCanvas.UseCustomCursor = true;
System.Windows.Forms.Cursor.Show();
}
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
var stylusPointCollection = e.GetStylusPoints(this);
foreach (var stylusPoint in stylusPointCollection)
@@ -224,8 +249,17 @@ namespace Ink_Canvas {
break;
}
inkCanvas.EraserShape = new EllipseStylusShape(boundsWidth * k * eraserMultiplier,
boundsWidth * k * eraserMultiplier);
// 根据EraserShapeType设置合适的橡皮擦形状
if (Settings.Canvas.EraserShapeType == 0) {
// 圆形擦
inkCanvas.EraserShape = new EllipseStylusShape(boundsWidth * k * eraserMultiplier,
boundsWidth * k * eraserMultiplier);
} else if (Settings.Canvas.EraserShapeType == 1) {
// 矩形黑板擦
inkCanvas.EraserShape = new RectangleStylusShape(boundsWidth * k * eraserMultiplier * 0.6,
boundsWidth * k * eraserMultiplier);
}
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
else {
@@ -245,7 +279,8 @@ namespace Ink_Canvas {
isLastTouchEraser = false;
// 修复面积擦时不显示橡皮形状:无论 forcePointEraser 状态,均显示 50x50 橡皮
inkCanvas.EraserShape = new EllipseStylusShape(50, 50);
if (forceEraser) return;
// 修复触屏状态下几何绘制功能不可用的问题:在几何绘制模式下不应该因为forceEraser而直接返回
if (forceEraser && drawingShapeMode == 0) return;
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
}
@@ -304,6 +339,16 @@ namespace Ink_Canvas {
inkCanvas.EditingMode = lastInkCanvasEditingMode;
dec.Remove(e.TouchDevice.Id);
inkCanvas.Opacity = 1;
// 如果是手掌触发的面积擦抬起,需要确保橡皮擦形状被正确重置
if (isLastTouchEraser && dec.Count == 0) {
isLastTouchEraser = false;
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint && forcePointEraser) {
// 重新应用当前设置的橡皮擦形状
ApplyCurrentEraserShape();
}
}
if (dec.Count == 0)
if (lastTouchDownStrokeCollection.Count() != inkCanvas.Strokes.Count() &&
!(drawingShapeMode == 9 && !isFirstTouchCuboid)) {
+2 -2
View File
@@ -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("1.6.5")]
[assembly: AssemblyFileVersion("1.6.5")]
[assembly: AssemblyVersion("1.6.7")]
[assembly: AssemblyFileVersion("1.6.7")]
+1 -1
View File
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A9A3B2D7B1A7EB897CCDEEA8991553AFAD256672"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "C618DEE2BF2FDFC3FC9E2911171FB8CC42684DCF"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A9A3B2D7B1A7EB897CCDEEA8991553AFAD256672"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "C618DEE2BF2FDFC3FC9E2911171FB8CC42684DCF"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。