优化代码
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -8,11 +6,13 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
public bool isFloatingBarFolded = false;
|
||||
private bool isFloatingBarChangingHideMode = false;
|
||||
public bool isFloatingBarFolded;
|
||||
private bool isFloatingBarChangingHideMode;
|
||||
|
||||
private void CloseWhiteboardImmediately() {
|
||||
if (isDisplayingOrHidingBlackboard) return;
|
||||
@@ -28,10 +28,10 @@ namespace Ink_Canvas {
|
||||
BtnSwitch_Click(BtnSwitch, null);
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(200);
|
||||
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
@@ -98,7 +98,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel == true) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
HideRightQuickPanel();
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
@@ -122,7 +122,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private async void RightUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel == true) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
HideLeftQuickPanel();
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
@@ -249,13 +249,13 @@ namespace Ink_Canvas {
|
||||
if (MarginFromEdge == -10) LeftSidePanel.Visibility = Visibility.Visible;
|
||||
|
||||
var LeftSidePanelmarginAnimation = new ThicknessAnimation {
|
||||
Duration = isNoAnimation == true ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
Duration = isNoAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
From = LeftSidePanel.Margin,
|
||||
To = new Thickness(MarginFromEdge, 0, 0, -150)
|
||||
};
|
||||
LeftSidePanelmarginAnimation.EasingFunction = new CubicEase();
|
||||
var RightSidePanelmarginAnimation = new ThicknessAnimation {
|
||||
Duration = isNoAnimation == true ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
Duration = isNoAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
From = RightSidePanel.Margin,
|
||||
To = new Thickness(0, 0, MarginFromEdge, -150)
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using IWshRuntimeLibrary;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -10,7 +12,7 @@ namespace Ink_Canvas {
|
||||
var shortcut = (IWshShortcut)shell.CreateShortcut(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName + ".lnk");
|
||||
//设置快捷方式的目标所在的位置(源程序完整路径)
|
||||
shortcut.TargetPath = System.Windows.Forms.Application.ExecutablePath;
|
||||
shortcut.TargetPath = Application.ExecutablePath;
|
||||
//应用程序的工作目录
|
||||
//当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
|
||||
shortcut.WorkingDirectory = Environment.CurrentDirectory;
|
||||
@@ -30,8 +32,8 @@ namespace Ink_Canvas {
|
||||
|
||||
public static bool StartAutomaticallyDel(string exeName) {
|
||||
try {
|
||||
System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
||||
".lnk");
|
||||
File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
||||
".lnk");
|
||||
return true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.Win32;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Win32;
|
||||
using Application = System.Windows.Application;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -11,19 +11,19 @@ namespace Ink_Canvas {
|
||||
|
||||
private void SetTheme(string theme) {
|
||||
if (theme == "Light") {
|
||||
var rd1 = new ResourceDictionary()
|
||||
var rd1 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
var rd2 = new ResourceDictionary()
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary()
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary()
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
@@ -32,18 +32,18 @@ namespace Ink_Canvas {
|
||||
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
||||
}
|
||||
else if (theme == "Dark") {
|
||||
var rd1 = new ResourceDictionary() { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
||||
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
var rd2 = new ResourceDictionary()
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary()
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary()
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -138,7 +139,7 @@ namespace Ink_Canvas {
|
||||
};
|
||||
|
||||
// 确保面板显示在顶层
|
||||
System.Windows.Controls.Panel.SetZIndex(BackgroundPalette, 1000);
|
||||
Panel.SetZIndex(BackgroundPalette, 1000);
|
||||
|
||||
// 创建面板内容
|
||||
var stackPanel = new StackPanel();
|
||||
@@ -169,9 +170,9 @@ namespace Ink_Canvas {
|
||||
titleCanvas.Children.Add(titleText);
|
||||
|
||||
// 关闭按钮
|
||||
var closeImage = new System.Windows.Controls.Image
|
||||
var closeImage = new Image
|
||||
{
|
||||
Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/new-icons/close-white.png", UriKind.Relative)),
|
||||
Source = new BitmapImage(new Uri("/Resources/new-icons/close-white.png", UriKind.Relative)),
|
||||
Height = 16,
|
||||
Width = 16
|
||||
};
|
||||
@@ -370,7 +371,7 @@ namespace Ink_Canvas {
|
||||
// R滑块和文本框
|
||||
var rPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var rLabel = new TextBlock { Text = "R:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var rSlider = new System.Windows.Controls.Slider
|
||||
var rSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -390,7 +391,7 @@ namespace Ink_Canvas {
|
||||
// G滑块和文本框
|
||||
var gPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var gLabel = new TextBlock { Text = "G:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var gSlider = new System.Windows.Controls.Slider
|
||||
var gSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -410,7 +411,7 @@ namespace Ink_Canvas {
|
||||
// B滑块和文本框
|
||||
var bPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 10, 5) };
|
||||
var bLabel = new TextBlock { Text = "B:", Width = 20, VerticalAlignment = VerticalAlignment.Center };
|
||||
var bSlider = new System.Windows.Controls.Slider
|
||||
var bSlider = new Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
@@ -575,7 +576,7 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 更新颜色预览框的颜色
|
||||
/// </summary>
|
||||
private void UpdateColorPreview(Border colorPreview, System.Windows.Controls.Slider rSlider, System.Windows.Controls.Slider gSlider, System.Windows.Controls.Slider bSlider)
|
||||
private void UpdateColorPreview(Border colorPreview, Slider rSlider, Slider gSlider, Slider bSlider)
|
||||
{
|
||||
Color previewColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
@@ -720,17 +721,17 @@ namespace Ink_Canvas {
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
// 保存非笔画元素(如图片)
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDelete: Preserved elements count: {preservedElements.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDelete: Preserved elements count: {preservedElements.Count}");
|
||||
inkCanvas.Children.Clear();
|
||||
// 恢复非笔画元素
|
||||
RestoreNonStrokeElements(preservedElements);
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDelete: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDelete: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
}
|
||||
}
|
||||
private void BoardSymbolIconDeleteInkAndHistories_MouseUp(object sender, RoutedEventArgs e)
|
||||
@@ -742,17 +743,17 @@ namespace Ink_Canvas {
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
// 保存非笔画元素(如图片)
|
||||
System.Diagnostics.Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: Preserved elements count: {preservedElements.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: Preserved elements count: {preservedElements.Count}");
|
||||
inkCanvas.Children.Clear();
|
||||
// 恢复非笔画元素
|
||||
RestoreNonStrokeElements(preservedElements);
|
||||
System.Diagnostics.Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
Debug.WriteLine($"BoardSymbolIconDeleteInkAndHistories: inkCanvas.Children.Count after restore: {inkCanvas.Children.Count}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,9 +778,9 @@ namespace Ink_Canvas {
|
||||
if (stackPanel.Children.Count > 1 && stackPanel.Children[1] is StackPanel contentPanel)
|
||||
{
|
||||
// 查找RGB滑块
|
||||
System.Windows.Controls.Slider rSlider = null;
|
||||
System.Windows.Controls.Slider gSlider = null;
|
||||
System.Windows.Controls.Slider bSlider = null;
|
||||
Slider rSlider = null;
|
||||
Slider gSlider = null;
|
||||
Slider bSlider = null;
|
||||
|
||||
// 遍历面板查找RGB滑块
|
||||
foreach (var child in contentPanel.Children)
|
||||
@@ -788,7 +789,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
foreach (var panelChild in panel.Children)
|
||||
{
|
||||
if (panelChild is System.Windows.Controls.Slider slider)
|
||||
if (panelChild is Slider slider)
|
||||
{
|
||||
if (panel.Children.Count > 0 && panel.Children[0] is TextBlock label)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -59,8 +58,8 @@ namespace Ink_Canvas {
|
||||
isLongPressSelected = false;
|
||||
}
|
||||
|
||||
private bool isUselightThemeColor = false, isDesktopUselightThemeColor = false;
|
||||
private int penType = 0; // 0是签字笔,1是荧光笔
|
||||
private bool isUselightThemeColor, isDesktopUselightThemeColor;
|
||||
private int penType; // 0是签字笔,1是荧光笔
|
||||
private int lastDesktopInkColor = 1, lastBoardInkColor = 5;
|
||||
private int highlighterColor = 102;
|
||||
|
||||
@@ -388,7 +387,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void CheckLastColor(int inkColor, bool isHighlighter = false) {
|
||||
if (isHighlighter == true) {
|
||||
if (isHighlighter) {
|
||||
highlighterColor = inkColor;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Ink_Canvas
|
||||
|
||||
@@ -12,18 +12,18 @@ namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
|
||||
// 新橡皮擦系统的核心变量
|
||||
public bool isUsingAdvancedEraser = false;
|
||||
private IncrementalStrokeHitTester advancedHitTester = null;
|
||||
public bool isUsingAdvancedEraser;
|
||||
private IncrementalStrokeHitTester advancedHitTester;
|
||||
|
||||
// 橡皮擦配置
|
||||
public double currentEraserSize = 64;
|
||||
public bool isCurrentEraserCircle = false;
|
||||
public bool isUsingStrokeEraser = false;
|
||||
public bool isCurrentEraserCircle;
|
||||
public bool isUsingStrokeEraser;
|
||||
|
||||
// 视觉反馈相关
|
||||
private Matrix eraserTransformMatrix = new Matrix();
|
||||
private Point lastEraserPosition = new Point();
|
||||
private bool isEraserVisible = false;
|
||||
private Matrix eraserTransformMatrix;
|
||||
private Point lastEraserPosition;
|
||||
private bool isEraserVisible;
|
||||
|
||||
// 性能优化相关
|
||||
private DateTime lastEraserUpdate = DateTime.Now;
|
||||
@@ -35,7 +35,7 @@ namespace Ink_Canvas {
|
||||
// 橡皮擦视觉反馈控件
|
||||
private DrawingVisual eraserVisual = new DrawingVisual();
|
||||
private VisualCanvas eraserOverlayCanvas = null;
|
||||
private Border eraserVisualBorder = null; // 用于显示橡皮擦视觉反馈的Border
|
||||
private Border eraserVisualBorder; // 用于显示橡皮擦视觉反馈的Border
|
||||
|
||||
// 兼容性属性:模拟原有的EraserOverlay_DrawingVisual
|
||||
private VisualCanvas EraserOverlay_DrawingVisual => eraserOverlayCanvas;
|
||||
@@ -102,7 +102,7 @@ namespace Ink_Canvas {
|
||||
UpdateEraserSize();
|
||||
|
||||
// 获取inkCanvas引用
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
// 根据橡皮擦形状创建碰撞检测器
|
||||
@@ -117,13 +117,14 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 创建橡皮擦形状
|
||||
/// </summary>
|
||||
private StylusShape CreateEraserShape() {
|
||||
private StylusShape CreateEraserShape()
|
||||
{
|
||||
if (isCurrentEraserCircle) {
|
||||
return new EllipseStylusShape(currentEraserSize, currentEraserSize);
|
||||
} else {
|
||||
// 矩形橡皮擦,使用与原来相同的逻辑
|
||||
return new RectangleStylusShape(currentEraserSize, currentEraserSize / 0.6);
|
||||
}
|
||||
|
||||
// 矩形橡皮擦,使用与原来相同的逻辑
|
||||
return new RectangleStylusShape(currentEraserSize, currentEraserSize / 0.6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -231,7 +232,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
private void OnAdvancedEraserStrokeHit(object sender, StrokeHitEventArgs args) {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
var eraseResult = args.GetPointEraseResults();
|
||||
@@ -296,7 +297,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
private void ProcessStrokeEraserAtPosition(Point position) {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
var hitStrokes = inkCanvas.Strokes.HitTest(position)
|
||||
@@ -343,7 +344,7 @@ namespace Ink_Canvas {
|
||||
Panel.SetZIndex(eraserVisualBorder, 1001);
|
||||
|
||||
// 将Border添加到InkCanvasGridForInkReplay中
|
||||
var inkCanvasGrid = this.FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
inkCanvasGrid.Children.Add(eraserVisualBorder);
|
||||
Trace.WriteLine("Advanced Eraser: Visual feedback border added to grid");
|
||||
@@ -401,7 +402,7 @@ namespace Ink_Canvas {
|
||||
string resourceKey = isCurrentEraserCircle ? "EraserCircleDrawingGroup" : "EraserDrawingGroup";
|
||||
|
||||
// 尝试从资源字典中获取DrawingGroup
|
||||
var drawingGroup = this.TryFindResource(resourceKey) as DrawingGroup;
|
||||
var drawingGroup = TryFindResource(resourceKey) as DrawingGroup;
|
||||
if (drawingGroup == null) {
|
||||
// 如果找不到资源,创建默认的橡皮擦图像
|
||||
return CreateDefaultEraserImage();
|
||||
@@ -525,7 +526,7 @@ namespace Ink_Canvas {
|
||||
/// 获取当前橡皮擦状态信息(用于调试)
|
||||
/// </summary>
|
||||
public string GetEraserStatusInfo() {
|
||||
return $"Advanced Eraser Status:\n" +
|
||||
return "Advanced Eraser Status:\n" +
|
||||
$"- Active: {isUsingAdvancedEraser}\n" +
|
||||
$"- Size: {currentEraserSize:F1}\n" +
|
||||
$"- Shape: {(isCurrentEraserCircle ? "Circle" : "Rectangle")}\n" +
|
||||
@@ -551,7 +552,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 清理视觉反馈Border
|
||||
if (eraserVisualBorder != null) {
|
||||
var inkCanvasGrid = this.FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
inkCanvasGrid.Children.Remove(eraserVisualBorder);
|
||||
}
|
||||
@@ -564,7 +565,7 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
public void ApplyAdvancedEraserShape() {
|
||||
try {
|
||||
var inkCanvas = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
// 更新橡皮擦尺寸和形状
|
||||
@@ -595,7 +596,7 @@ namespace Ink_Canvas {
|
||||
public void EnableAdvancedEraserSystem() {
|
||||
try {
|
||||
// 获取橡皮擦覆盖层
|
||||
var eraserOverlay = this.FindName("AdvancedEraserOverlay") as Border;
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
// 启用覆盖层的交互
|
||||
eraserOverlay.IsHitTestVisible = true;
|
||||
@@ -607,7 +608,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 设置覆盖层的大小以覆盖整个InkCanvas
|
||||
var inkCanvasControl = this.FindName("inkCanvas") as InkCanvas;
|
||||
var inkCanvasControl = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvasControl != null) {
|
||||
eraserOverlay.Width = inkCanvasControl.ActualWidth;
|
||||
eraserOverlay.Height = inkCanvasControl.ActualHeight;
|
||||
@@ -649,7 +650,7 @@ namespace Ink_Canvas {
|
||||
|
||||
overlay.MouseMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
var position = e.GetPosition((UIElement)this.FindName("inkCanvas"));
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
Trace.WriteLine($"Advanced Eraser: Mouse move event triggered at ({position.X:F1}, {position.Y:F1})");
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
} else {
|
||||
@@ -681,7 +682,7 @@ namespace Ink_Canvas {
|
||||
overlay.StylusMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
e.Handled = true;
|
||||
var position = e.GetPosition((UIElement)this.FindName("inkCanvas"));
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
Trace.WriteLine($"Advanced Eraser: Stylus move at ({position.X:F1}, {position.Y:F1})");
|
||||
}
|
||||
@@ -702,7 +703,7 @@ namespace Ink_Canvas {
|
||||
ResetEraserState();
|
||||
|
||||
// 获取橡皮擦覆盖层并禁用
|
||||
var eraserOverlay = this.FindName("AdvancedEraserOverlay") as Border;
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
eraserOverlay.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System.Threading;
|
||||
using Application = System.Windows.Application;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using HorizontalAlignment = System.Windows.HorizontalAlignment;
|
||||
using Point = System.Windows.Point;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
using Image = System.Windows.Controls.Image;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
using Panel = System.Windows.Controls.Panel;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -113,7 +117,7 @@ namespace Ink_Canvas {
|
||||
|| BorderFloatingBarMainControls.Visibility != Visibility.Visible) {
|
||||
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else if (isVisible == true) {
|
||||
else if (isVisible) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
|
||||
else EnableTwoFingerGestureBorder.Visibility = Visibility.Visible;
|
||||
@@ -127,9 +131,9 @@ namespace Ink_Canvas {
|
||||
|
||||
#region 浮動工具欄的拖動實現
|
||||
|
||||
private bool isDragDropInEffect = false;
|
||||
private Point pos = new Point();
|
||||
private Point downPos = new Point();
|
||||
private bool isDragDropInEffect;
|
||||
private Point pos;
|
||||
private Point downPos;
|
||||
private Point pointDesktop = new Point(-1, -1); //用于记录上次在桌面时的坐标
|
||||
private Point pointPPT = new Point(-1, -1); //用于记录上次在PPT中的坐标
|
||||
|
||||
@@ -295,7 +299,7 @@ namespace Ink_Canvas {
|
||||
To = BorderSettings.RenderTransform.Value.OffsetX - 440,
|
||||
Duration = TimeSpan.FromSeconds(0.6)
|
||||
};
|
||||
slideAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
|
||||
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
|
||||
Storyboard.SetTargetProperty(slideAnimation,
|
||||
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
|
||||
|
||||
@@ -310,7 +314,7 @@ namespace Ink_Canvas {
|
||||
BorderSettings.RenderTransform = new TranslateTransform();
|
||||
|
||||
isOpeningOrHidingSettingsPane = true;
|
||||
sb.Begin((FrameworkElement)BorderSettings);
|
||||
sb.Begin(BorderSettings);
|
||||
}
|
||||
|
||||
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
|
||||
@@ -420,7 +424,7 @@ namespace Ink_Canvas {
|
||||
await Task.Delay(50);
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
}
|
||||
else if (Topmost == true) //非黑板
|
||||
else if (Topmost) //非黑板
|
||||
{
|
||||
await Task.Delay(50);
|
||||
ViewboxFloatingBarMarginAnimation(100, true);
|
||||
@@ -469,7 +473,7 @@ namespace Ink_Canvas {
|
||||
#region 白板按鈕和退出白板模式按鈕
|
||||
|
||||
//private bool Not_Enter_Blackboard_fir_Mouse_Click = true;
|
||||
private bool isDisplayingOrHidingBlackboard = false;
|
||||
private bool isDisplayingOrHidingBlackboard;
|
||||
|
||||
private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -504,10 +508,10 @@ namespace Ink_Canvas {
|
||||
Not_Enter_Blackboard_fir_Mouse_Click = false;
|
||||
}
|
||||
*/
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
HideSubPanels();
|
||||
|
||||
@@ -531,7 +535,7 @@ namespace Ink_Canvas {
|
||||
if (isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = false;
|
||||
}
|
||||
|
||||
if (Settings.Appearance.EnableTimeDisplayInWhiteboardMode == true)
|
||||
if (Settings.Appearance.EnableTimeDisplayInWhiteboardMode)
|
||||
{
|
||||
WaterMarkTime.Visibility = Visibility.Visible;
|
||||
WaterMarkDate.Visibility = Visibility.Visible;
|
||||
@@ -540,7 +544,7 @@ namespace Ink_Canvas {
|
||||
WaterMarkDate.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
if (Settings.Appearance.EnableChickenSoupInWhiteboardMode == true)
|
||||
if (Settings.Appearance.EnableChickenSoupInWhiteboardMode)
|
||||
{
|
||||
BlackBoardWaterMark.Visibility = Visibility.Visible;
|
||||
} else {
|
||||
@@ -597,15 +601,15 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
|
||||
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Collapsed)
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(300);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(100, true); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
else
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(300);
|
||||
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
if (System.Windows.Controls.Canvas.GetLeft(FloatingbarSelectionBG)!=28) PenIcon_Click(null, null);
|
||||
|
||||
@@ -628,10 +632,10 @@ namespace Ink_Canvas {
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(200);
|
||||
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
SwitchToDefaultPen(null, null);
|
||||
CheckColorTheme(true);
|
||||
@@ -715,7 +719,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SymbolIconSettings_Click(object sender, RoutedEventArgs e) {
|
||||
if (isOpeningOrHidingSettingsPane != false) return;
|
||||
if (isOpeningOrHidingSettingsPane) return;
|
||||
HideSubPanels();
|
||||
BtnSettings_Click(null, null);
|
||||
}
|
||||
@@ -827,7 +831,7 @@ namespace Ink_Canvas {
|
||||
// 检查是否启用了直接调用ClassIsland点名功能
|
||||
if (Settings.RandSettings.DirectCallCiRand) {
|
||||
try {
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
FileName = "classisland://plugins/IslandCaller/Run",
|
||||
UseShellExecute = true
|
||||
});
|
||||
@@ -961,9 +965,9 @@ namespace Ink_Canvas {
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private bool isStopInkReplay = false;
|
||||
private bool isPauseInkReplay = false;
|
||||
private bool isRestartInkReplay = false;
|
||||
private bool isStopInkReplay;
|
||||
private bool isPauseInkReplay;
|
||||
private bool isRestartInkReplay;
|
||||
private double inkReplaySpeed = 1;
|
||||
|
||||
private void InkCanvasForInkReplay_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -1078,7 +1082,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isViewboxFloatingBarMarginAnimationRunning = false;
|
||||
private bool isViewboxFloatingBarMarginAnimationRunning;
|
||||
|
||||
public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge,
|
||||
bool PosXCaculatedWithTaskbarHeight = false) {
|
||||
@@ -1098,7 +1102,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1110,21 +1114,21 @@ namespace Ink_Canvas {
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定边距: {MarginFromEdge}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定边距: {MarginFromEdge}");
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
}
|
||||
}
|
||||
else if (PosXCaculatedWithTaskbarHeight == true)
|
||||
else if (PosXCaculatedWithTaskbarHeight)
|
||||
{
|
||||
// 如果任务栏高度为0(隐藏状态),则使用固定高度
|
||||
if (toolbarHeight == 0)
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1184,7 +1188,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1195,7 +1199,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
|
||||
3 * ViewboxFloatingBarScaleTransform.ScaleY;
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1237,7 +1241,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var windowHandle = new WindowInteropHelper(this).Handle;
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
var screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
|
||||
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
|
||||
@@ -1565,7 +1569,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void DrawShapePromptToPen() {
|
||||
if (isLongPressSelected == true) {
|
||||
if (isLongPressSelected) {
|
||||
// 如果是长按选中的状态,只隐藏面板,不切换到笔模式
|
||||
HideSubPanels("shape");
|
||||
}
|
||||
@@ -1629,7 +1633,7 @@ namespace Ink_Canvas {
|
||||
|
||||
#region Right Side Panel
|
||||
|
||||
public static bool CloseIsFromButton = false;
|
||||
public static bool CloseIsFromButton;
|
||||
|
||||
public void BtnExit_Click(object sender, RoutedEventArgs e) {
|
||||
App.IsAppExitByUser = true;
|
||||
@@ -1646,7 +1650,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SettingsOverlayClick(object sender, MouseButtonEventArgs e) {
|
||||
if (isOpeningOrHidingSettingsPane == true) return;
|
||||
if (isOpeningOrHidingSettingsPane) return;
|
||||
|
||||
// 获取点击的位置
|
||||
Point clickPoint = e.GetPosition(BorderSettingsMask);
|
||||
@@ -1666,7 +1670,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isOpeningOrHidingSettingsPane = false;
|
||||
private bool isOpeningOrHidingSettingsPane;
|
||||
|
||||
private void BtnSettings_Click(object sender, RoutedEventArgs e) {
|
||||
if (BorderSettings.Visibility == Visibility.Visible) {
|
||||
@@ -1685,7 +1689,7 @@ namespace Ink_Canvas {
|
||||
To = 0,
|
||||
Duration = TimeSpan.FromSeconds(0.6)
|
||||
};
|
||||
slideAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
|
||||
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
|
||||
Storyboard.SetTargetProperty(slideAnimation,
|
||||
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
|
||||
|
||||
@@ -1697,13 +1701,13 @@ namespace Ink_Canvas {
|
||||
BorderSettings.RenderTransform = new TranslateTransform();
|
||||
|
||||
isOpeningOrHidingSettingsPane = true;
|
||||
sb.Begin((FrameworkElement)BorderSettings);
|
||||
sb.Begin(BorderSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnThickness_Click(object sender, RoutedEventArgs e) { }
|
||||
|
||||
private bool forceEraser = false;
|
||||
private bool forceEraser;
|
||||
|
||||
|
||||
private void BtnClear_Click(object sender, RoutedEventArgs e) {
|
||||
@@ -1737,7 +1741,7 @@ namespace Ink_Canvas {
|
||||
if (Settings.Canvas.ClearCanvasAndClearTimeMachine) timeMachine.ClearStrokeHistory();
|
||||
}
|
||||
|
||||
private bool lastIsInMultiTouchMode = false;
|
||||
private bool lastIsInMultiTouchMode;
|
||||
|
||||
private void CancelSingleFingerDragMode() {
|
||||
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn) CollapseBorderDrawShape();
|
||||
@@ -1755,7 +1759,7 @@ namespace Ink_Canvas {
|
||||
StackPanelControl.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private int currentMode = 0;
|
||||
private int currentMode;
|
||||
|
||||
private void BtnSwitch_Click(object sender, RoutedEventArgs e) {
|
||||
if (GridTransparencyFakeBackground.Background == Brushes.Transparent) {
|
||||
@@ -1995,7 +1999,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private async void InsertImage_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var dialog = new Microsoft.Win32.OpenFileDialog
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private int lastNotificationShowTime = 0;
|
||||
private int lastNotificationShowTime;
|
||||
private int notificationShowTime = 2500;
|
||||
|
||||
public static void ShowNewMessage(string notice, bool isShowImmediately = true) {
|
||||
@@ -21,13 +21,13 @@ namespace Ink_Canvas {
|
||||
TextBlockNotice.Text = notice;
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(GridNotifications);
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(notificationShowTime + 300);
|
||||
if (Environment.TickCount - lastNotificationShowTime >= notificationShowTime)
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
+107
-103
@@ -1,25 +1,31 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
using Application = System.Windows.Application;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Office.Core;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using Point = System.Drawing.Point;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -30,7 +36,7 @@ namespace Ink_Canvas {
|
||||
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);
|
||||
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId, out uint lpdwThreadId);
|
||||
@@ -60,7 +66,7 @@ namespace Ink_Canvas {
|
||||
private static extern bool GetWindowRect(IntPtr hWnd, out ForegroundWindowInfo.RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern int GetClassName(IntPtr hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
|
||||
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
|
||||
private const int GWL_STYLE = -16;
|
||||
private const int WS_VISIBLE = 0x10000000;
|
||||
@@ -72,14 +78,14 @@ namespace Ink_Canvas {
|
||||
|
||||
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
public static Microsoft.Office.Interop.PowerPoint.Application pptApplication = null;
|
||||
public static Presentation presentation = null;
|
||||
public static Slides slides = null;
|
||||
public static Slide slide = null;
|
||||
public static int slidescount = 0;
|
||||
public static Microsoft.Office.Interop.PowerPoint.Application pptApplication;
|
||||
public static Presentation presentation;
|
||||
public static Slides slides;
|
||||
public static Slide slide;
|
||||
public static int slidescount;
|
||||
|
||||
// 在类中添加字段
|
||||
private bool wasFloatingBarFoldedWhenEnterSlideShow = false;
|
||||
private bool wasFloatingBarFoldedWhenEnterSlideShow;
|
||||
|
||||
// 新增:用于控制WPS强制关闭提示只弹一次
|
||||
private static bool hasShownWpsForceCloseWarning = false;
|
||||
@@ -115,7 +121,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +131,7 @@ namespace Ink_Canvas {
|
||||
StackPanelPPTControls.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查PPT应用程序失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查PPT应用程序失败: {ex}", LogHelper.LogType.Error);
|
||||
//BtnCheckPPT.Visibility = Visibility.Visible;
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -145,16 +151,16 @@ namespace Ink_Canvas {
|
||||
|
||||
private static bool isWPSSupportOn => Settings.PowerPointSettings.IsSupportWPS;
|
||||
|
||||
public static bool IsShowingRestoreHiddenSlidesWindow = false;
|
||||
private static bool IsShowingAutoplaySlidesWindow = false;
|
||||
public static bool IsShowingRestoreHiddenSlidesWindow;
|
||||
private static bool IsShowingAutoplaySlidesWindow;
|
||||
|
||||
// WPP 相关变量
|
||||
private static Process wppProcess = null;
|
||||
private static bool hasWppProcessID = false;
|
||||
private static System.Timers.Timer wppProcessCheckTimer = null;
|
||||
private static Process wppProcess;
|
||||
private static bool hasWppProcessID;
|
||||
private static Timer wppProcessCheckTimer;
|
||||
private static DateTime wppProcessRecordTime = DateTime.MinValue; // 记录进程时间
|
||||
private static int wppProcessCheckCount = 0; // 检查次数计数器
|
||||
private static WpsWindowInfo lastForegroundWpsWindow = null; // 记录上次检测到的前台WPS窗口
|
||||
private static int wppProcessCheckCount; // 检查次数计数器
|
||||
private static WpsWindowInfo lastForegroundWpsWindow; // 记录上次检测到的前台WPS窗口
|
||||
private static DateTime lastWindowCheckTime = DateTime.MinValue; // 记录上次窗口检查时间
|
||||
|
||||
|
||||
@@ -191,7 +197,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,14 +221,14 @@ namespace Ink_Canvas {
|
||||
PptApplication_SlideShowBegin(pptApplication.SlideShowWindows[1]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"启动幻灯片放映失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"启动幻灯片放映失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 忽略常见的COM对象失效错误
|
||||
if (ex is System.Runtime.InteropServices.COMException comEx)
|
||||
if (ex is COMException comEx)
|
||||
{
|
||||
uint hr = (uint)comEx.HResult;
|
||||
// 0x800401E3: 操作无法使用
|
||||
@@ -237,7 +243,7 @@ namespace Ink_Canvas {
|
||||
return;
|
||||
}
|
||||
}
|
||||
LogHelper.WriteLogToFile($"检查PPT状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查PPT状态失败: {ex}", LogHelper.LogType.Error);
|
||||
Application.Current.Dispatcher.Invoke(() => { BtnPPTSlideShow.Visibility = Visibility.Collapsed; });
|
||||
timerCheckPPT.Start();
|
||||
}
|
||||
@@ -262,7 +268,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"跳转到首页失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"跳转到首页失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), DispatcherPriority.Normal);
|
||||
}
|
||||
@@ -295,16 +301,16 @@ namespace Ink_Canvas {
|
||||
presentation.Windows[1].View.GotoSlide(page);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"跳转到指定页面失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"跳转到指定页面失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}).ShowDialog();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"读取上次播放位置失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"读取上次播放位置失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"处理上次播放页跳转失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"处理上次播放页跳转失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), DispatcherPriority.Normal);
|
||||
|
||||
@@ -316,7 +322,7 @@ namespace Ink_Canvas {
|
||||
if (slides != null)
|
||||
{
|
||||
foreach (Slide slide in slides)
|
||||
if (slide.SlideShowTransition.Hidden == Microsoft.Office.Core.MsoTriState.msoTrue) {
|
||||
if (slide.SlideShowTransition.Hidden == MsoTriState.msoTrue) {
|
||||
isHaveHiddenSlide = true;
|
||||
break;
|
||||
}
|
||||
@@ -332,13 +338,13 @@ namespace Ink_Canvas {
|
||||
{
|
||||
foreach (Slide slide in slides)
|
||||
if (slide.SlideShowTransition.Hidden ==
|
||||
Microsoft.Office.Core.MsoTriState.msoTrue)
|
||||
MsoTriState.msoTrue)
|
||||
slide.SlideShowTransition.Hidden =
|
||||
Microsoft.Office.Core.MsoTriState.msoFalse;
|
||||
MsoTriState.msoFalse;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"取消隐藏幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"取消隐藏幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
finally {
|
||||
IsShowingRestoreHiddenSlidesWindow = false;
|
||||
@@ -351,7 +357,7 @@ namespace Ink_Canvas {
|
||||
}), DispatcherPriority.Normal);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查隐藏幻灯片失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查隐藏幻灯片失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +392,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置手动播放模式失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置手动播放模式失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
finally {
|
||||
IsShowingAutoplaySlidesWindow = false;
|
||||
@@ -402,12 +408,12 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置演示文稿播放模式失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置演示文稿播放模式失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"检查自动播放设置失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查自动播放设置失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,8 +439,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isPresentationHaveBlackSpace = false;
|
||||
private string pptName = null;
|
||||
private bool isPresentationHaveBlackSpace;
|
||||
private string pptName;
|
||||
|
||||
private void UpdatePPTBtnStyleSettingsStatus() {
|
||||
try {
|
||||
@@ -600,7 +606,7 @@ namespace Ink_Canvas {
|
||||
else RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"更新PPT按钮显示状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"更新PPT按钮显示状态失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,7 +636,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"放映开始时跳转首页失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"放映开始时跳转首页失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,9 +650,8 @@ namespace Ink_Canvas {
|
||||
//Light
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
} else {
|
||||
//Dark
|
||||
}
|
||||
//Dark
|
||||
}
|
||||
} else if (screenRatio == -256 / 135) { }
|
||||
|
||||
@@ -658,7 +663,7 @@ namespace Ink_Canvas {
|
||||
|
||||
pptName = Wn.Presentation.Name;
|
||||
LogHelper.NewLog("Name: " + Wn.Presentation.Name);
|
||||
LogHelper.NewLog("Slides Count: " + slidescount.ToString());
|
||||
LogHelper.NewLog("Slides Count: " + slidescount);
|
||||
|
||||
//检查是否有已有墨迹,并加载
|
||||
if (Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint)
|
||||
@@ -685,7 +690,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(
|
||||
$"Failed to load strokes on Slide {i}\n{ex.ToString()}",
|
||||
$"Failed to load strokes on Slide {i}\n{ex}",
|
||||
LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
@@ -743,16 +748,16 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"加载当前页墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"加载当前页墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
if (!isFloatingBarFolded) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
});
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
@@ -763,12 +768,12 @@ namespace Ink_Canvas {
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile("PowerPoint Application Slide Show Begin Error: " + ex.ToString(), LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile("PowerPoint Application Slide Show Begin Error: " + ex, LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool isEnteredSlideShowEndEvent = false; //防止重复调用本函数导致墨迹保存失效
|
||||
private bool isEnteredSlideShowEndEvent; //防止重复调用本函数导致墨迹保存失效
|
||||
|
||||
private async void PptApplication_SlideShowEnd(Presentation Pres) {
|
||||
try {
|
||||
@@ -834,11 +839,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"记录WPS进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"记录WPS进程失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile(string.Format("PowerPoint Slide Show End"), LogHelper.LogType.Event);
|
||||
LogHelper.WriteLogToFile("PowerPoint Slide Show End", LogHelper.LogType.Event);
|
||||
if (isEnteredSlideShowEndEvent) {
|
||||
LogHelper.WriteLogToFile("Detected previous entrance, returning");
|
||||
return;
|
||||
@@ -878,7 +883,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile(
|
||||
$"Failed to save strokes for Slide {i}\n{ex.ToString()}",
|
||||
$"Failed to save strokes for Slide {i}\n{ex}",
|
||||
LogHelper.LogType.Error);
|
||||
if (File.Exists(folderPath + @"\" + i.ToString("0000") + ".icstk"))
|
||||
File.Delete(folderPath + @"\" + i.ToString("0000") + ".icstk");
|
||||
@@ -893,10 +898,9 @@ namespace Ink_Canvas {
|
||||
//Light
|
||||
BtnExit.Foreground = Brushes.Black;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
|
||||
} else {
|
||||
//Dark
|
||||
}
|
||||
|
||||
//Dark
|
||||
BtnPPTSlideShow.Visibility = Visibility.Visible;
|
||||
BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
@@ -941,11 +945,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private int previousSlideID = 0;
|
||||
private int previousSlideID;
|
||||
private MemoryStream[] memoryStreams = new MemoryStream[50];
|
||||
|
||||
private DateTime inkLockUntil = DateTime.MinValue;
|
||||
private int lockedSlideIndex = 0;
|
||||
private int lockedSlideIndex;
|
||||
private const int InkLockMilliseconds = 500;
|
||||
|
||||
private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn) {
|
||||
@@ -980,11 +984,11 @@ namespace Ink_Canvas {
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"幻灯片切换事件处理失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"幻灯片切换事件处理失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isPptClickingBtnTurned = false;
|
||||
private bool _isPptClickingBtnTurned;
|
||||
|
||||
private void BtnPPTSlidesUp_Click(object sender, RoutedEventArgs e) {
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
@@ -1023,7 +1027,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"PPT上一页操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT上一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -1070,7 +1074,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"PPT下一页操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT下一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
StackPanelPPTControls.Visibility = Visibility.Collapsed;
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -1177,7 +1181,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"设置PPT导航可见性失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"设置PPT导航可见性失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// 控制居中
|
||||
@@ -1188,17 +1192,17 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"PPT翻页控件操作失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"PPT翻页控件操作失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnPPTSlideShow_Click(object sender, RoutedEventArgs e) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
try {
|
||||
presentation.SlideShowSettings.Run();
|
||||
}
|
||||
catch { }
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private async void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e) {
|
||||
@@ -1240,11 +1244,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
try {
|
||||
// 安全访问SlideShowWindows[1]
|
||||
if (pptApplication.SlideShowWindows.Count >= 1)
|
||||
@@ -1257,9 +1261,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"退出PPT放映失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"退出PPT放映失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
})).Start();
|
||||
}).Start();
|
||||
|
||||
HideSubPanels("cursor");
|
||||
await Task.Delay(150);
|
||||
@@ -1267,7 +1271,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"结束PPT放映操作异常: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"结束PPT放映操作异常: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
// 隐藏侧边栏退出按钮
|
||||
@@ -1289,7 +1293,7 @@ namespace Ink_Canvas {
|
||||
LogHelper.WriteLogToFile("手动隐藏所有放映模式按钮", LogHelper.LogType.Trace);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogHelper.WriteLogToFile($"手动隐藏放映模式按钮失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"手动隐藏放映模式按钮失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1411,13 +1415,13 @@ namespace Ink_Canvas {
|
||||
wppProcessCheckTimer.Dispose();
|
||||
}
|
||||
|
||||
wppProcessCheckTimer = new System.Timers.Timer(500); // 改为500ms检查一次,提高响应速度
|
||||
wppProcessCheckTimer = new Timer(500); // 改为500ms检查一次,提高响应速度
|
||||
wppProcessCheckTimer.Elapsed += WppProcessCheckTimer_Elapsed;
|
||||
wppProcessCheckTimer.Start();
|
||||
LogHelper.WriteLogToFile("启动 WPP 进程检测定时器(前台窗口监控模式)", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
private void WppProcessCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
private void WppProcessCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
// 新增:WPS联动未启用时不查杀wpp进程
|
||||
if (!Settings.PowerPointSettings.IsSupportWPS)
|
||||
@@ -1487,7 +1491,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查WPS文档保存状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查WPS文档保存状态失败: {ex}", LogHelper.LogType.Error);
|
||||
allSaved = false; // 出错时默认不安全
|
||||
}
|
||||
|
||||
@@ -1515,7 +1519,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"结束WPP进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"结束WPP进程失败: {ex}", LogHelper.LogType.Error);
|
||||
|
||||
// 如果常规方法失败,尝试强制结束
|
||||
try
|
||||
@@ -1533,7 +1537,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception forceKillEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"强制结束WPP进程也失败: {forceKillEx.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"强制结束WPP进程也失败: {forceKillEx}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -1543,7 +1547,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"WPP 进程检测失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"WPP 进程检测失败: {ex}", LogHelper.LogType.Error);
|
||||
StopWppProcessCheckTimer();
|
||||
}
|
||||
}
|
||||
@@ -1568,7 +1572,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查WPP窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查WPP窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return false; // 出错时,默认允许Kill
|
||||
}
|
||||
@@ -1619,14 +1623,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return wpsWindows;
|
||||
@@ -1646,12 +1650,12 @@ namespace Ink_Canvas {
|
||||
};
|
||||
|
||||
// 获取窗口标题
|
||||
var windowTitle = new System.Text.StringBuilder(256);
|
||||
var windowTitle = new StringBuilder(256);
|
||||
GetWindowText(hWnd, windowTitle, 256);
|
||||
windowInfo.Title = windowTitle.ToString().Trim();
|
||||
|
||||
// 获取窗口类名
|
||||
var className = new System.Text.StringBuilder(256);
|
||||
var className = new StringBuilder(256);
|
||||
GetClassName(hWnd, className, 256);
|
||||
windowInfo.ClassName = className.ToString().Trim();
|
||||
|
||||
@@ -1668,7 +1672,7 @@ namespace Ink_Canvas {
|
||||
windowInfo.ProcessName = "";
|
||||
try
|
||||
{
|
||||
var proc = System.Diagnostics.Process.GetProcessById((int)processId);
|
||||
var proc = Process.GetProcessById((int)processId);
|
||||
windowInfo.ProcessName = proc.ProcessName.ToLower();
|
||||
}
|
||||
catch { }
|
||||
@@ -1730,7 +1734,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取前台WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取前台WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1805,7 +1809,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查前台WPS窗口状态失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查前台WPS窗口状态失败: {ex}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1837,9 +1841,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 按窗口位置排序,优先选择屏幕中央的窗口
|
||||
var screenCenter = new System.Drawing.Point(
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2
|
||||
var screenCenter = new Point(
|
||||
Screen.PrimaryScreen.Bounds.Width / 2,
|
||||
Screen.PrimaryScreen.Bounds.Height / 2
|
||||
);
|
||||
|
||||
var sortedWindows = allWpsWindows
|
||||
@@ -1854,7 +1858,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取顶级WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取顶级WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return topLevelWindows;
|
||||
@@ -1915,7 +1919,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"第{attempt}次尝试检查活跃WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"第{attempt}次尝试检查活跃WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
|
||||
// 如果还有重试机会,等待一小段时间再重试
|
||||
if (attempt < maxRetries)
|
||||
@@ -1959,13 +1963,13 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查进程{process.ProcessName}失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"检查进程{process.ProcessName}失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"获取WPS进程失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"获取WPS进程失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return wpsProcesses;
|
||||
}
|
||||
@@ -1995,7 +1999,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"调试窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
@@ -2004,7 +2008,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"调试窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2015,7 +2019,7 @@ namespace Ink_Canvas {
|
||||
var wpsWindowCount = 0;
|
||||
var currentProcessId = wppProcess?.Id ?? 0;
|
||||
|
||||
EnumWindows((IntPtr hWnd, IntPtr lParam) =>
|
||||
EnumWindows((hWnd, lParam) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2025,7 +2029,7 @@ namespace Ink_Canvas {
|
||||
// 检查是否是WPP进程的窗口
|
||||
if (windowProcessId == currentProcessId)
|
||||
{
|
||||
var windowTitle = new System.Text.StringBuilder(256);
|
||||
var windowTitle = new StringBuilder(256);
|
||||
GetWindowText(hWnd, windowTitle, 256);
|
||||
var title = windowTitle.ToString().Trim();
|
||||
|
||||
@@ -2040,7 +2044,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"枚举窗口时出错: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
return true; // 继续枚举
|
||||
@@ -2056,7 +2060,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"通过枚举检查WPS窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"通过枚举检查WPS窗口失败: {ex}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2092,15 +2096,15 @@ namespace Ink_Canvas {
|
||||
return "unknown";
|
||||
|
||||
// 使用文件路径的哈希值作为唯一标识符
|
||||
using (var md5 = System.Security.Cryptography.MD5.Create())
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] hashBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(filePath));
|
||||
byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(filePath));
|
||||
return BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 8);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex}", LogHelper.LogType.Error);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
@@ -2130,7 +2134,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
var st = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[index]);
|
||||
st.Clip(new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var pitem = new PageListViewItem()
|
||||
var pitem = new PageListViewItem
|
||||
{
|
||||
Index = index,
|
||||
Strokes = st,
|
||||
@@ -40,7 +40,7 @@ namespace Ink_Canvas
|
||||
foreach (int index in Enumerable.Range(1, WhiteboardTotalCount)) {
|
||||
var st = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[index]);
|
||||
st.Clip(new Rect(0,0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var pitem = new PageListViewItem()
|
||||
var pitem = new PageListViewItem
|
||||
{
|
||||
Index = index,
|
||||
Strokes = st,
|
||||
@@ -51,7 +51,7 @@ namespace Ink_Canvas
|
||||
|
||||
var _st = inkCanvas.Strokes.Clone();
|
||||
_st.Clip(new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var _pitem = new PageListViewItem()
|
||||
var _pitem = new PageListViewItem
|
||||
{
|
||||
Index = CurrentWhiteboardIndex,
|
||||
Strokes = _st,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -13,7 +15,7 @@ namespace Ink_Canvas {
|
||||
CaptureAndSaveScreenshot(savePath, isHideNotification);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false, false);
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
private void SaveScreenShotToDesktop() {
|
||||
@@ -24,16 +26,16 @@ namespace Ink_Canvas {
|
||||
CaptureAndSaveScreenshot(desktopPath, false);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false, false);
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
// 提取公共的截图和保存逻辑
|
||||
private void CaptureAndSaveScreenshot(string savePath, bool isHideNotification) {
|
||||
var rc = System.Windows.Forms.SystemInformation.VirtualScreen;
|
||||
var rc = SystemInformation.VirtualScreen;
|
||||
|
||||
using (var bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
|
||||
using (var memoryGraphics = System.Drawing.Graphics.FromImage(bitmap)) {
|
||||
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, System.Drawing.CopyPixelOperation.SourceCopy);
|
||||
using (var bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
|
||||
using (var memoryGraphics = Graphics.FromImage(bitmap)) {
|
||||
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
|
||||
|
||||
// 确保目录存在
|
||||
var directory = Path.GetDirectoryName(savePath);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
@@ -7,6 +6,7 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -26,7 +26,7 @@ namespace Ink_Canvas {
|
||||
lastBorderMouseDownObject = sender;
|
||||
}
|
||||
|
||||
private bool isStrokeSelectionCloneOn = false;
|
||||
private bool isStrokeSelectionCloneOn;
|
||||
|
||||
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
@@ -229,7 +229,7 @@ namespace Ink_Canvas {
|
||||
|
||||
#endregion
|
||||
|
||||
private bool isGridInkCanvasSelectionCoverMouseDown = false;
|
||||
private bool isGridInkCanvasSelectionCoverMouseDown;
|
||||
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
|
||||
|
||||
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -267,7 +267,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private double BorderStrokeSelectionControlWidth = 490.0;
|
||||
private double BorderStrokeSelectionControlHeight = 80.0;
|
||||
private bool isProgramChangeStrokeSelection = false;
|
||||
private bool isProgramChangeStrokeSelection;
|
||||
|
||||
private void inkCanvas_SelectionChanged(object sender, EventArgs e) {
|
||||
if (isProgramChangeStrokeSelection) return;
|
||||
@@ -459,10 +459,10 @@ namespace Ink_Canvas {
|
||||
|
||||
#region UIElement Selection and Resize
|
||||
|
||||
private UIElement selectedUIElement = null;
|
||||
private System.Windows.Controls.Canvas resizeHandlesCanvas = null;
|
||||
private UIElement selectedUIElement;
|
||||
private System.Windows.Controls.Canvas resizeHandlesCanvas;
|
||||
private readonly List<Rectangle> resizeHandles = new List<Rectangle>();
|
||||
private bool isResizing = false;
|
||||
private bool isResizing;
|
||||
private ResizeDirection currentResizeDirection = ResizeDirection.None;
|
||||
private Point resizeStartPoint;
|
||||
private Rect originalElementBounds;
|
||||
@@ -817,7 +817,7 @@ namespace Ink_Canvas {
|
||||
if (element != null)
|
||||
{
|
||||
// 切换到选择模式并选择这个元素
|
||||
inkCanvas.Select(new UIElement[] { element });
|
||||
inkCanvas.Select(new[] { element });
|
||||
SelectUIElement(element);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using File = System.IO.File;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Interop;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using Application = System.Windows.Application;
|
||||
using CheckBox = System.Windows.Controls.CheckBox;
|
||||
using ComboBox = System.Windows.Controls.ComboBox;
|
||||
using File = System.IO.File;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||
using RadioButton = System.Windows.Controls.RadioButton;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -312,7 +319,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
ComboBoxItem item = new ComboBoxItem();
|
||||
item.Content = customIcon.Name;
|
||||
item.FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei UI");
|
||||
item.FontFamily = new FontFamily("Microsoft YaHei UI");
|
||||
ComboBoxFloatingBarImg.Items.Add(item);
|
||||
}
|
||||
}
|
||||
@@ -834,7 +841,7 @@ namespace Ink_Canvas {
|
||||
Settings.InkToShape.LineStraightenSensitivity = e.NewValue;
|
||||
|
||||
// 输出调试信息,观察值变化
|
||||
System.Diagnostics.Debug.WriteLine($"LineStraightenSensitivity changed: {oldValue} -> {e.NewValue}");
|
||||
Debug.WriteLine($"LineStraightenSensitivity changed: {oldValue} -> {e.NewValue}");
|
||||
|
||||
// 立即保存设置到文件,确保设置不会丢失
|
||||
SaveSettingsToFile();
|
||||
@@ -844,7 +851,7 @@ namespace Ink_Canvas {
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.Canvas.HighPrecisionLineStraighten = ToggleSwitchHighPrecisionLineStraighten.IsOn;
|
||||
System.Diagnostics.Debug.WriteLine($"HighPrecisionLineStraighten changed: {Settings.Canvas.HighPrecisionLineStraighten}");
|
||||
Debug.WriteLine($"HighPrecisionLineStraighten changed: {Settings.Canvas.HighPrecisionLineStraighten}");
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
@@ -1399,7 +1406,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void AutoSavedStrokesLocationButton_Click(object sender, RoutedEventArgs e) {
|
||||
var folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
|
||||
var folderBrowser = new FolderBrowserDialog();
|
||||
folderBrowser.ShowDialog();
|
||||
if (folderBrowser.SelectedPath.Length > 0) AutoSavedStrokesLocation.Text = folderBrowser.SelectedPath;
|
||||
SaveSettingsToFile();
|
||||
@@ -1821,7 +1828,7 @@ namespace Ink_Canvas {
|
||||
private void ToggleSwitchIsEnableEdgeGestureUtil_Toggled(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
Settings.Advanced.IsEnableEdgeGestureUtil = ToggleSwitchIsEnableEdgeGestureUtil.IsOn;
|
||||
if (OSVersion.GetOperatingSystem() >= OSVersionExtension.OperatingSystem.Windows10) EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, ToggleSwitchIsEnableEdgeGestureUtil.IsOn);
|
||||
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10) EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, ToggleSwitchIsEnableEdgeGestureUtil.IsOn);
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
@@ -1913,7 +1920,7 @@ namespace Ink_Canvas {
|
||||
string backupDir = Path.Combine(App.RootPath, "Backups");
|
||||
if (!Directory.Exists(backupDir)) {
|
||||
Directory.CreateDirectory(backupDir);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
|
||||
}
|
||||
|
||||
// 创建备份文件名(使用当前日期时间)
|
||||
@@ -1924,7 +1931,7 @@ namespace Ink_Canvas {
|
||||
string settingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
|
||||
File.WriteAllText(backupPath, settingsJson);
|
||||
|
||||
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
|
||||
MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -1941,7 +1948,7 @@ namespace Ink_Canvas {
|
||||
string backupDir = Path.Combine(App.RootPath, "Backups");
|
||||
if (!Directory.Exists(backupDir)) {
|
||||
Directory.CreateDirectory(backupDir);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
|
||||
MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
@@ -1978,7 +1985,7 @@ namespace Ink_Canvas {
|
||||
// 重新加载设置到UI
|
||||
LoadSettings();
|
||||
|
||||
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
|
||||
MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
@@ -2073,7 +2080,7 @@ namespace Ink_Canvas {
|
||||
|
||||
private async void UpdateChannelSelector_Checked(object sender, RoutedEventArgs e) {
|
||||
if (!isLoaded) return;
|
||||
var radioButton = sender as System.Windows.Controls.RadioButton;
|
||||
var radioButton = sender as RadioButton;
|
||||
if (radioButton != null) {
|
||||
string channel = radioButton.Tag.ToString();
|
||||
UpdateChannel newChannel = channel == "Beta" ? UpdateChannel.Beta : UpdateChannel.Release;
|
||||
@@ -2172,7 +2179,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
ComboBoxItem item = new ComboBoxItem();
|
||||
item.Content = background.Name;
|
||||
item.FontFamily = new System.Windows.Media.FontFamily("Microsoft YaHei UI");
|
||||
item.FontFamily = new FontFamily("Microsoft YaHei UI");
|
||||
ComboBoxPickNameBackground.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -10,11 +6,15 @@ using System.Windows.Ink;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using File = System.IO.File;
|
||||
using OperatingSystem = OSVersionExtension.OperatingSystem;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : System.Windows.Window {
|
||||
public partial class MainWindow : Window {
|
||||
private void LoadSettings(bool isStartup = false) {
|
||||
AppVersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
try {
|
||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 初始化更新通道选择
|
||||
foreach (var radioButton in UpdateChannelSelector.Items) {
|
||||
if (radioButton is System.Windows.Controls.RadioButton rb) {
|
||||
if (radioButton is RadioButton rb) {
|
||||
if (rb.Tag.ToString() == Settings.Startup.UpdateChannel.ToString()) {
|
||||
rb.IsChecked = true;
|
||||
break;
|
||||
@@ -465,7 +465,7 @@ namespace Ink_Canvas {
|
||||
BoardComboBoxEraserSize.SelectedIndex = Settings.Canvas.EraserSize;
|
||||
|
||||
ToggleSwitchClearCanvasAndClearTimeMachine.IsOn =
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine == true;
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine;
|
||||
ToggleSwitchClearCanvasAlsoClearImages.IsOn = Settings.Canvas.ClearCanvasAlsoClearImages;
|
||||
|
||||
switch (Settings.Canvas.EraserShapeType) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,6 +8,8 @@ using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
@@ -55,8 +56,8 @@ namespace Ink_Canvas {
|
||||
|
||||
#endregion Floating Bar Control
|
||||
|
||||
private int drawingShapeMode = 0;
|
||||
private bool isLongPressSelected = false; // 用于存是否是"选中"状态,便于后期抬笔后不做切换到笔的处理
|
||||
private int drawingShapeMode;
|
||||
private bool isLongPressSelected; // 用于存是否是"选中"状态,便于后期抬笔后不做切换到笔的处理
|
||||
|
||||
#region Buttons
|
||||
|
||||
@@ -66,12 +67,12 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchDrawShapeBorderAutoHide.IsOn = !ToggleSwitchDrawShapeBorderAutoHide.IsOn;
|
||||
|
||||
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn)
|
||||
((iNKORE.UI.WPF.Modern.Controls.SymbolIcon)sender).Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pin;
|
||||
((SymbolIcon)sender).Symbol = Symbol.Pin;
|
||||
else
|
||||
((iNKORE.UI.WPF.Modern.Controls.SymbolIcon)sender).Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.UnPin;
|
||||
((SymbolIcon)sender).Symbol = Symbol.UnPin;
|
||||
}
|
||||
|
||||
private object lastMouseDownSender = null;
|
||||
private object lastMouseDownSender;
|
||||
private DateTime lastMouseDownTime = DateTime.MinValue;
|
||||
|
||||
private async void Image_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
@@ -402,23 +403,22 @@ namespace Ink_Canvas {
|
||||
inkCanvas.EditingMode == InkCanvasEditingMode.Select ||
|
||||
inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
// 允许正常橡皮、套索、批注
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private int drawMultiStepShapeCurrentStep = 0; //多笔完成的图形 当前所处在的笔画
|
||||
private int drawMultiStepShapeCurrentStep; //多笔完成的图形 当前所处在的笔画
|
||||
|
||||
private StrokeCollection drawMultiStepShapeSpecialStrokeCollection = new StrokeCollection(); //多笔完成的图形 当前所处在的笔画
|
||||
|
||||
//double drawMultiStepShapeSpecialParameter1 = 0.0; //多笔完成的图形 特殊参数 通常用于表示a
|
||||
//double drawMultiStepShapeSpecialParameter2 = 0.0; //多笔完成的图形 特殊参数 通常用于表示b
|
||||
private double drawMultiStepShapeSpecialParameter3 = 0.0; //多笔完成的图形 特殊参数 通常用于表示k
|
||||
private double drawMultiStepShapeSpecialParameter3; //多笔完成的图形 特殊参数 通常用于表示k
|
||||
|
||||
#region 形状绘制主函数
|
||||
|
||||
private void MouseTouchMove(Point endP) {
|
||||
// 禁用原有的FitToCurve,使用新的高级贝塞尔曲线平滑
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
if (Settings.Canvas.FitToCurve) drawingAttributes.FitToCurve = false;
|
||||
ViewboxFloatingBar.IsHitTestVisible = false;
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
List<Point> pointList;
|
||||
@@ -1041,7 +1041,7 @@ namespace Ink_Canvas {
|
||||
strokes.Add(stroke.Clone());
|
||||
//底部椭圆
|
||||
pointList = GenerateEllipseGeometry(new Point(newIniP.X, endP.Y - topB / 2),
|
||||
new Point(endP.X, endP.Y + topB / 2), false, true);
|
||||
new Point(endP.X, endP.Y + topB / 2), false);
|
||||
point = new StylusPointCollection(pointList);
|
||||
stroke = new Stroke(point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
@@ -1090,7 +1090,7 @@ namespace Ink_Canvas {
|
||||
var bottomB = bottomA / 2.646;
|
||||
//底部椭圆
|
||||
pointList = GenerateEllipseGeometry(new Point(newIniP.X, endP.Y - bottomB / 2),
|
||||
new Point(endP.X, endP.Y + bottomB / 2), false, true);
|
||||
new Point(endP.X, endP.Y + bottomB / 2), false);
|
||||
point = new StylusPointCollection(pointList);
|
||||
stroke = new Stroke(point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
@@ -1221,13 +1221,13 @@ namespace Ink_Canvas {
|
||||
#endregion
|
||||
|
||||
private bool isFirstTouchCuboid = true;
|
||||
private Point CuboidFrontRectIniP = new Point();
|
||||
private Point CuboidFrontRectEndP = new Point();
|
||||
private Point CuboidFrontRectIniP;
|
||||
private Point CuboidFrontRectEndP;
|
||||
|
||||
private Stroke lastTempStroke = null;
|
||||
private Stroke lastTempStroke;
|
||||
private StrokeCollection lastTempStrokeCollection = new StrokeCollection();
|
||||
|
||||
private bool isWaitUntilNextTouchDown = false;
|
||||
private bool isWaitUntilNextTouchDown;
|
||||
|
||||
private List<Point> GenerateEllipseGeometry(Point st, Point ed, bool isDrawTop = true,
|
||||
bool isDrawBottom = true) {
|
||||
@@ -1377,7 +1377,7 @@ namespace Ink_Canvas {
|
||||
return strokes;
|
||||
}
|
||||
|
||||
private bool isMouseDown = false;
|
||||
private bool isMouseDown;
|
||||
|
||||
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
inkCanvas.CaptureMouse();
|
||||
@@ -1547,7 +1547,7 @@ namespace Ink_Canvas {
|
||||
StrokeCollection collection = null;
|
||||
if (lastTempStrokeCollection != null && lastTempStrokeCollection.Count > 0)
|
||||
collection = lastTempStrokeCollection;
|
||||
else if (lastTempStroke != null) collection = new StrokeCollection() { lastTempStroke };
|
||||
else if (lastTempStroke != null) collection = new StrokeCollection { lastTempStroke };
|
||||
if (collection != null) timeMachine.CommitStrokeUserInputHistory(collection);
|
||||
}
|
||||
|
||||
@@ -1593,10 +1593,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"形状绘制高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"形状绘制高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else if (Settings.Canvas.FitToCurve == true)
|
||||
else if (Settings.Canvas.FitToCurve)
|
||||
{
|
||||
drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -21,7 +22,7 @@ namespace Ink_Canvas {
|
||||
bool wasStraightened = false;
|
||||
|
||||
// 禁用原有的FitToCurve,使用新的高级贝塞尔曲线平滑
|
||||
if (Settings.Canvas.FitToCurve == true) drawingAttributes.FitToCurve = false;
|
||||
if (Settings.Canvas.FitToCurve) drawingAttributes.FitToCurve = false;
|
||||
|
||||
try {
|
||||
inkCanvas.Opacity = 1;
|
||||
@@ -134,13 +135,13 @@ namespace Ink_Canvas {
|
||||
// 先完成所有直线判定,再考虑端点吸附
|
||||
// 读取实际的灵敏度设置值
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
System.Diagnostics.Debug.WriteLine($"当前灵敏度值: {sensitivity}");
|
||||
Debug.WriteLine($"当前灵敏度值: {sensitivity}");
|
||||
|
||||
// 判断是否应该拉直线条
|
||||
bool shouldStraighten = ShouldStraightenLine(e.Stroke);
|
||||
|
||||
// 输出一些调试信息,帮助理解灵敏度设置的效果
|
||||
System.Diagnostics.Debug.WriteLine($"LineStraightenSensitivity: {Settings.InkToShape.LineStraightenSensitivity}, ShouldStraighten: {shouldStraighten}");
|
||||
Debug.WriteLine($"LineStraightenSensitivity: {Settings.InkToShape.LineStraightenSensitivity}, ShouldStraighten: {shouldStraighten}");
|
||||
|
||||
// 只有当确定要拉直线条时,才检查端点吸附
|
||||
if (shouldStraighten && Settings.Canvas.LineEndpointSnapping) {
|
||||
@@ -208,7 +209,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
if (result.InkDrawingNode.GetShapeName() == "Circle" &&
|
||||
Settings.InkToShape.IsInkToShapeRounded == true) {
|
||||
Settings.InkToShape.IsInkToShapeRounded) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
if (shape.Width > 75) {
|
||||
foreach (var circle in circles)
|
||||
@@ -264,7 +265,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
else if (result.InkDrawingNode.GetShapeName().Contains("Ellipse") &&
|
||||
Settings.InkToShape.IsInkToShapeRounded == true) {
|
||||
Settings.InkToShape.IsInkToShapeRounded) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
//var shape1 = result.InkDrawingNode.GetShape();
|
||||
//shape1.Fill = Brushes.Gray;
|
||||
@@ -334,14 +335,14 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
||||
newStrokes = new StrokeCollection();
|
||||
|
||||
var _pointList = GenerateEllipseGeometry(iniP, endP, false, true);
|
||||
var _pointList = GenerateEllipseGeometry(iniP, endP, false);
|
||||
var _point = new StylusPointCollection(_pointList);
|
||||
var _stroke = new Stroke(_point) {
|
||||
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
|
||||
};
|
||||
var _dashedLineStroke =
|
||||
GenerateDashedLineEllipseStrokeCollection(iniP, endP, true, false);
|
||||
var strokes = new StrokeCollection() {
|
||||
var strokes = new StrokeCollection {
|
||||
_stroke,
|
||||
_dashedLineStroke
|
||||
};
|
||||
@@ -398,7 +399,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
else if (result.InkDrawingNode.GetShapeName().Contains("Triangle") &&
|
||||
Settings.InkToShape.IsInkToShapeTriangle == true) {
|
||||
Settings.InkToShape.IsInkToShapeTriangle) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
var p = result.InkDrawingNode.HotPoints;
|
||||
if ((Math.Max(Math.Max(p[0].X, p[1].X), p[2].X) -
|
||||
@@ -437,7 +438,7 @@ namespace Ink_Canvas {
|
||||
result.InkDrawingNode.GetShapeName().Contains("Parallelogram") ||
|
||||
result.InkDrawingNode.GetShapeName().Contains("Square") ||
|
||||
result.InkDrawingNode.GetShapeName().Contains("Trapezoid")) &&
|
||||
Settings.InkToShape.IsInkToShapeRectangle == true) {
|
||||
Settings.InkToShape.IsInkToShapeRectangle) {
|
||||
var shape = result.InkDrawingNode.GetShape();
|
||||
var p = result.InkDrawingNode.HotPoints;
|
||||
if ((Math.Max(Math.Max(Math.Max(p[0].X, p[1].X), p[2].X), p[3].X) -
|
||||
@@ -514,7 +515,7 @@ namespace Ink_Canvas {
|
||||
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());
|
||||
s += speed.ToString() + "\t";
|
||||
s += speed + "\t";
|
||||
var point = new StylusPoint();
|
||||
if (speed >= 0.25)
|
||||
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1.5) - 0.3) / 1.2);
|
||||
@@ -614,10 +615,10 @@ namespace Ink_Canvas {
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 如果高级平滑失败,回退到原始笔画
|
||||
System.Diagnostics.Debug.WriteLine($"高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"高级贝塞尔曲线平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else if (Settings.Canvas.FitToCurve == true && !wasStraightened)
|
||||
else if (Settings.Canvas.FitToCurve && !wasStraightened)
|
||||
{
|
||||
drawingAttributes.FitToCurve = true;
|
||||
}
|
||||
@@ -645,7 +646,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"异步墨迹平滑失败: {ex.Message}");
|
||||
Debug.WriteLine($"异步墨迹平滑失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +669,7 @@ namespace Ink_Canvas {
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 输出当前灵敏度值(调试用)
|
||||
System.Diagnostics.Debug.WriteLine($"IsPotentialStraightLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
Debug.WriteLine($"IsPotentialStraightLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
|
||||
// 根据灵敏度调整快速检查阈值
|
||||
double quickThreshold;
|
||||
@@ -682,7 +683,7 @@ namespace Ink_Canvas {
|
||||
quickThreshold = Math.Min(sensitivity * 1.5, 0.20);
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"使用快速检查阈值: {quickThreshold}");
|
||||
Debug.WriteLine($"使用快速检查阈值: {quickThreshold}");
|
||||
|
||||
// 快速检查:计算几个关键点与直线的距离
|
||||
if (stroke.StylusPoints.Count >= 10) {
|
||||
@@ -703,7 +704,7 @@ namespace Ink_Canvas {
|
||||
double quickRelativeThreshold = lineLength * quickThreshold;
|
||||
|
||||
// 记录检测到的偏差(调试用)
|
||||
System.Diagnostics.Debug.WriteLine($"Deviations: q={quarterDeviation}, m={midDeviation}, tq={threeQuarterDeviation}, threshold={quickRelativeThreshold}");
|
||||
Debug.WriteLine($"Deviations: q={quarterDeviation}, m={midDeviation}, tq={threeQuarterDeviation}, threshold={quickRelativeThreshold}");
|
||||
|
||||
// 如果灵敏度超过1.5,则即使有一个点满足条件也认为可能是直线
|
||||
if (sensitivity > 1.5) {
|
||||
@@ -745,7 +746,7 @@ namespace Ink_Canvas {
|
||||
double sensitivity = Settings.InkToShape.LineStraightenSensitivity;
|
||||
|
||||
// 输出详细的调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"ShouldStraightenLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
Debug.WriteLine($"ShouldStraightenLine - sensitivity: {sensitivity}, length: {lineLength}");
|
||||
|
||||
// 临时:显示调试消息框
|
||||
// MessageBox.Show($"灵敏度值: {sensitivity}", "调试信息");
|
||||
@@ -758,7 +759,7 @@ namespace Ink_Canvas {
|
||||
bool useHighPrecision = Settings.Canvas.HighPrecisionLineStraighten;
|
||||
|
||||
if (useHighPrecision) {
|
||||
System.Diagnostics.Debug.WriteLine("使用高精度直线拉直模式");
|
||||
Debug.WriteLine("使用高精度直线拉直模式");
|
||||
|
||||
// 高精度模式:每隔10像素取一个计数点
|
||||
double strokeLength = 0;
|
||||
@@ -844,7 +845,7 @@ namespace Ink_Canvas {
|
||||
double avgDeviation = totalDeviation / pointCount;
|
||||
|
||||
// 更详细的调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"Max deviation: {maxDeviation}, Avg: {avgDeviation}, Threshold: {sensitivity * lineLength}, Points: {pointCount}");
|
||||
Debug.WriteLine($"Max deviation: {maxDeviation}, Avg: {avgDeviation}, Threshold: {sensitivity * lineLength}, Points: {pointCount}");
|
||||
|
||||
// 支持更广泛的灵敏度范围 (0.05-2.0)
|
||||
|
||||
@@ -855,129 +856,128 @@ namespace Ink_Canvas {
|
||||
|
||||
// 只判断平均偏差和相对偏差
|
||||
if (maxDeviation / lineLength < adjustedSensitivity && avgDeviation < lineLength * 0.1 * adjustedSensitivity) {
|
||||
System.Diagnostics.Debug.WriteLine("接受拉直 (高灵敏度模式)");
|
||||
Debug.WriteLine("接受拉直 (高灵敏度模式)");
|
||||
return true;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直 (高灵敏度模式)");
|
||||
Debug.WriteLine("拒绝拉直 (高灵敏度模式)");
|
||||
return false;
|
||||
}
|
||||
// 否则使用常规判断标准
|
||||
else {
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
|
||||
// 检查点分布的一致性 - 如果有些点偏离很大而其他点很接近直线,表明线条有明显弯曲
|
||||
double deviationVariance = 0;
|
||||
|
||||
// 使用相同的高精度/原始模式来计算方差
|
||||
if (useHighPrecision) {
|
||||
// 高精度模式:重新采样计算方差
|
||||
double strokeLength = 0;
|
||||
double sampleInterval = 10.0; // 10像素间隔
|
||||
// 使用相同的高精度/原始模式来计算方差
|
||||
if (useHighPrecision) {
|
||||
// 高精度模式:重新采样计算方差
|
||||
double strokeLength = 0;
|
||||
double sampleInterval = 10.0; // 10像素间隔
|
||||
|
||||
// 计算笔画的总长度,用于后续采样
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point p1 = stroke.StylusPoints[i-1].ToPoint();
|
||||
Point p2 = stroke.StylusPoints[i].ToPoint();
|
||||
strokeLength += GetDistance(p1, p2);
|
||||
}
|
||||
// 计算笔画的总长度,用于后续采样
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point p1 = stroke.StylusPoints[i-1].ToPoint();
|
||||
Point p2 = stroke.StylusPoints[i].ToPoint();
|
||||
strokeLength += GetDistance(p1, p2);
|
||||
}
|
||||
|
||||
// 如果笔画太短,直接使用所有点
|
||||
if (strokeLength < sampleInterval * 5) {
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 使用等距采样点
|
||||
double currentLength = 0;
|
||||
double nextSampleAt = 0;
|
||||
Point lastPoint = start;
|
||||
|
||||
// 起点方差
|
||||
double deviation = DistanceFromLineToPoint(start, end, lastPoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 采样中间点
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point currentPoint = stroke.StylusPoints[i].ToPoint();
|
||||
double segmentLength = GetDistance(lastPoint, currentPoint);
|
||||
|
||||
// 如果这段线段跨越了下一个采样点
|
||||
while (currentLength + segmentLength >= nextSampleAt) {
|
||||
// 计算采样点在线段上的位置
|
||||
double t = (nextSampleAt - currentLength) / segmentLength;
|
||||
Point samplePoint = new Point(
|
||||
lastPoint.X + t * (currentPoint.X - lastPoint.X),
|
||||
lastPoint.Y + t * (currentPoint.Y - lastPoint.Y)
|
||||
);
|
||||
|
||||
// 计算采样点的方差
|
||||
deviation = DistanceFromLineToPoint(start, end, samplePoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 设置下一个采样点位置
|
||||
nextSampleAt += sampleInterval;
|
||||
|
||||
// 防止无限循环
|
||||
if (nextSampleAt > strokeLength) break;
|
||||
}
|
||||
|
||||
currentLength += segmentLength;
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
|
||||
// 终点方差
|
||||
deviation = DistanceFromLineToPoint(start, end, end);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 原始模式:使用所有点计算方差
|
||||
// 如果笔画太短,直接使用所有点
|
||||
if (strokeLength < sampleInterval * 5) {
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
}
|
||||
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 输出更多调试信息
|
||||
System.Diagnostics.Debug.WriteLine($"Deviation variance: {deviationVariance}, Threshold: {sensitivity * lineLength * 0.05}");
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
// 灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:最大偏差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
// 灵敏度越大,容许的偏差方差越大
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:偏差方差过大");
|
||||
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);
|
||||
|
||||
// 输出中点偏差信息
|
||||
System.Diagnostics.Debug.WriteLine($"Mid deviation: {midDeviation}, Threshold: {lineLength * sensitivity * 0.8}");
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
// 使用灵敏度作为判断基准,灵敏度越大,容许的中点偏离越大
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
System.Diagnostics.Debug.WriteLine("拒绝拉直:中点偏差过大");
|
||||
return false;
|
||||
} else {
|
||||
// 使用等距采样点
|
||||
double currentLength = 0;
|
||||
double nextSampleAt = 0;
|
||||
Point lastPoint = start;
|
||||
|
||||
// 起点方差
|
||||
double deviation = DistanceFromLineToPoint(start, end, lastPoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 采样中间点
|
||||
for (int i = 1; i < stroke.StylusPoints.Count; i++) {
|
||||
Point currentPoint = stroke.StylusPoints[i].ToPoint();
|
||||
double segmentLength = GetDistance(lastPoint, currentPoint);
|
||||
|
||||
// 如果这段线段跨越了下一个采样点
|
||||
while (currentLength + segmentLength >= nextSampleAt) {
|
||||
// 计算采样点在线段上的位置
|
||||
double t = (nextSampleAt - currentLength) / segmentLength;
|
||||
Point samplePoint = new Point(
|
||||
lastPoint.X + t * (currentPoint.X - lastPoint.X),
|
||||
lastPoint.Y + t * (currentPoint.Y - lastPoint.Y)
|
||||
);
|
||||
|
||||
// 计算采样点的方差
|
||||
deviation = DistanceFromLineToPoint(start, end, samplePoint);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
|
||||
// 设置下一个采样点位置
|
||||
nextSampleAt += sampleInterval;
|
||||
|
||||
// 防止无限循环
|
||||
if (nextSampleAt > strokeLength) break;
|
||||
}
|
||||
|
||||
currentLength += segmentLength;
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
|
||||
// 终点方差
|
||||
deviation = DistanceFromLineToPoint(start, end, end);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
} else {
|
||||
// 原始模式:使用所有点计算方差
|
||||
foreach (StylusPoint sp in stroke.StylusPoints) {
|
||||
Point p = sp.ToPoint();
|
||||
double deviation = DistanceFromLineToPoint(start, end, p);
|
||||
deviationVariance += Math.Pow(deviation - avgDeviation, 2);
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("接受拉直");
|
||||
return true;
|
||||
}
|
||||
|
||||
deviationVariance /= pointCount;
|
||||
|
||||
// 输出更多调试信息
|
||||
Debug.WriteLine($"Deviation variance: {deviationVariance}, Threshold: {sensitivity * lineLength * 0.05}");
|
||||
|
||||
// 如果最大偏差超过线长的阈值比例,或者偏差方差较大(表示不均匀弯曲),则不拉直
|
||||
// 灵敏度越大,容许的偏差越大,更容易将线条识别为直线
|
||||
if ((maxDeviation / lineLength) > sensitivity) {
|
||||
Debug.WriteLine("拒绝拉直:最大偏差过大");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果偏差方差大,说明线条弯曲不均匀
|
||||
// 灵敏度越大,容许的偏差方差越大
|
||||
if (deviationVariance > (sensitivity * lineLength * 0.05)) {
|
||||
Debug.WriteLine("拒绝拉直:偏差方差过大");
|
||||
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);
|
||||
|
||||
// 输出中点偏差信息
|
||||
Debug.WriteLine($"Mid deviation: {midDeviation}, Threshold: {lineLength * sensitivity * 0.8}");
|
||||
|
||||
// 如果中点偏离过大,不拉直
|
||||
// 使用灵敏度作为判断基准,灵敏度越大,容许的中点偏离越大
|
||||
if (midDeviation > (lineLength * sensitivity * 0.8)) {
|
||||
Debug.WriteLine("拒绝拉直:中点偏差过大");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("接受拉直");
|
||||
return true;
|
||||
}
|
||||
|
||||
// New method: Creates a straight line stroke between two points
|
||||
@@ -987,7 +987,7 @@ namespace Ink_Canvas {
|
||||
// 根据是否启用压感触屏模式决定如何设置压感
|
||||
// 如果未启用压感触屏模式,则使用均匀粗细
|
||||
if (!Settings.Canvas.EnablePressureTouchMode || Settings.Canvas.DisablePressure ||
|
||||
Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
Settings.InkToShape.IsInkToShapeNoFakePressureRectangle || penType == 1) {
|
||||
// 使用均匀粗细(所有点压感值都是0.5f)
|
||||
points.Add(new StylusPoint(start.X, start.Y, 0.5f));
|
||||
|
||||
@@ -1083,7 +1083,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// Return snapped points if any snapping occurred
|
||||
if (startSnapped || endSnapped) {
|
||||
return new Point[] { snappedStart, snappedEnd };
|
||||
return new[] { snappedStart, snappedEnd };
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -1140,7 +1140,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
public StylusPointCollection GenerateFakePressureTriangle(StylusPointCollection points) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureTriangle == true || penType == 1) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureTriangle || penType == 1) {
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
@@ -1174,30 +1174,30 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
public StylusPointCollection GenerateFakePressureRectangle(StylusPointCollection points) {
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle == true || penType == 1) {
|
||||
public StylusPointCollection GenerateFakePressureRectangle(StylusPointCollection points)
|
||||
{
|
||||
if (Settings.InkToShape.IsInkToShapeNoFakePressureRectangle || penType == 1) {
|
||||
return points;
|
||||
}
|
||||
else {
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[1], points[2]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[2], points[3]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[3], points[0]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
var newPoint = new StylusPointCollection();
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
var cPoint = GetCenterPoint(points[0], points[1]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[1].X, points[1].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[1], points[2]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[2].X, points[2].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[2], points[3]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
newPoint.Add(new StylusPoint(points[3].X, points[3].Y, (float)0.4));
|
||||
cPoint = GetCenterPoint(points[3], points[0]);
|
||||
newPoint.Add(new StylusPoint(cPoint.X, cPoint.Y, (float)0.8));
|
||||
newPoint.Add(new StylusPoint(points[0].X, points[0].Y, (float)0.4));
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
public Point GetCenterPoint(Point point1, Point point2) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -32,7 +32,7 @@ namespace Ink_Canvas {
|
||||
private Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> DrawingAttributesHistory =
|
||||
new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
|
||||
|
||||
private Dictionary<Guid, List<Stroke>> DrawingAttributesHistoryFlag = new Dictionary<Guid, List<Stroke>>() {
|
||||
private Dictionary<Guid, List<Stroke>> DrawingAttributesHistoryFlag = new Dictionary<Guid, List<Stroke>> {
|
||||
{ DrawingAttributeIds.Color, new List<Stroke>() },
|
||||
{ DrawingAttributeIds.DrawingFlags, new List<Stroke>() },
|
||||
{ DrawingAttributeIds.IsHighlighter, new List<Stroke>() },
|
||||
@@ -145,7 +145,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private StrokeCollection ApplyHistoriesToNewStrokeCollection(TimeMachineHistory[] items) {
|
||||
InkCanvas fakeInkCanv = new InkCanvas() {
|
||||
InkCanvas fakeInkCanv = new InkCanvas {
|
||||
Width = inkCanvas.ActualWidth,
|
||||
Height = inkCanvas.ActualHeight,
|
||||
EditingMode = InkCanvasEditingMode.None,
|
||||
@@ -202,24 +202,23 @@ namespace Ink_Canvas {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Added.Count != 0) {
|
||||
if (e.Added.Count != 0)
|
||||
{
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
timeMachine.CommitStrokeShapeHistory(ReplacedStroke, e.Added);
|
||||
ReplacedStroke = null;
|
||||
return;
|
||||
} else {
|
||||
timeMachine.CommitStrokeUserInputHistory(e.Added);
|
||||
return;
|
||||
}
|
||||
|
||||
timeMachine.CommitStrokeUserInputHistory(e.Added);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Removed.Count != 0) {
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
ReplacedStroke = e.Removed;
|
||||
return;
|
||||
} else if (!IsEraseByPoint || _currentCommitType == CommitReason.ClearingCanvas) {
|
||||
timeMachine.CommitStrokeEraseHistory(e.Removed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public class TimeViewModel : INotifyPropertyChanged {
|
||||
@@ -49,9 +49,9 @@ namespace Ink_Canvas {
|
||||
private Timer timerCheckPPT = new Timer();
|
||||
private Timer timerKillProcess = new Timer();
|
||||
private Timer timerCheckAutoFold = new Timer();
|
||||
private string AvailableLatestVersion = null;
|
||||
private string AvailableLatestVersion;
|
||||
private Timer timerCheckAutoUpdateWithSilence = new Timer();
|
||||
private bool isHidingSubPanelsWhenInking = false; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
||||
private bool isHidingSubPanelsWhenInking; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
||||
|
||||
private Timer timerDisplayTime = new Timer();
|
||||
private Timer timerDisplayDate = new Timer();
|
||||
@@ -232,8 +232,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
|
||||
private bool foldFloatingBarByUser = false, // 保持收纳操作不受自动收纳的控制
|
||||
unfoldFloatingBarByUser = false; // 允许用户在希沃软件内进行展开操作
|
||||
private bool foldFloatingBarByUser, // 保持收纳操作不受自动收纳的控制
|
||||
unfoldFloatingBarByUser; // 允许用户在希沃软件内进行展开操作
|
||||
|
||||
private void timerCheckAutoFold_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
if (isFloatingBarChangingHideMode) return;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -8,16 +7,16 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Point = System.Windows.Point;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
#region Multi-Touch
|
||||
|
||||
private bool isInMultiTouchMode = false;
|
||||
private bool isInMultiTouchMode;
|
||||
private List<int> dec = new List<int>();
|
||||
private bool isSingleFingerDragMode = false;
|
||||
private bool isSingleFingerDragMode;
|
||||
private Point centerPoint = new Point(0, 0);
|
||||
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
||||
|
||||
@@ -273,10 +272,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 手掌擦相关变量
|
||||
private bool isPalmEraserActive = false;
|
||||
private bool isPalmEraserActive;
|
||||
private InkCanvasEditingMode palmEraserLastEditingMode = InkCanvasEditingMode.Ink;
|
||||
private bool palmEraserLastIsHighlighter = false;
|
||||
private bool palmEraserWasEnabledBeforeMultiTouch = false;
|
||||
private bool palmEraserLastIsHighlighter;
|
||||
private bool palmEraserWasEnabledBeforeMultiTouch;
|
||||
|
||||
private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e) {
|
||||
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
|
||||
@@ -358,7 +357,7 @@ namespace Ink_Canvas {
|
||||
if (drawingShapeMode != 0) {
|
||||
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
|
||||
{
|
||||
RoutedEvent = UIElement.MouseLeftButtonUpEvent,
|
||||
RoutedEvent = MouseLeftButtonUpEvent,
|
||||
Source = inkCanvas
|
||||
};
|
||||
inkCanvas_MouseUp(inkCanvas, mouseArgs);
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Application = System.Windows.Application;
|
||||
using ContextMenu = System.Windows.Controls.ContextMenu;
|
||||
using MenuItem = System.Windows.Controls.MenuItem;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -21,7 +25,7 @@ namespace Ink_Canvas
|
||||
(TextBlock)((SimpleStackPanel)((MenuItem)s.Items[s.Items.Count - 5]).Header).Children[0];
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var HideICCMainWindowTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 9];
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
// 判斷是否在收納模式中
|
||||
if (mainWin.isFloatingBarFolded) {
|
||||
@@ -46,18 +50,18 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
private void CloseAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
Application.Current.Shutdown();
|
||||
IsAppExitByUser = true;
|
||||
Current.Shutdown();
|
||||
// mainWin.BtnExit_Click(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
IsAppExitByUser = true;
|
||||
|
||||
try {
|
||||
// 启动新实例
|
||||
@@ -73,22 +77,22 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 退出当前实例
|
||||
Application.Current.Shutdown();
|
||||
Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
Ink_Canvas.MainWindow.MoveWindow(new WindowInteropHelper(mainWin).Handle, 0, 0,
|
||||
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true);
|
||||
Ink_Canvas.MainWindow.ShowNewMessage($"已强制全屏化:{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height}(缩放比例为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, true);
|
||||
Ink_Canvas.MainWindow.ShowNewMessage($"已强制全屏化:{Screen.PrimaryScreen.Bounds.Width}x{Screen.PrimaryScreen.Bounds.Height}(缩放比例为{Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})");
|
||||
}
|
||||
}
|
||||
|
||||
private void FoldFloatingBarTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded)
|
||||
if (mainWin.isFloatingBarFolded) mainWin.UnFoldFloatingBar_MouseUp(new object(),null);
|
||||
else mainWin.FoldFloatingBar_MouseUp(new object(),null);
|
||||
@@ -96,7 +100,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void ResetFloatingBarPositionTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
var isInPPTPresentationMode = false;
|
||||
Dispatcher.Invoke(() => {
|
||||
@@ -111,10 +115,10 @@ namespace Ink_Canvas
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_Checked(object sender, RoutedEventArgs e) {
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
mainWin.Hide();
|
||||
var s = ((TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5];
|
||||
var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6];
|
||||
@@ -132,10 +136,10 @@ namespace Ink_Canvas
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_UnChecked(object sender, RoutedEventArgs e) {
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
mainWin.Show();
|
||||
var s = ((TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5];
|
||||
var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6];
|
||||
|
||||
Reference in New Issue
Block a user