代码清理
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -6,15 +8,16 @@ 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 {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public bool isFloatingBarFolded;
|
||||
private bool isFloatingBarChangingHideMode;
|
||||
|
||||
private void CloseWhiteboardImmediately() {
|
||||
private void CloseWhiteboardImmediately()
|
||||
{
|
||||
if (isDisplayingOrHidingBlackboard) return;
|
||||
isDisplayingOrHidingBlackboard = true;
|
||||
HideSubPanelsImmediately();
|
||||
@@ -28,13 +31,15 @@ namespace Ink_Canvas {
|
||||
BtnSwitch_Click(BtnSwitch, null);
|
||||
BtnExit.Foreground = Brushes.White;
|
||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||
new Thread(() => {
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
public async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await FoldFloatingBar(sender);
|
||||
}
|
||||
|
||||
@@ -42,7 +47,8 @@ namespace Ink_Canvas {
|
||||
{
|
||||
var isShouldRejectAction = false;
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
|
||||
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
|
||||
if (sender == Fold_Icon && lastBorderMouseDownObject != Fold_Icon) isShouldRejectAction = true;
|
||||
@@ -59,7 +65,8 @@ namespace Ink_Canvas {
|
||||
|
||||
if (isFloatingBarChangingHideMode) return;
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
InkCanvasForInkReplay.Visibility = Visibility.Collapsed;
|
||||
InkCanvasGridForInkReplay.Visibility = Visibility.Visible;
|
||||
InkCanvasGridForInkReplay.IsHitTestVisible = true;
|
||||
@@ -71,7 +78,8 @@ namespace Ink_Canvas {
|
||||
isStopInkReplay = true;
|
||||
});
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
isFloatingBarChangingHideMode = true;
|
||||
isFloatingBarFolded = true;
|
||||
if (currentMode != 0) CloseWhiteboardImmediately();
|
||||
@@ -84,7 +92,8 @@ namespace Ink_Canvas {
|
||||
|
||||
await Task.Delay(300);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
|
||||
@@ -97,12 +106,16 @@ namespace Ink_Canvas {
|
||||
isFloatingBarChangingHideMode = false;
|
||||
}
|
||||
|
||||
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
private async void LeftUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Settings.Appearance.IsShowQuickPanel)
|
||||
{
|
||||
HideRightQuickPanel();
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
var marginAnimation = new ThicknessAnimation {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
From = new Thickness(-50, 0, 0, -150),
|
||||
To = new Thickness(-1, 0, 0, -150)
|
||||
@@ -112,21 +125,27 @@ namespace Ink_Canvas {
|
||||
});
|
||||
await Task.Delay(100);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftUnFoldButtonQuickPanel.Margin = new Thickness(-1, 0, 0, -150);
|
||||
});
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
UnFoldFloatingBar_MouseUp(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private async void RightUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (Settings.Appearance.IsShowQuickPanel) {
|
||||
private async void RightUnFoldButtonDisplayQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (Settings.Appearance.IsShowQuickPanel)
|
||||
{
|
||||
HideLeftQuickPanel();
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Visible;
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
var marginAnimation = new ThicknessAnimation {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
From = new Thickness(0, 0, -50, -150),
|
||||
To = new Thickness(0, 0, -1, -150)
|
||||
@@ -136,19 +155,25 @@ namespace Ink_Canvas {
|
||||
});
|
||||
await Task.Delay(100);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
RightUnFoldButtonQuickPanel.Margin = new Thickness(0, 0, -1, -150);
|
||||
});
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
UnFoldFloatingBar_MouseUp(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private async void HideLeftQuickPanel() {
|
||||
if (LeftUnFoldButtonQuickPanel.Visibility == Visibility.Visible) {
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
var marginAnimation = new ThicknessAnimation {
|
||||
private async void HideLeftQuickPanel()
|
||||
{
|
||||
if (LeftUnFoldButtonQuickPanel.Visibility == Visibility.Visible)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
From = new Thickness(-1, 0, 0, -150),
|
||||
To = new Thickness(-50, 0, 0, -150)
|
||||
@@ -158,17 +183,22 @@ namespace Ink_Canvas {
|
||||
});
|
||||
await Task.Delay(100);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftUnFoldButtonQuickPanel.Margin = new Thickness(0, 0, -50, -150);
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void HideRightQuickPanel() {
|
||||
if (RightUnFoldButtonQuickPanel.Visibility == Visibility.Visible) {
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
var marginAnimation = new ThicknessAnimation {
|
||||
private async void HideRightQuickPanel()
|
||||
{
|
||||
if (RightUnFoldButtonQuickPanel.Visibility == Visibility.Visible)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
From = new Thickness(0, 0, -1, -150),
|
||||
To = new Thickness(0, 0, -50, -150)
|
||||
@@ -178,25 +208,29 @@ namespace Ink_Canvas {
|
||||
});
|
||||
await Task.Delay(100);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
RightUnFoldButtonQuickPanel.Margin = new Thickness(0, 0, -50, -150);
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void HideQuickPanel_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void HideQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
HideLeftQuickPanel();
|
||||
HideRightQuickPanel();
|
||||
}
|
||||
|
||||
public async void UnFoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
public async void UnFoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
await UnFoldFloatingBar(sender);
|
||||
}
|
||||
|
||||
public async Task UnFoldFloatingBar(object sender)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
@@ -208,21 +242,23 @@ namespace Ink_Canvas {
|
||||
|
||||
if (isFloatingBarChangingHideMode) return;
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
isFloatingBarChangingHideMode = true;
|
||||
isFloatingBarFolded = false;
|
||||
});
|
||||
|
||||
await Task.Delay(0);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
// 根据设置决定是否自动切换至批注模式
|
||||
if (Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode && currentMode == 0)
|
||||
{
|
||||
// 切换至批注模式
|
||||
PenIcon_Click(null, null);
|
||||
}
|
||||
|
||||
|
||||
if (StackPanelPPTControls.Visibility == Visibility.Visible)
|
||||
{
|
||||
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
|
||||
@@ -245,16 +281,19 @@ namespace Ink_Canvas {
|
||||
|
||||
private async void SidePannelMarginAnimation(int MarginFromEdge, bool isNoAnimation = false) // Possible value: -50, -10
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (MarginFromEdge == -10) LeftSidePanel.Visibility = Visibility.Visible;
|
||||
|
||||
var LeftSidePanelmarginAnimation = new ThicknessAnimation {
|
||||
var LeftSidePanelmarginAnimation = new ThicknessAnimation
|
||||
{
|
||||
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 {
|
||||
var RightSidePanelmarginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = isNoAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromSeconds(0.175),
|
||||
From = RightSidePanel.Margin,
|
||||
To = new Thickness(0, 0, MarginFromEdge, -150)
|
||||
@@ -266,7 +305,8 @@ namespace Ink_Canvas {
|
||||
|
||||
await Task.Delay(600);
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
LeftSidePanel.Margin = new Thickness(MarginFromEdge, 0, 0, -150);
|
||||
RightSidePanel.Margin = new Thickness(0, 0, MarginFromEdge, -150);
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using IWshRuntimeLibrary;
|
||||
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 {
|
||||
public static bool StartAutomaticallyCreate(string exeName) {
|
||||
try {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static bool StartAutomaticallyCreate(string exeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shell = new WshShell();
|
||||
var shortcut = (IWshShortcut)shell.CreateShortcut(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName + ".lnk");
|
||||
@@ -30,8 +34,10 @@ namespace Ink_Canvas {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool StartAutomaticallyDel(string exeName) {
|
||||
try {
|
||||
public static bool StartAutomaticallyDel(string exeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
||||
".lnk");
|
||||
return true;
|
||||
|
||||
@@ -1,50 +1,55 @@
|
||||
using System;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Win32;
|
||||
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 {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private Color FloatBarForegroundColor = Color.FromRgb(102, 102, 102);
|
||||
|
||||
private void SetTheme(string theme) {
|
||||
if (theme == "Light") {
|
||||
private void SetTheme(string theme)
|
||||
{
|
||||
if (theme == "Light")
|
||||
{
|
||||
var rd1 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/Styles/Light.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Light);
|
||||
|
||||
FloatBarForegroundColor = (Color)Application.Current.FindResource("FloatBarForegroundColor");
|
||||
}
|
||||
else if (theme == "Dark") {
|
||||
else if (theme == "Dark")
|
||||
{
|
||||
var rd1 = new ResourceDictionary { Source = new Uri("Resources/Styles/Dark.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd1);
|
||||
|
||||
var rd2 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/DrawShapeImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd2);
|
||||
|
||||
var rd3 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/SeewoImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd3);
|
||||
|
||||
var rd4 = new ResourceDictionary
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
{ Source = new Uri("Resources/IconImageDictionary.xaml", UriKind.Relative) };
|
||||
Application.Current.Resources.MergedDictionaries.Add(rd4);
|
||||
|
||||
ThemeManager.SetRequestedTheme(window, ElementTheme.Dark);
|
||||
@@ -53,8 +58,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e) {
|
||||
switch (Settings.Appearance.Theme) {
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
switch (Settings.Appearance.Theme)
|
||||
{
|
||||
case 0:
|
||||
SetTheme("Light");
|
||||
break;
|
||||
@@ -68,9 +75,11 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsSystemThemeLight() {
|
||||
private bool IsSystemThemeLight()
|
||||
{
|
||||
var light = false;
|
||||
try {
|
||||
try
|
||||
{
|
||||
var registryKey = Registry.CurrentUser;
|
||||
var themeKey =
|
||||
registryKey.OpenSubKey("software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private StrokeCollection[] strokeCollections = new StrokeCollection[101];
|
||||
private bool[] whiteboadLastModeIsRedo = new bool[101];
|
||||
private StrokeCollection lastTouchDownStrokeCollection = new StrokeCollection();
|
||||
@@ -23,17 +21,21 @@ namespace Ink_Canvas {
|
||||
private TimeMachineHistory[][] TimeMachineHistories = new TimeMachineHistory[101][]; //最多99页,0用来存储非白板时的墨迹以便还原
|
||||
|
||||
// 保存每页白板图片信息
|
||||
private void SaveStrokes(bool isBackupMain = false) {
|
||||
private void SaveStrokes(bool isBackupMain = false)
|
||||
{
|
||||
// 确保画布上的所有UI元素都被保存到时间机器历史记录中
|
||||
var currentHistory = timeMachine.ExportTimeMachineHistory();
|
||||
var elementsInHistory = new HashSet<UIElement>();
|
||||
|
||||
// 收集已经在历史记录中的元素
|
||||
if (currentHistory != null) {
|
||||
foreach (var h in currentHistory) {
|
||||
if (currentHistory != null)
|
||||
{
|
||||
foreach (var h in currentHistory)
|
||||
{
|
||||
if (h.CommitType == TimeMachineHistoryType.ElementInsert &&
|
||||
h.InsertedElement != null &&
|
||||
!h.StrokeHasBeenCleared) {
|
||||
!h.StrokeHasBeenCleared)
|
||||
{
|
||||
elementsInHistory.Add(h.InsertedElement);
|
||||
}
|
||||
}
|
||||
@@ -41,26 +43,34 @@ namespace Ink_Canvas {
|
||||
|
||||
// 检查画布上的所有UI元素,确保它们都在历史记录中
|
||||
var missingElements = 0;
|
||||
foreach (UIElement child in inkCanvas.Children) {
|
||||
if (child is Image || child is MediaElement) {
|
||||
if (!elementsInHistory.Contains(child)) {
|
||||
foreach (UIElement child in inkCanvas.Children)
|
||||
{
|
||||
if (child is Image || child is MediaElement)
|
||||
{
|
||||
if (!elementsInHistory.Contains(child))
|
||||
{
|
||||
timeMachine.CommitElementInsertHistory(child);
|
||||
missingElements++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 确保画布上的所有墨迹都被保存
|
||||
if (inkCanvas.Strokes.Count > 0) {
|
||||
if (inkCanvas.Strokes.Count > 0)
|
||||
{
|
||||
// 检查是否有墨迹没有在时间机器历史记录中
|
||||
var strokesInHistory = new HashSet<Stroke>();
|
||||
if (currentHistory != null) {
|
||||
foreach (var h in currentHistory) {
|
||||
if (currentHistory != null)
|
||||
{
|
||||
foreach (var h in currentHistory)
|
||||
{
|
||||
if (h.CommitType == TimeMachineHistoryType.UserInput &&
|
||||
h.CurrentStroke != null &&
|
||||
!h.StrokeHasBeenCleared) {
|
||||
foreach (Stroke stroke in h.CurrentStroke) {
|
||||
!h.StrokeHasBeenCleared)
|
||||
{
|
||||
foreach (Stroke stroke in h.CurrentStroke)
|
||||
{
|
||||
strokesInHistory.Add(stroke);
|
||||
}
|
||||
}
|
||||
@@ -69,24 +79,30 @@ namespace Ink_Canvas {
|
||||
|
||||
// 收集没有在历史记录中的墨迹
|
||||
var missingStrokes = new StrokeCollection();
|
||||
foreach (Stroke stroke in inkCanvas.Strokes) {
|
||||
if (!strokesInHistory.Contains(stroke)) {
|
||||
foreach (Stroke stroke in inkCanvas.Strokes)
|
||||
{
|
||||
if (!strokesInHistory.Contains(stroke))
|
||||
{
|
||||
missingStrokes.Add(stroke);
|
||||
}
|
||||
}
|
||||
|
||||
if (missingStrokes.Count > 0) {
|
||||
if (missingStrokes.Count > 0)
|
||||
{
|
||||
timeMachine.CommitStrokeUserInputHistory(missingStrokes);
|
||||
}
|
||||
}
|
||||
|
||||
if (isBackupMain) {
|
||||
if (isBackupMain)
|
||||
{
|
||||
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
|
||||
TimeMachineHistories[0] = timeMachineHistory;
|
||||
timeMachine.ClearStrokeHistory();
|
||||
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeMachineHistory = timeMachine.ExportTimeMachineHistory();
|
||||
TimeMachineHistories[CurrentWhiteboardIndex] = timeMachineHistory;
|
||||
timeMachine.ClearStrokeHistory();
|
||||
@@ -95,7 +111,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearStrokes(bool isErasedByCode) {
|
||||
private void ClearStrokes(bool isErasedByCode)
|
||||
{
|
||||
_currentCommitType = CommitReason.ClearingCanvas;
|
||||
if (isErasedByCode) _currentCommitType = CommitReason.CodeInput;
|
||||
|
||||
@@ -110,8 +127,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 恢复每页白板图片信息
|
||||
private void RestoreStrokes(bool isBackupMain = false) {
|
||||
try {
|
||||
private void RestoreStrokes(bool isBackupMain = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetIndex = isBackupMain ? 0 : CurrentWhiteboardIndex;
|
||||
|
||||
// 先清空当前画布的墨迹
|
||||
@@ -122,35 +141,46 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Children.Clear();
|
||||
|
||||
// 如果历史记录为空,直接返回(新页面或空页面)
|
||||
if (TimeMachineHistories[targetIndex] == null) {
|
||||
if (TimeMachineHistories[targetIndex] == null)
|
||||
{
|
||||
timeMachine.ClearStrokeHistory();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBackupMain) {
|
||||
if (isBackupMain)
|
||||
{
|
||||
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
|
||||
foreach (var item in TimeMachineHistories[0]) ApplyHistoryToCanvas(item);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
|
||||
// 通过时间机器历史恢复所有内容(墨迹和图片)
|
||||
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex]) ApplyHistoryToCanvas(item);
|
||||
}
|
||||
|
||||
// 确保选中状态被清除,因为我们切换了页面
|
||||
if (selectedUIElement != null) {
|
||||
if (selectedUIElement != null)
|
||||
{
|
||||
DeselectUIElement();
|
||||
}
|
||||
}
|
||||
catch {
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private async void BtnWhiteBoardPageIndex_Click(object sender, EventArgs e) {
|
||||
if (sender == BtnLeftPageListWB) {
|
||||
if (BoardBorderLeftPageListView.Visibility == Visibility.Visible) {
|
||||
private async void BtnWhiteBoardPageIndex_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == BtnLeftPageListWB)
|
||||
{
|
||||
if (BoardBorderLeftPageListView.Visibility == Visibility.Visible)
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
|
||||
RefreshBlackBoardSidePageListView();
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderLeftPageListView);
|
||||
@@ -159,11 +189,15 @@ namespace Ink_Canvas {
|
||||
(ListViewItem)BlackBoardLeftSidePageListView.ItemContainerGenerator.ContainerFromIndex(
|
||||
CurrentWhiteboardIndex - 1), BlackBoardLeftSidePageListScrollViewer);
|
||||
}
|
||||
} else if (sender == BtnRightPageListWB)
|
||||
}
|
||||
else if (sender == BtnRightPageListWB)
|
||||
{
|
||||
if (BoardBorderRightPageListView.Visibility == Visibility.Visible) {
|
||||
if (BoardBorderRightPageListView.Visibility == Visibility.Visible)
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
|
||||
RefreshBlackBoardSidePageListView();
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderRightPageListView);
|
||||
@@ -176,7 +210,8 @@ namespace Ink_Canvas {
|
||||
|
||||
}
|
||||
|
||||
private void BtnWhiteBoardSwitchPrevious_Click(object sender, EventArgs e) {
|
||||
private void BtnWhiteBoardSwitchPrevious_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrentWhiteboardIndex <= 1) return;
|
||||
|
||||
// 取消任何UI元素的选择
|
||||
@@ -192,12 +227,14 @@ namespace Ink_Canvas {
|
||||
UpdateIndexInfoDisplay();
|
||||
}
|
||||
|
||||
private void BtnWhiteBoardSwitchNext_Click(object sender, EventArgs e) {
|
||||
private void BtnWhiteBoardSwitchNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
Trace.WriteLine("113223234");
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
|
||||
if (CurrentWhiteboardIndex >= WhiteboardTotalCount) {
|
||||
if (CurrentWhiteboardIndex >= WhiteboardTotalCount)
|
||||
{
|
||||
// 在最后一页时,点击“新页面”按钮直接新增一页
|
||||
BtnWhiteBoardAdd_Click(sender, e);
|
||||
return;
|
||||
@@ -216,7 +253,8 @@ namespace Ink_Canvas {
|
||||
UpdateIndexInfoDisplay();
|
||||
}
|
||||
|
||||
private void BtnWhiteBoardAdd_Click(object sender, EventArgs e) {
|
||||
private void BtnWhiteBoardAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (WhiteboardTotalCount >= 99) return;
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
|
||||
@@ -244,12 +282,14 @@ namespace Ink_Canvas {
|
||||
|
||||
if (WhiteboardTotalCount >= 99) BtnWhiteBoardAdd.IsEnabled = false;
|
||||
|
||||
if (BlackBoardLeftSidePageListView.Visibility == Visibility.Visible) {
|
||||
if (BlackBoardLeftSidePageListView.Visibility == Visibility.Visible)
|
||||
{
|
||||
RefreshBlackBoardSidePageListView();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnWhiteBoardDelete_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnWhiteBoardDelete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ClearStrokes(true);
|
||||
|
||||
if (CurrentWhiteboardIndex != WhiteboardTotalCount)
|
||||
@@ -267,7 +307,8 @@ namespace Ink_Canvas {
|
||||
if (WhiteboardTotalCount < 99) BtnWhiteBoardAdd.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void UpdateIndexInfoDisplay() {
|
||||
private void UpdateIndexInfoDisplay()
|
||||
{
|
||||
TextBlockWhiteBoardIndexInfo.Text =
|
||||
$"{CurrentWhiteboardIndex}/{WhiteboardTotalCount}";
|
||||
|
||||
@@ -289,13 +330,16 @@ namespace Ink_Canvas {
|
||||
|
||||
BtnWhiteBoardSwitchPrevious.IsEnabled = true;
|
||||
|
||||
if (CurrentWhiteboardIndex == 1) {
|
||||
if (CurrentWhiteboardIndex == 1)
|
||||
{
|
||||
BtnWhiteBoardSwitchPrevious.IsEnabled = false;
|
||||
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
|
||||
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
|
||||
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(127, 24, 24, 27));
|
||||
BtnRightWhiteBoardSwitchPreviousLabel.Opacity = 0.5;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnLeftWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
|
||||
BtnLeftWhiteBoardSwitchPreviousLabel.Opacity = 1;
|
||||
BtnRightWhiteBoardSwitchPreviousGeometry.Brush = new SolidColorBrush(Color.FromArgb(255, 24, 24, 27));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -6,11 +7,13 @@ 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 {
|
||||
private void BoardChangeBackgroundColorBtn_MouseUp(object sender, RoutedEventArgs e) {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private void BoardChangeBackgroundColorBtn_MouseUp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
// 创建背景选项面板(如果不存在)
|
||||
@@ -50,66 +53,68 @@ namespace Ink_Canvas {
|
||||
// 原有的背景切换代码
|
||||
Settings.Canvas.UsingWhiteboard = !Settings.Canvas.UsingWhiteboard;
|
||||
SaveSettingsToFile();
|
||||
if (Settings.Canvas.UsingWhiteboard) {
|
||||
if (Settings.Canvas.UsingWhiteboard)
|
||||
{
|
||||
if (inkColor == 5) lastBoardInkColor = 0;
|
||||
ICCWaterMarkDark.Visibility = Visibility.Visible;
|
||||
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 设置为白板默认背景色
|
||||
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
|
||||
|
||||
|
||||
if (currentMode == 1) // 白板模式
|
||||
{
|
||||
// 设置背景为默认白板背景色
|
||||
GridBackgroundCover.Background = new SolidColorBrush(defaultWhiteboardColor);
|
||||
|
||||
|
||||
// 更新RGB滑块的值为默认白板背景色
|
||||
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
|
||||
{
|
||||
UpdateRGBSliders(defaultWhiteboardColor);
|
||||
}
|
||||
|
||||
|
||||
// 更新自定义背景色为默认白板背景色
|
||||
CustomBackgroundColor = defaultWhiteboardColor;
|
||||
|
||||
|
||||
// 保存到设置
|
||||
string colorHex = $"#{defaultWhiteboardColor.R:X2}{defaultWhiteboardColor.G:X2}{defaultWhiteboardColor.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
// 设置墨迹颜色为黑色
|
||||
CheckLastColor(0);
|
||||
forceEraser = false;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (inkColor == 0) lastBoardInkColor = 5;
|
||||
ICCWaterMarkWhite.Visibility = Visibility.Visible;
|
||||
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 设置为黑板默认背景色
|
||||
Color defaultBlackboardColor = Color.FromRgb(22, 41, 36);
|
||||
|
||||
|
||||
if (currentMode == 1) // 黑板模式
|
||||
{
|
||||
// 设置背景为默认黑板背景色
|
||||
GridBackgroundCover.Background = new SolidColorBrush(defaultBlackboardColor);
|
||||
|
||||
|
||||
// 更新RGB滑块的值为默认黑板背景色
|
||||
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
|
||||
{
|
||||
UpdateRGBSliders(defaultBlackboardColor);
|
||||
}
|
||||
|
||||
|
||||
// 更新自定义背景色为默认黑板背景色
|
||||
CustomBackgroundColor = defaultBlackboardColor;
|
||||
|
||||
|
||||
// 保存到设置
|
||||
string colorHex = $"#{defaultBlackboardColor.R:X2}{defaultBlackboardColor.G:X2}{defaultBlackboardColor.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
// 设置墨迹颜色为白色
|
||||
CheckLastColor(5);
|
||||
forceEraser = false;
|
||||
@@ -123,7 +128,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
// 确保加载自定义背景色
|
||||
LoadCustomBackgroundColor();
|
||||
|
||||
|
||||
// 创建一个类似于PenPalette的面板
|
||||
BackgroundPalette = new Border
|
||||
{
|
||||
@@ -137,7 +142,7 @@ namespace Ink_Canvas {
|
||||
Width = 300,
|
||||
MaxHeight = 400
|
||||
};
|
||||
|
||||
|
||||
// 确保面板显示在顶层
|
||||
Panel.SetZIndex(BackgroundPalette, 1000);
|
||||
|
||||
@@ -201,7 +206,7 @@ namespace Ink_Canvas {
|
||||
contentPanel.Children.Add(modeTitle);
|
||||
|
||||
var modePanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };
|
||||
|
||||
|
||||
// 白板按钮
|
||||
var whiteboardButton = new Border
|
||||
{
|
||||
@@ -219,41 +224,42 @@ namespace Ink_Canvas {
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
whiteboardButton.Child = whiteboardText;
|
||||
whiteboardButton.MouseUp += (s, args) => {
|
||||
whiteboardButton.MouseUp += (s, args) =>
|
||||
{
|
||||
Settings.Canvas.UsingWhiteboard = true;
|
||||
SaveSettingsToFile();
|
||||
ICCWaterMarkDark.Visibility = Visibility.Visible;
|
||||
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 设置为白板默认背景色
|
||||
Color defaultWhiteboardColor = Color.FromRgb(234, 235, 237);
|
||||
|
||||
|
||||
if (currentMode == 1) // 白板模式
|
||||
{
|
||||
// 设置背景为默认白板背景色
|
||||
GridBackgroundCover.Background = new SolidColorBrush(defaultWhiteboardColor);
|
||||
|
||||
|
||||
// 更新RGB滑块的值为默认白板背景色
|
||||
UpdateRGBSliders(defaultWhiteboardColor);
|
||||
|
||||
|
||||
// 更新自定义背景色为默认白板背景色
|
||||
CustomBackgroundColor = defaultWhiteboardColor;
|
||||
|
||||
|
||||
// 保存到设置
|
||||
string colorHex = $"#{defaultWhiteboardColor.R:X2}{defaultWhiteboardColor.G:X2}{defaultWhiteboardColor.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
// 设置墨迹颜色为黑色
|
||||
CheckLastColor(0);
|
||||
forceEraser = false;
|
||||
|
||||
|
||||
CheckColorTheme(true);
|
||||
UpdateBackgroundButtonsState();
|
||||
};
|
||||
modePanel.Children.Add(whiteboardButton);
|
||||
|
||||
|
||||
// 黑板按钮
|
||||
var blackboardButton = new Border
|
||||
{
|
||||
@@ -270,264 +276,269 @@ namespace Ink_Canvas {
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
blackboardButton.Child = blackboardText;
|
||||
blackboardButton.MouseUp += (s, args) => {
|
||||
blackboardButton.MouseUp += (s, args) =>
|
||||
{
|
||||
Settings.Canvas.UsingWhiteboard = false;
|
||||
SaveSettingsToFile();
|
||||
ICCWaterMarkWhite.Visibility = Visibility.Visible;
|
||||
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 设置为黑板默认背景色
|
||||
Color defaultBlackboardColor = Color.FromRgb(22, 41, 36);
|
||||
|
||||
|
||||
if (currentMode == 1) // 黑板模式
|
||||
{
|
||||
// 设置背景为默认黑板背景色
|
||||
GridBackgroundCover.Background = new SolidColorBrush(defaultBlackboardColor);
|
||||
|
||||
|
||||
// 更新RGB滑块的值为默认黑板背景色
|
||||
UpdateRGBSliders(defaultBlackboardColor);
|
||||
|
||||
|
||||
// 更新自定义背景色为默认黑板背景色
|
||||
CustomBackgroundColor = defaultBlackboardColor;
|
||||
|
||||
|
||||
// 保存到设置
|
||||
string colorHex = $"#{defaultBlackboardColor.R:X2}{defaultBlackboardColor.G:X2}{defaultBlackboardColor.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
// 设置墨迹颜色为白色
|
||||
CheckLastColor(5);
|
||||
forceEraser = false;
|
||||
|
||||
|
||||
CheckColorTheme(true);
|
||||
UpdateBackgroundButtonsState();
|
||||
};
|
||||
modePanel.Children.Add(blackboardButton);
|
||||
|
||||
contentPanel.Children.Add(modePanel);
|
||||
|
||||
// 添加一条分隔线
|
||||
var separator = new Border
|
||||
{
|
||||
Height = 1,
|
||||
Background = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
|
||||
Margin = new Thickness(0, 12, 0, 12)
|
||||
};
|
||||
contentPanel.Children.Add(separator);
|
||||
|
||||
// 添加RGB颜色选择器部分
|
||||
var colorTitle = new TextBlock
|
||||
{
|
||||
Text = "背景颜色",
|
||||
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
|
||||
FontSize = 10,
|
||||
FontWeight = FontWeights.Bold,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Margin = new Thickness(0, 4, 0, 8)
|
||||
};
|
||||
contentPanel.Children.Add(colorTitle);
|
||||
|
||||
// 创建颜色预览
|
||||
Border colorPreview = new Border
|
||||
{
|
||||
Width = 100,
|
||||
Height = 40,
|
||||
BorderThickness = new Thickness(1),
|
||||
BorderBrush = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
|
||||
Background = new SolidColorBrush(Colors.White),
|
||||
CornerRadius = new CornerRadius(4),
|
||||
Margin = new Thickness(0, 0, 0, 10),
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
};
|
||||
contentPanel.Children.Add(colorPreview);
|
||||
|
||||
// 获取当前背景颜色
|
||||
Color currentBackgroundColor;
|
||||
if (currentMode == 1) // 白板或黑板模式
|
||||
{
|
||||
if (GridBackgroundCover.Background is SolidColorBrush brush)
|
||||
{
|
||||
currentBackgroundColor = brush.Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认颜色
|
||||
currentBackgroundColor = Settings.Canvas.UsingWhiteboard ?
|
||||
Color.FromRgb(234, 235, 237) : // 白板默认颜色
|
||||
Color.FromRgb(22, 41, 36); // 黑板默认颜色
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认白色
|
||||
currentBackgroundColor = Colors.White;
|
||||
}
|
||||
|
||||
// 更新颜色预览
|
||||
colorPreview.Background = new SolidColorBrush(currentBackgroundColor);
|
||||
|
||||
// 先创建所有滑块控件
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.R,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var rValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.R.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.G,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var gValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.G.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.B,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var bValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.B.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 现在添加事件处理程序
|
||||
rSlider.ValueChanged += (s, e) => {
|
||||
int value = (int)e.NewValue;
|
||||
rValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
gSlider.ValueChanged += (s, e) => {
|
||||
int value = (int)e.NewValue;
|
||||
gValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
bSlider.ValueChanged += (s, e) => {
|
||||
int value = (int)e.NewValue;
|
||||
bValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
// 添加控件到面板
|
||||
rPanel.Children.Add(rLabel);
|
||||
rPanel.Children.Add(rSlider);
|
||||
rPanel.Children.Add(rValueText);
|
||||
contentPanel.Children.Add(rPanel);
|
||||
|
||||
gPanel.Children.Add(gLabel);
|
||||
gPanel.Children.Add(gSlider);
|
||||
gPanel.Children.Add(gValueText);
|
||||
contentPanel.Children.Add(gPanel);
|
||||
|
||||
bPanel.Children.Add(bLabel);
|
||||
bPanel.Children.Add(bSlider);
|
||||
bPanel.Children.Add(bValueText);
|
||||
contentPanel.Children.Add(bPanel);
|
||||
|
||||
// 应用按钮
|
||||
var applyButton = new Button
|
||||
{
|
||||
Content = "应用颜色",
|
||||
Margin = new Thickness(0, 10, 0, 0),
|
||||
Padding = new Thickness(10, 5, 10, 5),
|
||||
Background = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
|
||||
Foreground = new SolidColorBrush(Colors.White),
|
||||
BorderThickness = new Thickness(0),
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
};
|
||||
|
||||
applyButton.Click += (s, e) => {
|
||||
Color selectedColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
(byte)gSlider.Value,
|
||||
(byte)bSlider.Value
|
||||
);
|
||||
ApplyCustomBackgroundColor(selectedColor);
|
||||
};
|
||||
|
||||
contentPanel.Children.Add(applyButton);
|
||||
|
||||
// 添加一条分隔线
|
||||
var separator = new Border
|
||||
{
|
||||
Height = 1,
|
||||
Background = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
|
||||
Margin = new Thickness(0, 12, 0, 12)
|
||||
};
|
||||
contentPanel.Children.Add(separator);
|
||||
|
||||
// 添加RGB颜色选择器部分
|
||||
var colorTitle = new TextBlock
|
||||
{
|
||||
Text = "背景颜色",
|
||||
Foreground = new SolidColorBrush(Color.FromRgb(0x17, 0x25, 0x54)),
|
||||
FontSize = 10,
|
||||
FontWeight = FontWeights.Bold,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
Margin = new Thickness(0, 4, 0, 8)
|
||||
};
|
||||
contentPanel.Children.Add(colorTitle);
|
||||
|
||||
// 创建颜色预览
|
||||
Border colorPreview = new Border
|
||||
{
|
||||
Width = 100,
|
||||
Height = 40,
|
||||
BorderThickness = new Thickness(1),
|
||||
BorderBrush = new SolidColorBrush(Color.FromRgb(0xd4, 0xd4, 0xd8)),
|
||||
Background = new SolidColorBrush(Colors.White),
|
||||
CornerRadius = new CornerRadius(4),
|
||||
Margin = new Thickness(0, 0, 0, 10),
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
};
|
||||
contentPanel.Children.Add(colorPreview);
|
||||
|
||||
// 获取当前背景颜色
|
||||
Color currentBackgroundColor;
|
||||
if (currentMode == 1) // 白板或黑板模式
|
||||
{
|
||||
if (GridBackgroundCover.Background is SolidColorBrush brush)
|
||||
{
|
||||
currentBackgroundColor = brush.Color;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认颜色
|
||||
currentBackgroundColor = Settings.Canvas.UsingWhiteboard ?
|
||||
Color.FromRgb(234, 235, 237) : // 白板默认颜色
|
||||
Color.FromRgb(22, 41, 36); // 黑板默认颜色
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认白色
|
||||
currentBackgroundColor = Colors.White;
|
||||
}
|
||||
|
||||
// 更新颜色预览
|
||||
colorPreview.Background = new SolidColorBrush(currentBackgroundColor);
|
||||
|
||||
// 先创建所有滑块控件
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.R,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var rValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.R.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.G,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var gValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.G.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 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 Slider
|
||||
{
|
||||
Minimum = 0,
|
||||
Maximum = 255,
|
||||
Value = currentBackgroundColor.B,
|
||||
Width = 150,
|
||||
Margin = new Thickness(5, 0, 5, 0),
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
var bValueText = new TextBlock
|
||||
{
|
||||
Text = currentBackgroundColor.B.ToString(),
|
||||
Width = 30,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextAlignment = TextAlignment.Right
|
||||
};
|
||||
|
||||
// 现在添加事件处理程序
|
||||
rSlider.ValueChanged += (s, e) =>
|
||||
{
|
||||
int value = (int)e.NewValue;
|
||||
rValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
gSlider.ValueChanged += (s, e) =>
|
||||
{
|
||||
int value = (int)e.NewValue;
|
||||
gValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
bSlider.ValueChanged += (s, e) =>
|
||||
{
|
||||
int value = (int)e.NewValue;
|
||||
bValueText.Text = value.ToString();
|
||||
UpdateColorPreview(colorPreview, rSlider, gSlider, bSlider);
|
||||
};
|
||||
|
||||
// 添加控件到面板
|
||||
rPanel.Children.Add(rLabel);
|
||||
rPanel.Children.Add(rSlider);
|
||||
rPanel.Children.Add(rValueText);
|
||||
contentPanel.Children.Add(rPanel);
|
||||
|
||||
gPanel.Children.Add(gLabel);
|
||||
gPanel.Children.Add(gSlider);
|
||||
gPanel.Children.Add(gValueText);
|
||||
contentPanel.Children.Add(gPanel);
|
||||
|
||||
bPanel.Children.Add(bLabel);
|
||||
bPanel.Children.Add(bSlider);
|
||||
bPanel.Children.Add(bValueText);
|
||||
contentPanel.Children.Add(bPanel);
|
||||
|
||||
// 应用按钮
|
||||
var applyButton = new Button
|
||||
{
|
||||
Content = "应用颜色",
|
||||
Margin = new Thickness(0, 10, 0, 0),
|
||||
Padding = new Thickness(10, 5, 10, 5),
|
||||
Background = new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)),
|
||||
Foreground = new SolidColorBrush(Colors.White),
|
||||
BorderThickness = new Thickness(0),
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
};
|
||||
|
||||
applyButton.Click += (s, e) =>
|
||||
{
|
||||
Color selectedColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
(byte)gSlider.Value,
|
||||
(byte)bSlider.Value
|
||||
);
|
||||
ApplyCustomBackgroundColor(selectedColor);
|
||||
};
|
||||
|
||||
contentPanel.Children.Add(applyButton);
|
||||
|
||||
stackPanel.Children.Add(contentPanel);
|
||||
|
||||
// 将面板添加到父容器
|
||||
BackgroundPalette.Child = stackPanel;
|
||||
|
||||
// 获取主窗口中的根网格,确保面板添加到顶层
|
||||
Grid mainGrid = FindName("Main_Grid") as Grid;
|
||||
if (mainGrid != null)
|
||||
{
|
||||
// 删除可能已存在的BackgroundPalette
|
||||
foreach (UIElement element in mainGrid.Children)
|
||||
{
|
||||
if (element is Border border && border.Name == "BackgroundPalette")
|
||||
{
|
||||
mainGrid.Children.Remove(border);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 重新定位面板
|
||||
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
BackgroundPalette.VerticalAlignment = VerticalAlignment.Center;
|
||||
BackgroundPalette.Margin = new Thickness(0, 0, 0, 0);
|
||||
|
||||
// 添加到主网格
|
||||
mainGrid.Children.Add(BackgroundPalette);
|
||||
|
||||
// 设置面板位置
|
||||
var clickElement = FindName("BoardChangeBackgroundColorBtn") as FrameworkElement;
|
||||
if (clickElement != null)
|
||||
{
|
||||
Point position = clickElement.TranslatePoint(new Point(0, 0), mainGrid);
|
||||
BackgroundPalette.Margin = new Thickness(
|
||||
position.X - 150,
|
||||
position.Y + clickElement.ActualHeight + 5,
|
||||
0, 0);
|
||||
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
BackgroundPalette.VerticalAlignment = VerticalAlignment.Top;
|
||||
}
|
||||
}
|
||||
// 将面板添加到父容器
|
||||
BackgroundPalette.Child = stackPanel;
|
||||
|
||||
// 获取主窗口中的根网格,确保面板添加到顶层
|
||||
Grid mainGrid = FindName("Main_Grid") as Grid;
|
||||
if (mainGrid != null)
|
||||
{
|
||||
// 删除可能已存在的BackgroundPalette
|
||||
foreach (UIElement element in mainGrid.Children)
|
||||
{
|
||||
if (element is Border border && border.Name == "BackgroundPalette")
|
||||
{
|
||||
mainGrid.Children.Remove(border);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 重新定位面板
|
||||
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
BackgroundPalette.VerticalAlignment = VerticalAlignment.Center;
|
||||
BackgroundPalette.Margin = new Thickness(0, 0, 0, 0);
|
||||
|
||||
// 添加到主网格
|
||||
mainGrid.Children.Add(BackgroundPalette);
|
||||
|
||||
// 设置面板位置
|
||||
var clickElement = FindName("BoardChangeBackgroundColorBtn") as FrameworkElement;
|
||||
if (clickElement != null)
|
||||
{
|
||||
Point position = clickElement.TranslatePoint(new Point(0, 0), mainGrid);
|
||||
BackgroundPalette.Margin = new Thickness(
|
||||
position.X - 150,
|
||||
position.Y + clickElement.ActualHeight + 5,
|
||||
0, 0);
|
||||
BackgroundPalette.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
BackgroundPalette.VerticalAlignment = VerticalAlignment.Top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新背景按钮状态
|
||||
private void UpdateBackgroundButtonsState()
|
||||
{
|
||||
@@ -541,17 +552,17 @@ namespace Ink_Canvas {
|
||||
{
|
||||
var whiteboardButton = modePanel.Children[0] as Border;
|
||||
var blackboardButton = modePanel.Children[1] as Border;
|
||||
|
||||
|
||||
if (whiteboardButton != null && whiteboardButton.Child is TextBlock whiteboardText)
|
||||
{
|
||||
whiteboardButton.Background = Settings.Canvas.UsingWhiteboard ?
|
||||
new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) :
|
||||
whiteboardButton.Background = Settings.Canvas.UsingWhiteboard ?
|
||||
new SolidColorBrush(Color.FromRgb(0x25, 0x63, 0xeb)) :
|
||||
new SolidColorBrush(Colors.LightGray);
|
||||
whiteboardText.Foreground = Settings.Canvas.UsingWhiteboard ?
|
||||
new SolidColorBrush(Colors.White) :
|
||||
new SolidColorBrush(Colors.Black);
|
||||
}
|
||||
|
||||
|
||||
if (blackboardButton != null && blackboardButton.Child is TextBlock blackboardText)
|
||||
{
|
||||
blackboardButton.Background = !Settings.Canvas.UsingWhiteboard ?
|
||||
@@ -566,58 +577,58 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加成员变量保存背景面板引用
|
||||
private Border BackgroundPalette { get; set; }
|
||||
|
||||
// 添加成员变量保存当前自定义背景色
|
||||
private Color? CustomBackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新颜色预览框的颜色
|
||||
/// </summary>
|
||||
private void UpdateColorPreview(Border colorPreview, Slider rSlider, Slider gSlider, Slider bSlider)
|
||||
{
|
||||
Color previewColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
(byte)gSlider.Value,
|
||||
(byte)bSlider.Value
|
||||
);
|
||||
colorPreview.Background = new SolidColorBrush(previewColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用自定义背景颜色
|
||||
/// </summary>
|
||||
private void ApplyCustomBackgroundColor(Color color)
|
||||
{
|
||||
// 保存当前选择的颜色
|
||||
CustomBackgroundColor = color;
|
||||
|
||||
// 将颜色转换为十六进制字符串并保存到设置中
|
||||
string colorHex = $"#{color.R:X2}{color.G:X2}{color.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
|
||||
// 只在白板或黑板模式下应用自定义背景色
|
||||
if (currentMode == 1) // 白板或黑板模式
|
||||
{
|
||||
// 设置白板/黑板模式下的背景
|
||||
GridBackgroundCover.Background = new SolidColorBrush(color);
|
||||
}
|
||||
|
||||
// 保存设置
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 立即更新界面
|
||||
if (BackgroundPalette != null)
|
||||
{
|
||||
UpdateBackgroundButtonsState();
|
||||
UpdateRGBSliders(color); // 更新RGB滑块的值
|
||||
}
|
||||
|
||||
// 显示提示信息
|
||||
ShowNotification($"已应用自定义背景色: {colorHex}");
|
||||
}
|
||||
|
||||
// 添加成员变量保存背景面板引用
|
||||
private Border BackgroundPalette { get; set; }
|
||||
|
||||
// 添加成员变量保存当前自定义背景色
|
||||
private Color? CustomBackgroundColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新颜色预览框的颜色
|
||||
/// </summary>
|
||||
private void UpdateColorPreview(Border colorPreview, Slider rSlider, Slider gSlider, Slider bSlider)
|
||||
{
|
||||
Color previewColor = Color.FromRgb(
|
||||
(byte)rSlider.Value,
|
||||
(byte)gSlider.Value,
|
||||
(byte)bSlider.Value
|
||||
);
|
||||
colorPreview.Background = new SolidColorBrush(previewColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用自定义背景颜色
|
||||
/// </summary>
|
||||
private void ApplyCustomBackgroundColor(Color color)
|
||||
{
|
||||
// 保存当前选择的颜色
|
||||
CustomBackgroundColor = color;
|
||||
|
||||
// 将颜色转换为十六进制字符串并保存到设置中
|
||||
string colorHex = $"#{color.R:X2}{color.G:X2}{color.B:X2}";
|
||||
Settings.Canvas.CustomBackgroundColor = colorHex;
|
||||
|
||||
// 只在白板或黑板模式下应用自定义背景色
|
||||
if (currentMode == 1) // 白板或黑板模式
|
||||
{
|
||||
// 设置白板/黑板模式下的背景
|
||||
GridBackgroundCover.Background = new SolidColorBrush(color);
|
||||
}
|
||||
|
||||
// 保存设置
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 立即更新界面
|
||||
if (BackgroundPalette != null)
|
||||
{
|
||||
UpdateBackgroundButtonsState();
|
||||
UpdateRGBSliders(color); // 更新RGB滑块的值
|
||||
}
|
||||
|
||||
// 显示提示信息
|
||||
ShowNotification($"已应用自定义背景色: {colorHex}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从设置中加载自定义背景色
|
||||
@@ -635,7 +646,7 @@ namespace Ink_Canvas {
|
||||
byte r = Convert.ToByte(colorHex.Substring(1, 2), 16);
|
||||
byte g = Convert.ToByte(colorHex.Substring(3, 2), 16);
|
||||
byte b = Convert.ToByte(colorHex.Substring(5, 2), 16);
|
||||
|
||||
|
||||
// 保存到内存中
|
||||
CustomBackgroundColor = Color.FromRgb(r, g, b);
|
||||
}
|
||||
@@ -653,7 +664,7 @@ namespace Ink_Canvas {
|
||||
// 白板模式默认颜色
|
||||
CustomBackgroundColor = Color.FromRgb(234, 235, 237);
|
||||
}
|
||||
|
||||
|
||||
// 可以在这里记录日志
|
||||
Console.WriteLine($"解析自定义背景色失败: {ex.Message}");
|
||||
}
|
||||
@@ -672,13 +683,13 @@ namespace Ink_Canvas {
|
||||
CustomBackgroundColor = Color.FromRgb(234, 235, 237);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 只在白板或黑板模式下应用自定义背景色
|
||||
if (currentMode == 1 && CustomBackgroundColor.HasValue) // 白板或黑板模式
|
||||
{
|
||||
// 设置白板/黑板模式下的背景
|
||||
GridBackgroundCover.Background = new SolidColorBrush(CustomBackgroundColor.Value);
|
||||
|
||||
|
||||
// 更新RGB滑块的值(如果调色板已经创建)
|
||||
if (BackgroundPalette != null && BackgroundPalette.Visibility == Visibility.Visible)
|
||||
{
|
||||
@@ -687,7 +698,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void BoardLassoIcon_Click(object sender, RoutedEventArgs e) {
|
||||
private void BoardLassoIcon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
forceEraser = false;
|
||||
forcePointEraser = false;
|
||||
drawingShapeMode = 0;
|
||||
@@ -695,43 +707,48 @@ namespace Ink_Canvas {
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
private void BoardEraserIconByStrokes_Click(object sender, RoutedEventArgs e) {
|
||||
private void BoardEraserIconByStrokes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//if (BoardEraserByStrokes.Background.ToString() == "#FF679CF4") {
|
||||
// AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardDeleteIcon);
|
||||
//}
|
||||
//else {
|
||||
// 禁用高级橡皮擦系统
|
||||
DisableAdvancedEraserSystem();
|
||||
// 禁用高级橡皮擦系统
|
||||
DisableAdvancedEraserSystem();
|
||||
|
||||
forceEraser = true;
|
||||
forcePointEraser = false;
|
||||
forceEraser = true;
|
||||
forcePointEraser = false;
|
||||
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
|
||||
drawingShapeMode = 0;
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
|
||||
drawingShapeMode = 0;
|
||||
|
||||
// 修复:切换到线擦时,确保重置笔的状态
|
||||
penType = 0;
|
||||
drawingAttributes.IsHighlighter = false;
|
||||
drawingAttributes.StylusTip = StylusTip.Ellipse;
|
||||
// 修复:切换到线擦时,确保重置笔的状态
|
||||
penType = 0;
|
||||
drawingAttributes.IsHighlighter = false;
|
||||
drawingAttributes.StylusTip = StylusTip.Ellipse;
|
||||
|
||||
inkCanvas_EditingModeChanged(inkCanvas, null);
|
||||
CancelSingleFingerDragMode();
|
||||
inkCanvas_EditingModeChanged(inkCanvas, null);
|
||||
CancelSingleFingerDragMode();
|
||||
|
||||
HideSubPanels("eraserByStrokes");
|
||||
HideSubPanels("eraserByStrokes");
|
||||
//}
|
||||
}
|
||||
|
||||
private void BoardSymbolIconDelete_MouseUp(object sender, RoutedEventArgs e) {
|
||||
private void BoardSymbolIconDelete_MouseUp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PenIcon_Click(null, null);
|
||||
SymbolIconDelete_MouseUp(null, null);
|
||||
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages)
|
||||
{
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 保存非笔画元素(如图片)
|
||||
Debug.WriteLine("BoardSymbolIconDelete: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
@@ -749,11 +766,14 @@ namespace Ink_Canvas {
|
||||
if (Settings.Canvas.ClearCanvasAndClearTimeMachine == false) timeMachine.ClearStrokeHistory();
|
||||
|
||||
// 根据设置决定是否清空图片
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages) {
|
||||
if (Settings.Canvas.ClearCanvasAlsoClearImages)
|
||||
{
|
||||
// 如果设置为清空图片,则直接清空所有子元素
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Clearing all children including images");
|
||||
inkCanvas.Children.Clear();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 保存非笔画元素(如图片)
|
||||
Debug.WriteLine("BoardSymbolIconDeleteInkAndHistories: Preserving non-stroke elements (images)");
|
||||
var preservedElements = PreserveNonStrokeElements();
|
||||
@@ -765,12 +785,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void BoardLaunchEasiCamera_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BoardLaunchEasiCamera_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ImageBlackboard_MouseUp(null, null);
|
||||
SoftwareLauncher.LaunchEasiCamera("希沃视频展台");
|
||||
}
|
||||
|
||||
private void BoardLaunchDesmos_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BoardLaunchDesmos_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
HideSubPanelsImmediately();
|
||||
ImageBlackboard_MouseUp(null, null);
|
||||
Process.Start("https://www.desmos.com/calculator?lang=zh-CN");
|
||||
@@ -789,7 +811,7 @@ namespace Ink_Canvas {
|
||||
Slider rSlider = null;
|
||||
Slider gSlider = null;
|
||||
Slider bSlider = null;
|
||||
|
||||
|
||||
// 遍历面板查找RGB滑块
|
||||
foreach (var child in contentPanel.Children)
|
||||
{
|
||||
@@ -818,7 +840,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新滑块值
|
||||
if (rSlider != null && gSlider != null && bSlider != null)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -78,12 +78,12 @@ namespace Ink_Canvas
|
||||
|
||||
// 创建右键菜单
|
||||
var contextMenu = new ContextMenu();
|
||||
|
||||
|
||||
var pasteMenuItem = new MenuItem
|
||||
{
|
||||
Header = "粘贴图片"
|
||||
};
|
||||
|
||||
|
||||
pasteMenuItem.Click += async (s, e) => await PasteImageFromClipboard(position);
|
||||
contextMenu.Items.Add(pasteMenuItem);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -8,16 +9,20 @@ 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 {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private int inkColor = 1;
|
||||
|
||||
private void ColorSwitchCheck() {
|
||||
private void ColorSwitchCheck()
|
||||
{
|
||||
HideSubPanels("color");
|
||||
if (GridTransparencyFakeBackground.Background == Brushes.Transparent) {
|
||||
if (currentMode == 1) {
|
||||
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
|
||||
{
|
||||
if (currentMode == 1)
|
||||
{
|
||||
currentMode = 0;
|
||||
GridBackgroundCover.Visibility = Visibility.Collapsed;
|
||||
AnimationsHelper.HideWithSlideAndFade(BlackboardLeftSide);
|
||||
@@ -29,12 +34,15 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var strokes = inkCanvas.GetSelectedStrokes();
|
||||
if (strokes.Count != 0) {
|
||||
if (strokes.Count != 0)
|
||||
{
|
||||
foreach (var stroke in strokes)
|
||||
try {
|
||||
try
|
||||
{
|
||||
stroke.DrawingAttributes.Color = inkCanvas.DefaultDrawingAttributes.Color;
|
||||
}
|
||||
catch {
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -47,7 +55,8 @@ namespace Ink_Canvas {
|
||||
item.Value.Clear();
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
inkCanvas.IsManipulationEnabled = true;
|
||||
drawingShapeMode = 0;
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
@@ -63,14 +72,20 @@ namespace Ink_Canvas {
|
||||
private int lastDesktopInkColor = 1, lastBoardInkColor = 5;
|
||||
private int highlighterColor = 102;
|
||||
|
||||
private void CheckColorTheme(bool changeColorTheme = false) {
|
||||
private void CheckColorTheme(bool changeColorTheme = false)
|
||||
{
|
||||
if (changeColorTheme)
|
||||
if (currentMode != 0) {
|
||||
if (Settings.Canvas.UsingWhiteboard) {
|
||||
if (currentMode != 0)
|
||||
{
|
||||
if (Settings.Canvas.UsingWhiteboard)
|
||||
{
|
||||
// 检查是否有自定义背景色,如果有则使用自定义背景色
|
||||
if (CustomBackgroundColor.HasValue) {
|
||||
if (CustomBackgroundColor.HasValue)
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(CustomBackgroundColor.Value);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(Color.FromRgb(234, 235, 237));
|
||||
}
|
||||
WaterMarkTime.Foreground = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
@@ -78,11 +93,15 @@ namespace Ink_Canvas {
|
||||
BlackBoardWaterMark.Foreground = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
isUselightThemeColor = false;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// 黑板模式下,检查是否有自定义背景色
|
||||
if (CustomBackgroundColor.HasValue) {
|
||||
if (CustomBackgroundColor.HasValue)
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(CustomBackgroundColor.Value);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
}
|
||||
WaterMarkTime.Foreground = new SolidColorBrush(Color.FromRgb(234, 235, 237));
|
||||
@@ -92,26 +111,32 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMode == 0) {
|
||||
if (currentMode == 0)
|
||||
{
|
||||
isUselightThemeColor = isDesktopUselightThemeColor;
|
||||
inkColor = lastDesktopInkColor;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
inkColor = lastBoardInkColor;
|
||||
}
|
||||
|
||||
double alpha = inkCanvas.DefaultDrawingAttributes.Color.A;
|
||||
|
||||
if (penType == 0) {
|
||||
if (inkColor == 0) {
|
||||
if (penType == 0)
|
||||
{
|
||||
if (inkColor == 0)
|
||||
{
|
||||
// Black
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 0, 0, 0);
|
||||
}
|
||||
else if (inkColor == 5) {
|
||||
else if (inkColor == 5)
|
||||
{
|
||||
// White
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 255, 255, 255);
|
||||
}
|
||||
else if (isUselightThemeColor) {
|
||||
else if (isUselightThemeColor)
|
||||
{
|
||||
if (inkColor == 1)
|
||||
// Red
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 239, 68, 68);
|
||||
@@ -134,7 +159,8 @@ namespace Ink_Canvas {
|
||||
// Orange (亮色)
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 249, 115, 22);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (inkColor == 1)
|
||||
// Red
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 220, 38, 38);
|
||||
@@ -158,7 +184,8 @@ namespace Ink_Canvas {
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 234, 88, 12);
|
||||
}
|
||||
}
|
||||
else if (penType == 1) {
|
||||
else if (penType == 1)
|
||||
{
|
||||
if (highlighterColor == 100)
|
||||
// Black
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(0, 0, 0);
|
||||
@@ -191,7 +218,8 @@ namespace Ink_Canvas {
|
||||
inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(249, 115, 22);
|
||||
}
|
||||
|
||||
if (isUselightThemeColor) {
|
||||
if (isUselightThemeColor)
|
||||
{
|
||||
// 亮系
|
||||
// 亮色的红色
|
||||
BorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(239, 68, 68));
|
||||
@@ -226,7 +254,8 @@ namespace Ink_Canvas {
|
||||
ColorThemeSwitchTextBlock.Text = "暗系";
|
||||
BoardColorThemeSwitchTextBlock.Text = "暗系";
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// 暗系
|
||||
// 暗色的红色
|
||||
BorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(220, 38, 38));
|
||||
@@ -305,7 +334,8 @@ namespace Ink_Canvas {
|
||||
BoardHighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Collapsed;
|
||||
BoardHighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Collapsed;
|
||||
|
||||
switch (inkColor) {
|
||||
switch (inkColor)
|
||||
{
|
||||
case 0:
|
||||
ViewboxBtnColorBlackContent.Visibility = Visibility.Visible;
|
||||
BoardViewboxBtnColorBlackContent.Visibility = Visibility.Visible;
|
||||
@@ -342,7 +372,8 @@ namespace Ink_Canvas {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (highlighterColor) {
|
||||
switch (highlighterColor)
|
||||
{
|
||||
case 100:
|
||||
HighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible;
|
||||
BoardHighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible;
|
||||
@@ -386,18 +417,23 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckLastColor(int inkColor, bool isHighlighter = false) {
|
||||
if (isHighlighter) {
|
||||
private void CheckLastColor(int inkColor, bool isHighlighter = false)
|
||||
{
|
||||
if (isHighlighter)
|
||||
{
|
||||
highlighterColor = inkColor;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (currentMode == 0) lastDesktopInkColor = inkColor;
|
||||
else lastBoardInkColor = inkColor;
|
||||
}
|
||||
}
|
||||
|
||||
private async void CheckPenTypeUIState() {
|
||||
if (penType == 0) {
|
||||
private async void CheckPenTypeUIState()
|
||||
{
|
||||
if (penType == 0)
|
||||
{
|
||||
DefaultPenPropsPanel.Visibility = Visibility.Visible;
|
||||
DefaultPenColorsPanel.Visibility = Visibility.Visible;
|
||||
HighlighterPenColorsPanel.Visibility = Visibility.Collapsed;
|
||||
@@ -433,7 +469,8 @@ namespace Ink_Canvas {
|
||||
BoardHighlightPenTabButtonIndicator.Visibility = Visibility.Collapsed;
|
||||
|
||||
// PenPalette.Margin = new Thickness(-160, -200, -33, 32);
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
@@ -444,7 +481,8 @@ namespace Ink_Canvas {
|
||||
PenPalette.BeginAnimation(MarginProperty, marginAnimation);
|
||||
});
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
@@ -462,7 +500,8 @@ namespace Ink_Canvas {
|
||||
|
||||
await Dispatcher.InvokeAsync(() => { BoardPenPaletteGrid.Margin = new Thickness(-160, -200, -33, 50); });
|
||||
}
|
||||
else if (penType == 1) {
|
||||
else if (penType == 1)
|
||||
{
|
||||
DefaultPenPropsPanel.Visibility = Visibility.Collapsed;
|
||||
DefaultPenColorsPanel.Visibility = Visibility.Collapsed;
|
||||
HighlighterPenColorsPanel.Visibility = Visibility.Visible;
|
||||
@@ -498,7 +537,8 @@ namespace Ink_Canvas {
|
||||
BoardHighlightPenTabButtonIndicator.Visibility = Visibility.Visible;
|
||||
|
||||
// PenPalette.Margin = new Thickness(-160, -157, -33, 32);
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
@@ -509,7 +549,8 @@ namespace Ink_Canvas {
|
||||
PenPalette.BeginAnimation(MarginProperty, marginAnimation);
|
||||
});
|
||||
|
||||
await Dispatcher.InvokeAsync(() => {
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var marginAnimation = new ThicknessAnimation
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0.1),
|
||||
@@ -528,7 +569,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToDefaultPen(object sender, MouseButtonEventArgs e) {
|
||||
private void SwitchToDefaultPen(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
penType = 0;
|
||||
CheckPenTypeUIState();
|
||||
CheckColorTheme();
|
||||
@@ -538,7 +580,8 @@ namespace Ink_Canvas {
|
||||
drawingAttributes.IsHighlighter = false;
|
||||
}
|
||||
|
||||
private void SwitchToHighlighterPen(object sender, MouseButtonEventArgs e) {
|
||||
private void SwitchToHighlighterPen(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
CheckColorTheme();
|
||||
@@ -548,124 +591,145 @@ namespace Ink_Canvas {
|
||||
drawingAttributes.IsHighlighter = true;
|
||||
}
|
||||
|
||||
private void BtnColorBlack_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorBlack_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(0);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorRed_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorRed_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(1);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorGreen_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorGreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(2);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorBlue_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorBlue_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(3);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorYellow_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorYellow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(4);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorWhite_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorWhite_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(5);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorPink_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorPink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(6);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorOrange_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorOrange_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(8);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnColorTeal_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnColorTeal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(7);
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorBlack_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorBlack_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(100, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorWhite_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorWhite_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(101, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorRed_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorRed_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(102, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorYellow_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorYellow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(103, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorGreen_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorGreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(104, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorZinc_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorZinc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(105, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorBlue_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorBlue_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(106, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorPurple_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorPurple_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(107, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorTeal_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorTeal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(108, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private void BtnHighlighterColorOrange_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnHighlighterColorOrange_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckLastColor(109, true);
|
||||
penType = 1;
|
||||
CheckPenTypeUIState();
|
||||
ColorSwitchCheck();
|
||||
}
|
||||
|
||||
private Color StringToColor(string colorStr) {
|
||||
private Color StringToColor(string colorStr)
|
||||
{
|
||||
var argb = new byte[4];
|
||||
for (var i = 0; i < 4; i++) {
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var charArray = colorStr.Substring(i * 2 + 1, 2).ToCharArray();
|
||||
var b1 = toByte(charArray[0]);
|
||||
var b2 = toByte(charArray[1]);
|
||||
@@ -675,7 +739,8 @@ namespace Ink_Canvas {
|
||||
return Color.FromArgb(argb[0], argb[1], argb[2], argb[3]); //#FFFFFFFF
|
||||
}
|
||||
|
||||
private static byte toByte(char c) {
|
||||
private static byte toByte(char c)
|
||||
{
|
||||
var b = (byte)"0123456789ABCDEF".IndexOf(c);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -6,10 +7,11 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
|
||||
// 新橡皮擦系统的核心变量
|
||||
public bool isUsingAdvancedEraser;
|
||||
@@ -79,19 +81,21 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 新橡皮擦覆盖层加载事件处理
|
||||
/// </summary>
|
||||
private void EraserOverlay_Loaded(object sender, RoutedEventArgs e) {
|
||||
private void EraserOverlay_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var border = (Border)sender;
|
||||
|
||||
|
||||
// 初始化覆盖层
|
||||
InitializeEraserOverlay(border);
|
||||
|
||||
|
||||
Trace.WriteLine("Advanced Eraser: Overlay loaded and initialized");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始高级橡皮擦操作
|
||||
/// </summary>
|
||||
private void StartAdvancedEraserOperation(object sender) {
|
||||
private void StartAdvancedEraserOperation(object sender)
|
||||
{
|
||||
if (isUsingAdvancedEraser) return;
|
||||
|
||||
// 设置操作状态
|
||||
@@ -119,7 +123,8 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
private StylusShape CreateEraserShape()
|
||||
{
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
return new EllipseStylusShape(currentEraserSize, currentEraserSize);
|
||||
}
|
||||
|
||||
@@ -130,14 +135,18 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 初始化橡皮擦变换矩阵
|
||||
/// </summary>
|
||||
private void InitializeEraserTransform() {
|
||||
private void InitializeEraserTransform()
|
||||
{
|
||||
eraserTransformMatrix = new Matrix();
|
||||
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
// 圆形橡皮擦:等比例缩放
|
||||
var scale = currentEraserSize / 56.0; // 基于56x56的基准尺寸
|
||||
eraserTransformMatrix.ScaleAt(scale, scale, 0, 0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 矩形橡皮擦:保持传统比例
|
||||
var scaleX = currentEraserSize / 38.0;
|
||||
var scaleY = (currentEraserSize * 56 / 38) / 56.0;
|
||||
@@ -148,11 +157,13 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 更新橡皮擦尺寸
|
||||
/// </summary>
|
||||
private void UpdateEraserSize() {
|
||||
private void UpdateEraserSize()
|
||||
{
|
||||
// 使用与原来相同的逻辑计算橡皮擦尺寸
|
||||
double k = 1.0;
|
||||
|
||||
switch (Settings.Canvas.EraserSize) {
|
||||
|
||||
switch (Settings.Canvas.EraserSize)
|
||||
{
|
||||
case 0: k = Settings.Canvas.EraserShapeType == 0 ? 0.5 : 0.7; break;
|
||||
case 1: k = Settings.Canvas.EraserShapeType == 0 ? 0.8 : 0.9; break;
|
||||
case 2: k = 1.0; break;
|
||||
@@ -162,11 +173,14 @@ namespace Ink_Canvas {
|
||||
|
||||
// 更新形状类型
|
||||
isCurrentEraserCircle = (Settings.Canvas.EraserShapeType == 0);
|
||||
|
||||
|
||||
// 根据形状类型设置尺寸
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
currentEraserSize = k * 90; // 圆形橡皮擦
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
currentEraserSize = k * 90 * 0.6; // 矩形橡皮擦宽度
|
||||
}
|
||||
}
|
||||
@@ -174,7 +188,8 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 结束高级橡皮擦操作
|
||||
/// </summary>
|
||||
private void EndAdvancedEraserOperation(object sender) {
|
||||
private void EndAdvancedEraserOperation(object sender)
|
||||
{
|
||||
if (!isUsingAdvancedEraser) return;
|
||||
|
||||
// 重置操作状态
|
||||
@@ -182,7 +197,8 @@ namespace Ink_Canvas {
|
||||
isEraserVisible = false;
|
||||
|
||||
// 释放鼠标捕获
|
||||
if (sender is Border border) {
|
||||
if (sender is Border border)
|
||||
{
|
||||
border.ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
@@ -190,7 +206,8 @@ namespace Ink_Canvas {
|
||||
HideEraserFeedback();
|
||||
|
||||
// 结束碰撞检测
|
||||
if (advancedHitTester != null) {
|
||||
if (advancedHitTester != null)
|
||||
{
|
||||
advancedHitTester.EndHitTesting();
|
||||
advancedHitTester = null;
|
||||
}
|
||||
@@ -202,12 +219,17 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 隐藏橡皮擦视觉反馈
|
||||
/// </summary>
|
||||
private void HideEraserFeedback() {
|
||||
try {
|
||||
if (eraserVisualBorder != null) {
|
||||
private void HideEraserFeedback()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (eraserVisualBorder != null)
|
||||
{
|
||||
eraserVisualBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error hiding feedback - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -215,14 +237,19 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 提交橡皮擦历史记录
|
||||
/// </summary>
|
||||
private void CommitEraserHistory() {
|
||||
try {
|
||||
if (ReplacedStroke != null || AddedStroke != null) {
|
||||
private void CommitEraserHistory()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ReplacedStroke != null || AddedStroke != null)
|
||||
{
|
||||
timeMachine.CommitStrokeEraseHistory(ReplacedStroke, AddedStroke);
|
||||
AddedStroke = null;
|
||||
ReplacedStroke = null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error committing history - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -230,8 +257,10 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 高级橡皮擦笔画碰撞事件处理
|
||||
/// </summary>
|
||||
private void OnAdvancedEraserStrokeHit(object sender, StrokeHitEventArgs args) {
|
||||
try {
|
||||
private void OnAdvancedEraserStrokeHit(object sender, StrokeHitEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
@@ -248,15 +277,20 @@ namespace Ink_Canvas {
|
||||
var filteredResultArray = filteredResult as Stroke[] ?? filteredResult.ToArray();
|
||||
|
||||
// 执行笔画替换或删除
|
||||
if (filteredResultArray.Any()) {
|
||||
if (filteredResultArray.Any())
|
||||
{
|
||||
inkCanvas.Strokes.Replace(
|
||||
new StrokeCollection(filteredToReplaceArray),
|
||||
new StrokeCollection(filteredResultArray)
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
inkCanvas.Strokes.Remove(new StrokeCollection(filteredToReplaceArray));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error in stroke hit - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -264,13 +298,15 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 更新高级橡皮擦位置
|
||||
/// </summary>
|
||||
private void UpdateAdvancedEraserPosition(object sender, Point position) {
|
||||
private void UpdateAdvancedEraserPosition(object sender, Point position)
|
||||
{
|
||||
// 移除isUsingAdvancedEraser检查,让视觉反馈始终更新
|
||||
// if (!isUsingAdvancedEraser) return;
|
||||
|
||||
// 性能优化:限制更新频率
|
||||
var now = DateTime.Now;
|
||||
if ((now - lastEraserUpdate).TotalMilliseconds < ERASER_UPDATE_INTERVAL) {
|
||||
if ((now - lastEraserUpdate).TotalMilliseconds < ERASER_UPDATE_INTERVAL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastEraserUpdate = now;
|
||||
@@ -282,11 +318,15 @@ namespace Ink_Canvas {
|
||||
UpdateEraserVisualFeedback(position);
|
||||
|
||||
// 只有在实际使用橡皮擦时才处理擦除
|
||||
if (isUsingAdvancedEraser) {
|
||||
if (isUsingAdvancedEraser)
|
||||
{
|
||||
// 处理不同的橡皮擦模式
|
||||
if (isUsingStrokeEraser) {
|
||||
if (isUsingStrokeEraser)
|
||||
{
|
||||
ProcessStrokeEraserAtPosition(position);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessGeometryEraserAtPosition(position);
|
||||
}
|
||||
}
|
||||
@@ -295,8 +335,10 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 在指定位置处理笔画橡皮擦
|
||||
/// </summary>
|
||||
private void ProcessStrokeEraserAtPosition(Point position) {
|
||||
try {
|
||||
private void ProcessStrokeEraserAtPosition(Point position)
|
||||
{
|
||||
try
|
||||
{
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
@@ -304,10 +346,13 @@ namespace Ink_Canvas {
|
||||
.Where(stroke => !stroke.ContainsPropertyData(IsLockGuid));
|
||||
var strokesArray = hitStrokes as Stroke[] ?? hitStrokes.ToArray();
|
||||
|
||||
if (strokesArray.Any()) {
|
||||
if (strokesArray.Any())
|
||||
{
|
||||
inkCanvas.Strokes.Remove(new StrokeCollection(strokesArray));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error in stroke eraser - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -315,12 +360,17 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 在指定位置处理几何橡皮擦
|
||||
/// </summary>
|
||||
private void ProcessGeometryEraserAtPosition(Point position) {
|
||||
try {
|
||||
if (advancedHitTester != null) {
|
||||
private void ProcessGeometryEraserAtPosition(Point position)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (advancedHitTester != null)
|
||||
{
|
||||
advancedHitTester.AddPoint(position);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error in geometry eraser - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -328,11 +378,15 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 更新橡皮擦视觉反馈
|
||||
/// </summary>
|
||||
private void UpdateEraserVisualFeedback(Point position) {
|
||||
try {
|
||||
private void UpdateEraserVisualFeedback(Point position)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取或创建橡皮擦视觉反馈Border
|
||||
if (eraserVisualBorder == null) {
|
||||
eraserVisualBorder = new Border {
|
||||
if (eraserVisualBorder == null)
|
||||
{
|
||||
eraserVisualBorder = new Border
|
||||
{
|
||||
Background = new SolidColorBrush(Colors.Transparent),
|
||||
BorderBrush = new SolidColorBrush(Colors.Transparent),
|
||||
BorderThickness = new Thickness(0),
|
||||
@@ -342,53 +396,62 @@ namespace Ink_Canvas {
|
||||
Opacity = 1
|
||||
};
|
||||
Panel.SetZIndex(eraserVisualBorder, 1001);
|
||||
|
||||
|
||||
// 将Border添加到InkCanvasGridForInkReplay中
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
if (inkCanvasGrid != null)
|
||||
{
|
||||
inkCanvasGrid.Children.Add(eraserVisualBorder);
|
||||
Trace.WriteLine("Advanced Eraser: Visual feedback border added to grid");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("Advanced Eraser: Failed to find InkCanvasGridForInkReplay");
|
||||
return; // 如果找不到Grid,直接返回
|
||||
}
|
||||
}
|
||||
|
||||
if (eraserVisualBorder != null) {
|
||||
if (eraserVisualBorder != null)
|
||||
{
|
||||
// 创建橡皮擦视觉反馈
|
||||
var eraserImage = CreateEraserVisualImage();
|
||||
|
||||
|
||||
// 清除Border的内容并添加新的图像
|
||||
eraserVisualBorder.Child = eraserImage;
|
||||
|
||||
|
||||
// 更新橡皮擦位置和大小
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
var radius = currentEraserSize / 2;
|
||||
eraserVisualBorder.Width = currentEraserSize;
|
||||
eraserVisualBorder.Height = currentEraserSize;
|
||||
|
||||
|
||||
// 使用Margin来定位,因为Border在Grid中
|
||||
eraserVisualBorder.Margin = new Thickness(
|
||||
position.X - radius,
|
||||
position.Y - radius,
|
||||
position.X - radius,
|
||||
position.Y - radius,
|
||||
0, 0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 矩形橡皮擦,使用与原来相同的逻辑
|
||||
var height = currentEraserSize / 0.6;
|
||||
eraserVisualBorder.Width = currentEraserSize;
|
||||
eraserVisualBorder.Height = height;
|
||||
|
||||
|
||||
// 使用Margin来定位,因为Border在Grid中
|
||||
eraserVisualBorder.Margin = new Thickness(
|
||||
position.X - currentEraserSize / 2,
|
||||
position.Y - height / 2,
|
||||
position.X - currentEraserSize / 2,
|
||||
position.Y - height / 2,
|
||||
0, 0);
|
||||
}
|
||||
|
||||
|
||||
eraserVisualBorder.Visibility = Visibility.Visible;
|
||||
Trace.WriteLine($"Advanced Eraser: Visual feedback updated to ({position.X:F1}, {position.Y:F1})");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error updating visual feedback - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -396,14 +459,17 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 创建橡皮擦视觉图像
|
||||
/// </summary>
|
||||
private Image CreateEraserVisualImage() {
|
||||
try {
|
||||
private Image CreateEraserVisualImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 根据橡皮擦形状选择对应的DrawingGroup资源
|
||||
string resourceKey = isCurrentEraserCircle ? "EraserCircleDrawingGroup" : "EraserDrawingGroup";
|
||||
|
||||
|
||||
// 尝试从资源字典中获取DrawingGroup
|
||||
var drawingGroup = TryFindResource(resourceKey) as DrawingGroup;
|
||||
if (drawingGroup == null) {
|
||||
if (drawingGroup == null)
|
||||
{
|
||||
// 如果找不到资源,创建默认的橡皮擦图像
|
||||
return CreateDefaultEraserImage();
|
||||
}
|
||||
@@ -411,14 +477,17 @@ namespace Ink_Canvas {
|
||||
// 创建变换后的DrawingGroup
|
||||
var transformedGroup = new DrawingGroup();
|
||||
transformedGroup.Children.Add(drawingGroup);
|
||||
|
||||
|
||||
// 应用缩放变换
|
||||
var transform = new ScaleTransform();
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
var scale = currentEraserSize / 56.0; // 基于56x56的基准尺寸
|
||||
transform.ScaleX = scale;
|
||||
transform.ScaleY = scale;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
var scaleX = currentEraserSize / 38.0;
|
||||
var scaleY = (currentEraserSize / 0.6) / 56.0;
|
||||
transform.ScaleX = scaleX;
|
||||
@@ -428,16 +497,19 @@ namespace Ink_Canvas {
|
||||
|
||||
// 创建DrawingImage
|
||||
var drawingImage = new DrawingImage(transformedGroup);
|
||||
|
||||
|
||||
// 创建Image控件
|
||||
var image = new Image {
|
||||
var image = new Image
|
||||
{
|
||||
Source = drawingImage,
|
||||
Stretch = Stretch.None
|
||||
};
|
||||
RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
|
||||
|
||||
return image;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error creating eraser visual image - {ex.Message}");
|
||||
return CreateDefaultEraserImage();
|
||||
}
|
||||
@@ -446,13 +518,18 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 创建默认的橡皮擦图像(当资源不可用时)
|
||||
/// </summary>
|
||||
private Image CreateDefaultEraserImage() {
|
||||
try {
|
||||
private Image CreateDefaultEraserImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建一个简单的几何图形作为默认橡皮擦
|
||||
Geometry geometry;
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
geometry = new EllipseGeometry(new Point(28, 28), 28, 28);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
geometry = new RectangleGeometry(new Rect(0, 0, 38, 56));
|
||||
}
|
||||
|
||||
@@ -465,11 +542,14 @@ namespace Ink_Canvas {
|
||||
|
||||
// 应用缩放变换
|
||||
var transform = new ScaleTransform();
|
||||
if (isCurrentEraserCircle) {
|
||||
if (isCurrentEraserCircle)
|
||||
{
|
||||
var scale = currentEraserSize / 56.0;
|
||||
transform.ScaleX = scale;
|
||||
transform.ScaleY = scale;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
var scaleX = currentEraserSize / 38.0;
|
||||
var scaleY = (currentEraserSize / 0.6) / 56.0;
|
||||
transform.ScaleX = scaleX;
|
||||
@@ -478,13 +558,16 @@ namespace Ink_Canvas {
|
||||
drawingGroup.Transform = transform;
|
||||
|
||||
var drawingImage = new DrawingImage(drawingGroup);
|
||||
var image = new Image {
|
||||
var image = new Image
|
||||
{
|
||||
Source = drawingImage,
|
||||
Stretch = Stretch.None
|
||||
};
|
||||
|
||||
return image;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error creating default eraser image - {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
@@ -494,7 +577,8 @@ namespace Ink_Canvas {
|
||||
/// 兼容性方法:旧版橡皮擦几何碰撞处理
|
||||
/// </summary>
|
||||
[Obsolete("使用 OnAdvancedEraserStrokeHit 替代")]
|
||||
private void EraserGeometry_StrokeHit(object sender, StrokeHitEventArgs args) {
|
||||
private void EraserGeometry_StrokeHit(object sender, StrokeHitEventArgs args)
|
||||
{
|
||||
OnAdvancedEraserStrokeHit(sender, args);
|
||||
}
|
||||
|
||||
@@ -502,7 +586,8 @@ namespace Ink_Canvas {
|
||||
/// 兼容性方法:旧版橡皮擦移动处理
|
||||
/// </summary>
|
||||
[Obsolete("使用 UpdateAdvancedEraserPosition 替代")]
|
||||
private void EraserOverlay_PointerMove(object sender, Point pt) {
|
||||
private void EraserOverlay_PointerMove(object sender, Point pt)
|
||||
{
|
||||
UpdateAdvancedEraserPosition(sender, pt);
|
||||
}
|
||||
|
||||
@@ -510,7 +595,8 @@ namespace Ink_Canvas {
|
||||
/// 兼容性方法:旧版橡皮擦按下处理
|
||||
/// </summary>
|
||||
[Obsolete("使用 StartAdvancedEraserOperation 替代")]
|
||||
private void EraserOverlay_PointerDown(object sender) {
|
||||
private void EraserOverlay_PointerDown(object sender)
|
||||
{
|
||||
StartAdvancedEraserOperation(sender);
|
||||
}
|
||||
|
||||
@@ -518,14 +604,16 @@ namespace Ink_Canvas {
|
||||
/// 兼容性方法:旧版橡皮擦抬起处理
|
||||
/// </summary>
|
||||
[Obsolete("使用 EndAdvancedEraserOperation 替代")]
|
||||
private void EraserOverlay_PointerUp(object sender) {
|
||||
private void EraserOverlay_PointerUp(object sender)
|
||||
{
|
||||
EndAdvancedEraserOperation(sender);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前橡皮擦状态信息(用于调试)
|
||||
/// </summary>
|
||||
public string GetEraserStatusInfo() {
|
||||
public string GetEraserStatusInfo()
|
||||
{
|
||||
return "Advanced Eraser Status:\n" +
|
||||
$"- Active: {isUsingAdvancedEraser}\n" +
|
||||
$"- Size: {currentEraserSize:F1}\n" +
|
||||
@@ -538,22 +626,26 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 重置橡皮擦状态
|
||||
/// </summary>
|
||||
public void ResetEraserState() {
|
||||
public void ResetEraserState()
|
||||
{
|
||||
isUsingAdvancedEraser = false;
|
||||
isEraserVisible = false;
|
||||
lastEraserPosition = new Point();
|
||||
|
||||
if (advancedHitTester != null) {
|
||||
if (advancedHitTester != null)
|
||||
{
|
||||
advancedHitTester.EndHitTesting();
|
||||
advancedHitTester = null;
|
||||
}
|
||||
|
||||
HideEraserFeedback();
|
||||
|
||||
|
||||
// 清理视觉反馈Border
|
||||
if (eraserVisualBorder != null) {
|
||||
if (eraserVisualBorder != null)
|
||||
{
|
||||
var inkCanvasGrid = FindName("InkCanvasGridForInkReplay") as Grid;
|
||||
if (inkCanvasGrid != null) {
|
||||
if (inkCanvasGrid != null)
|
||||
{
|
||||
inkCanvasGrid.Children.Remove(eraserVisualBorder);
|
||||
}
|
||||
eraserVisualBorder = null;
|
||||
@@ -563,8 +655,10 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 应用高级橡皮擦形状到InkCanvas
|
||||
/// </summary>
|
||||
public void ApplyAdvancedEraserShape() {
|
||||
try {
|
||||
public void ApplyAdvancedEraserShape()
|
||||
{
|
||||
try
|
||||
{
|
||||
var inkCanvas = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvas == null) return;
|
||||
|
||||
@@ -578,13 +672,18 @@ namespace Ink_Canvas {
|
||||
inkCanvas.EraserShape = eraserShape;
|
||||
|
||||
Trace.WriteLine($"Advanced Eraser: Applied shape - Size: {currentEraserSize}, Circle: {isCurrentEraserCircle}");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error applying shape - {ex.Message}");
|
||||
|
||||
// 回退到传统方法
|
||||
try {
|
||||
try
|
||||
{
|
||||
ApplyCurrentEraserShape();
|
||||
} catch (Exception fallbackEx) {
|
||||
}
|
||||
catch (Exception fallbackEx)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Fallback also failed - {fallbackEx.Message}");
|
||||
}
|
||||
}
|
||||
@@ -593,33 +692,42 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 启用高级橡皮擦系统
|
||||
/// </summary>
|
||||
public void EnableAdvancedEraserSystem() {
|
||||
try {
|
||||
public void EnableAdvancedEraserSystem()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取橡皮擦覆盖层
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
if (eraserOverlay != null)
|
||||
{
|
||||
// 启用覆盖层的交互
|
||||
eraserOverlay.IsHitTestVisible = true;
|
||||
|
||||
|
||||
// 确保覆盖层在橡皮擦模式下启用
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
eraserOverlay.IsHitTestVisible = true;
|
||||
Trace.WriteLine("Advanced Eraser: Overlay enabled for eraser mode");
|
||||
}
|
||||
|
||||
|
||||
// 设置覆盖层的大小以覆盖整个InkCanvas
|
||||
var inkCanvasControl = FindName("inkCanvas") as InkCanvas;
|
||||
if (inkCanvasControl != null) {
|
||||
if (inkCanvasControl != null)
|
||||
{
|
||||
eraserOverlay.Width = inkCanvasControl.ActualWidth;
|
||||
eraserOverlay.Height = inkCanvasControl.ActualHeight;
|
||||
Trace.WriteLine($"Advanced Eraser: Overlay size set to {eraserOverlay.Width}x{eraserOverlay.Height}");
|
||||
}
|
||||
|
||||
|
||||
Trace.WriteLine("Advanced Eraser: System enabled successfully");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("Advanced Eraser: Failed to find eraser overlay");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error enabling system - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -627,69 +735,89 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 初始化橡皮擦覆盖层
|
||||
/// </summary>
|
||||
private void InitializeEraserOverlay(Border overlay) {
|
||||
try {
|
||||
private void InitializeEraserOverlay(Border overlay)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 设置覆盖层的基本属性
|
||||
overlay.Background = new SolidColorBrush(Colors.Transparent);
|
||||
overlay.IsHitTestVisible = false; // 默认禁用,只在橡皮擦模式下启用
|
||||
|
||||
|
||||
// 绑定事件处理
|
||||
overlay.MouseDown += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
overlay.MouseDown += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
overlay.CaptureMouse();
|
||||
StartAdvancedEraserOperation(sender);
|
||||
}
|
||||
};
|
||||
|
||||
overlay.MouseUp += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
|
||||
overlay.MouseUp += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
overlay.ReleaseMouseCapture();
|
||||
EndAdvancedEraserOperation(sender);
|
||||
}
|
||||
};
|
||||
|
||||
overlay.MouseMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
|
||||
overlay.MouseMove += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
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 {
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Mouse move ignored - not in eraser mode, current mode: {inkCanvas.EditingMode}");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 触控笔事件
|
||||
overlay.StylusDown += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
overlay.StylusDown += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
e.Handled = true;
|
||||
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) {
|
||||
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus)
|
||||
{
|
||||
overlay.CaptureStylus();
|
||||
}
|
||||
StartAdvancedEraserOperation(sender);
|
||||
}
|
||||
};
|
||||
|
||||
overlay.StylusUp += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
|
||||
overlay.StylusUp += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
e.Handled = true;
|
||||
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) {
|
||||
if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus)
|
||||
{
|
||||
overlay.ReleaseStylusCapture();
|
||||
}
|
||||
EndAdvancedEraserOperation(sender);
|
||||
}
|
||||
};
|
||||
|
||||
overlay.StylusMove += (sender, e) => {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
|
||||
overlay.StylusMove += (sender, e) =>
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
e.Handled = true;
|
||||
var position = e.GetPosition((UIElement)FindName("inkCanvas"));
|
||||
UpdateAdvancedEraserPosition(sender, position);
|
||||
Trace.WriteLine($"Advanced Eraser: Stylus move at ({position.X:F1}, {position.Y:F1})");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Trace.WriteLine("Advanced Eraser: Overlay initialized successfully");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error initializing overlay - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -697,22 +825,27 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 禁用高级橡皮擦系统
|
||||
/// </summary>
|
||||
public void DisableAdvancedEraserSystem() {
|
||||
try {
|
||||
public void DisableAdvancedEraserSystem()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 重置橡皮擦状态
|
||||
ResetEraserState();
|
||||
|
||||
|
||||
// 获取橡皮擦覆盖层并禁用
|
||||
var eraserOverlay = FindName("AdvancedEraserOverlay") as Border;
|
||||
if (eraserOverlay != null) {
|
||||
if (eraserOverlay != null)
|
||||
{
|
||||
eraserOverlay.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
|
||||
// 确保视觉反馈被隐藏
|
||||
HideEraserFeedback();
|
||||
|
||||
|
||||
Trace.WriteLine("Advanced Eraser: System disabled successfully");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.WriteLine($"Advanced Eraser: Error disabling system - {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -720,7 +853,8 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 切换橡皮擦形状(圆形/矩形)
|
||||
/// </summary>
|
||||
public void ToggleEraserShape() {
|
||||
public void ToggleEraserShape()
|
||||
{
|
||||
isCurrentEraserCircle = !isCurrentEraserCircle;
|
||||
|
||||
// 更新设置
|
||||
@@ -730,6 +864,6 @@ namespace Ink_Canvas {
|
||||
ApplyAdvancedEraserShape();
|
||||
|
||||
Trace.WriteLine($"Advanced Eraser: Toggled to {(isCurrentEraserCircle ? "Circle" : "Rectangle")}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,20 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private void Window_MouseWheel(object sender, MouseWheelEventArgs e) {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible || currentMode != 0) return;
|
||||
if (e.Delta >= 120)
|
||||
BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null);
|
||||
else if (e.Delta <= -120) BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null);
|
||||
}
|
||||
|
||||
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e) {
|
||||
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (StackPanelPPTControls.Visibility != Visibility.Visible || currentMode != 0) return;
|
||||
|
||||
if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right || e.Key == Key.N ||
|
||||
@@ -19,53 +23,66 @@ namespace Ink_Canvas {
|
||||
BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null);
|
||||
}
|
||||
|
||||
private void Window_KeyDown(object sender, KeyEventArgs e) {
|
||||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape) KeyExit(null, null);
|
||||
}
|
||||
|
||||
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e) {
|
||||
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
e.CanExecute = true;
|
||||
}
|
||||
|
||||
private void HotKey_Undo(object sender, ExecutedRoutedEventArgs e) {
|
||||
try {
|
||||
private void HotKey_Undo(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SymbolIconUndo_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void HotKey_Redo(object sender, ExecutedRoutedEventArgs e) {
|
||||
try {
|
||||
private void HotKey_Redo(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SymbolIconRedo_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void HotKey_Clear(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void HotKey_Clear(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
SymbolIconDelete_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
|
||||
|
||||
private void KeyExit(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyExit(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
|
||||
}
|
||||
|
||||
private void KeyChangeToDrawTool(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyChangeToDrawTool(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
PenIcon_Click(lastBorderMouseDownObject, null);
|
||||
}
|
||||
|
||||
private void KeyChangeToQuitDrawTool(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyChangeToQuitDrawTool(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (currentMode != 0) ImageBlackboard_MouseUp(lastBorderMouseDownObject, null);
|
||||
CursorIcon_Click(lastBorderMouseDownObject, null);
|
||||
}
|
||||
|
||||
private void KeyChangeToSelect(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyChangeToSelect(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (StackPanelCanvasControls.Visibility == Visibility.Visible)
|
||||
SymbolIconSelect_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
|
||||
private void KeyChangeToEraser(object sender, ExecutedRoutedEventArgs e) {
|
||||
if (StackPanelCanvasControls.Visibility == Visibility.Visible) {
|
||||
private void KeyChangeToEraser(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (StackPanelCanvasControls.Visibility == Visibility.Visible)
|
||||
{
|
||||
if (Eraser_Icon.Background != null)
|
||||
EraserIconByStrokes_Click(lastBorderMouseDownObject, null);
|
||||
else
|
||||
@@ -73,19 +90,23 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void KeyChangeToBoard(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyChangeToBoard(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
ImageBlackboard_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
|
||||
private void KeyCapture(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyCapture(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
SaveScreenShotToDesktop();
|
||||
}
|
||||
|
||||
private void KeyDrawLine(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyDrawLine(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (StackPanelCanvasControls.Visibility == Visibility.Visible) BtnDrawLine_Click(lastMouseDownSender, null);
|
||||
}
|
||||
|
||||
private void KeyHide(object sender, ExecutedRoutedEventArgs e) {
|
||||
private void KeyHide(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
SymbolIconEmoji_MouseUp(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace Ink_Canvas {
|
||||
public static class XamlGraphicsIconGeometries {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public static class XamlGraphicsIconGeometries
|
||||
{
|
||||
public static string LinedCursorIcon =
|
||||
"F1 M24,24z M0,0z M5.72106,15.9716L3.71327,3.00395C3.6389,2.6693 3.65747,2.41831 3.76902,2.25099 3.88057,2.08366 4.0479,2 4.271,2 4.4941,2 4.71711,2.07437 4.94021,2.2231 6.72502,3.39438 9.28149,5.10481 12.6094,7.3544 15.677,9.45526 18.1125,11.1285 19.9159,12.3742 20.1204,12.5229 20.2505,12.6995 20.3062,12.904 20.362,13.1085 20.3249,13.2944 20.1947,13.4618 20.0832,13.6105 19.8973,13.6849 19.637,13.6849L13.3902,13.6849 17.6291,19.7365C17.722,19.8666 17.75,20.0153 17.7128,20.1827 17.6942,20.3314 17.6198,20.4522 17.4897,20.5452L15.5654,21.8838C15.4353,21.9768 15.2865,22.0139 15.1192,21.9953 14.9704,21.9582 14.8496,21.8745 14.7566,21.7444L10.2389,15.2745 7.58956,19.9038C7.45942,20.1269 7.30144,20.2756 7.11552,20.35 6.92961,20.4058 6.75292,20.3872 6.5856,20.2942 6.43686,20.2013 6.34392,20.0339 6.30673,19.7922L6.00007,17.8959C5.88852,17.0779,5.79543,16.4364,5.72106,15.9716z";
|
||||
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private int lastNotificationShowTime;
|
||||
private int notificationShowTime = 2500;
|
||||
|
||||
public static void ShowNewMessage(string notice, bool isShowImmediately = true) {
|
||||
public static void ShowNewMessage(string notice, bool isShowImmediately = true)
|
||||
{
|
||||
(Application.Current?.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow)
|
||||
?.ShowNotification(notice, isShowImmediately);
|
||||
}
|
||||
|
||||
public void ShowNotification(string notice, bool isShowImmediately = true) {
|
||||
try {
|
||||
public void ShowNotification(string notice, bool isShowImmediately = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
lastNotificationShowTime = Environment.TickCount;
|
||||
|
||||
TextBlockNotice.Text = notice;
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(GridNotifications);
|
||||
|
||||
new Thread(() => {
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(notificationShowTime + 300);
|
||||
if (Environment.TickCount - lastNotificationShowTime >= notificationShowTime)
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
|
||||
});
|
||||
}).Start();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.Office.Interop.PowerPoint;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
@@ -6,22 +10,17 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
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 MouseButtonEventArgs = System.Windows.Input.MouseButtonEventArgs;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
#region Win32 API Declarations
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
@@ -627,8 +626,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void BtnCheckPPT_Click(object sender, RoutedEventArgs e) {
|
||||
try {
|
||||
private void BtnCheckPPT_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用新的PPT管理器进行连接检查
|
||||
if (_pptManager == null)
|
||||
{
|
||||
@@ -655,14 +656,16 @@ namespace Ink_Canvas {
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"手动检查PPT应用程序失败: {ex}", LogHelper.LogType.Error);
|
||||
_pptUIManager?.UpdateConnectionStatus(false);
|
||||
MessageBox.Show("未找到幻灯片");
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitchSupportWPS_Toggled(object sender, RoutedEventArgs e) {
|
||||
private void ToggleSwitchSupportWPS_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
|
||||
Settings.PowerPointSettings.IsSupportWPS = ToggleSwitchSupportWPS.IsOn;
|
||||
@@ -699,8 +702,10 @@ namespace Ink_Canvas {
|
||||
|
||||
|
||||
|
||||
private void BtnPPTSlidesUp_Click(object sender, RoutedEventArgs e) {
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
private void BtnPPTSlidesUp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_isPptClickingBtnTurned = true;
|
||||
@@ -732,15 +737,18 @@ namespace Ink_Canvas {
|
||||
_pptUIManager?.UpdateConnectionStatus(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"PPT上一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
_pptUIManager?.UpdateConnectionStatus(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void BtnPPTSlidesDown_Click(object sender, RoutedEventArgs e) {
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
private void BtnPPTSlidesDown_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_isPptClickingBtnTurned = true;
|
||||
@@ -772,7 +780,8 @@ namespace Ink_Canvas {
|
||||
_pptUIManager?.UpdateConnectionStatus(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"PPT下一页操作异常: {ex}", LogHelper.LogType.Error);
|
||||
_pptUIManager?.UpdateConnectionStatus(false);
|
||||
}
|
||||
@@ -822,7 +831,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private async void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private async void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
if (sender == PPTLSPageButton)
|
||||
@@ -868,7 +878,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 控制居中
|
||||
if (!isFloatingBarFolded) {
|
||||
if (!isFloatingBarFolded)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
}
|
||||
@@ -879,28 +890,34 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnPPTSlideShow_Click(object sender, RoutedEventArgs e) {
|
||||
new Thread(() => {
|
||||
try {
|
||||
private void BtnPPTSlideShow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_pptManager?.TryStartSlideShow() != true)
|
||||
{
|
||||
LogHelper.WriteLogToFile("启动幻灯片放映失败", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"启动幻灯片放映异常: {ex}", LogHelper.LogType.Error);
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private async void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e) {
|
||||
private async void BtnPPTSlideShowEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存当前页墨迹
|
||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||
if (currentSlide > 0)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
_pptInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
});
|
||||
@@ -916,7 +933,8 @@ namespace Ink_Canvas {
|
||||
LogHelper.WriteLogToFile("结束幻灯片放映失败", LogHelper.LogType.Warning);
|
||||
|
||||
// 手动更新UI状态,防止事件未触发
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
_pptUIManager?.UpdateSlideShowStatus(false);
|
||||
_pptUIManager?.UpdateSidebarExitButtons(false);
|
||||
LogHelper.WriteLogToFile("手动更新放映结束UI状态", LogHelper.LogType.Trace);
|
||||
@@ -932,7 +950,8 @@ namespace Ink_Canvas {
|
||||
LogHelper.WriteLogToFile($"结束PPT放映操作异常: {ex}", LogHelper.LogType.Error);
|
||||
|
||||
// 确保UI状态正确
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => {
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
_pptUIManager?.UpdateSlideShowStatus(false);
|
||||
_pptUIManager?.UpdateSidebarExitButtons(false);
|
||||
});
|
||||
@@ -942,11 +961,15 @@ namespace Ink_Canvas {
|
||||
private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
lastBorderMouseDownObject = sender;
|
||||
if (sender == PPTLSPreviousButtonBorder) {
|
||||
if (sender == PPTLSPreviousButtonBorder)
|
||||
{
|
||||
PPTLSPreviousButtonFeedbackBorder.Opacity = 0.15;
|
||||
} else if (sender == PPTRSPreviousButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSPreviousButtonBorder)
|
||||
{
|
||||
PPTRSPreviousButtonFeedbackBorder.Opacity = 0.15;
|
||||
} else if (sender == PPTLBPreviousButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBPreviousButtonBorder)
|
||||
{
|
||||
PPTLBPreviousButtonFeedbackBorder.Opacity = 0.15;
|
||||
}
|
||||
@@ -958,11 +981,15 @@ namespace Ink_Canvas {
|
||||
private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
lastBorderMouseDownObject = null;
|
||||
if (sender == PPTLSPreviousButtonBorder) {
|
||||
if (sender == PPTLSPreviousButtonBorder)
|
||||
{
|
||||
PPTLSPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTRSPreviousButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSPreviousButtonBorder)
|
||||
{
|
||||
PPTRSPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTLBPreviousButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBPreviousButtonBorder)
|
||||
{
|
||||
PPTLBPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
@@ -971,13 +998,18 @@ namespace Ink_Canvas {
|
||||
PPTRBPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
}
|
||||
private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
if (sender == PPTLSPreviousButtonBorder) {
|
||||
if (sender == PPTLSPreviousButtonBorder)
|
||||
{
|
||||
PPTLSPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTRSPreviousButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSPreviousButtonBorder)
|
||||
{
|
||||
PPTRSPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTLBPreviousButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBPreviousButtonBorder)
|
||||
{
|
||||
PPTLBPreviousButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
@@ -989,13 +1021,18 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
|
||||
private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
lastBorderMouseDownObject = sender;
|
||||
if (sender == PPTLSNextButtonBorder) {
|
||||
if (sender == PPTLSNextButtonBorder)
|
||||
{
|
||||
PPTLSNextButtonFeedbackBorder.Opacity = 0.15;
|
||||
} else if (sender == PPTRSNextButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSNextButtonBorder)
|
||||
{
|
||||
PPTRSNextButtonFeedbackBorder.Opacity = 0.15;
|
||||
} else if (sender == PPTLBNextButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBNextButtonBorder)
|
||||
{
|
||||
PPTLBNextButtonFeedbackBorder.Opacity = 0.15;
|
||||
}
|
||||
@@ -1007,11 +1044,15 @@ namespace Ink_Canvas {
|
||||
private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
lastBorderMouseDownObject = null;
|
||||
if (sender == PPTLSNextButtonBorder) {
|
||||
if (sender == PPTLSNextButtonBorder)
|
||||
{
|
||||
PPTLSNextButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTRSNextButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSNextButtonBorder)
|
||||
{
|
||||
PPTRSNextButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTLBNextButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBNextButtonBorder)
|
||||
{
|
||||
PPTLBNextButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
@@ -1020,13 +1061,18 @@ namespace Ink_Canvas {
|
||||
PPTRBNextButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
}
|
||||
private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
if (sender == PPTLSNextButtonBorder) {
|
||||
if (sender == PPTLSNextButtonBorder)
|
||||
{
|
||||
PPTLSNextButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTRSNextButtonBorder) {
|
||||
}
|
||||
else if (sender == PPTRSNextButtonBorder)
|
||||
{
|
||||
PPTRSNextButtonFeedbackBorder.Opacity = 0;
|
||||
} else if (sender == PPTLBNextButtonBorder)
|
||||
}
|
||||
else if (sender == PPTLBNextButtonBorder)
|
||||
{
|
||||
PPTLBNextButtonFeedbackBorder.Opacity = 0;
|
||||
}
|
||||
@@ -1037,7 +1083,8 @@ namespace Ink_Canvas {
|
||||
BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null);
|
||||
}
|
||||
|
||||
private void ImagePPTControlEnd_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void ImagePPTControlEnd_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -23,7 +23,8 @@ namespace Ink_Canvas
|
||||
/// </summary>
|
||||
private void RefreshBlackBoardSidePageListView()
|
||||
{
|
||||
if (blackBoardSidePageListViewObservableCollection.Count == WhiteboardTotalCount) {
|
||||
if (blackBoardSidePageListViewObservableCollection.Count == WhiteboardTotalCount)
|
||||
{
|
||||
foreach (int index in Enumerable.Range(1, WhiteboardTotalCount))
|
||||
{
|
||||
var st = ApplyHistoriesToNewStrokeCollection(TimeMachineHistories[index]);
|
||||
@@ -33,13 +34,16 @@ namespace Ink_Canvas
|
||||
Index = index,
|
||||
Strokes = st,
|
||||
};
|
||||
blackBoardSidePageListViewObservableCollection[index-1] = pitem;
|
||||
blackBoardSidePageListViewObservableCollection[index - 1] = pitem;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
blackBoardSidePageListViewObservableCollection.Clear();
|
||||
foreach (int index in Enumerable.Range(1, WhiteboardTotalCount)) {
|
||||
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));
|
||||
st.Clip(new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight));
|
||||
var pitem = new PageListViewItem
|
||||
{
|
||||
Index = index,
|
||||
@@ -58,8 +62,8 @@ namespace Ink_Canvas
|
||||
};
|
||||
blackBoardSidePageListViewObservableCollection[CurrentWhiteboardIndex - 1] = _pitem;
|
||||
|
||||
BlackBoardLeftSidePageListView.SelectedIndex = CurrentWhiteboardIndex -1;
|
||||
BlackBoardRightSidePageListView.SelectedIndex = CurrentWhiteboardIndex -1;
|
||||
BlackBoardLeftSidePageListView.SelectedIndex = CurrentWhiteboardIndex - 1;
|
||||
BlackBoardRightSidePageListView.SelectedIndex = CurrentWhiteboardIndex - 1;
|
||||
}
|
||||
|
||||
public static void ScrollViewToVerticalTop(FrameworkElement element, ScrollViewer scrollViewer)
|
||||
@@ -71,7 +75,8 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
|
||||
private void BlackBoardLeftSidePageListView_OnMouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BlackBoardLeftSidePageListView_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
|
||||
var item = BlackBoardLeftSidePageListView.SelectedItem;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using File = System.IO.File;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using File = System.IO.File;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
// 1. 定义元素信息结构
|
||||
public class CanvasElementInfo
|
||||
{
|
||||
@@ -24,8 +25,10 @@ namespace Ink_Canvas {
|
||||
public double Height { get; set; }
|
||||
public string Stretch { get; set; } = "Fill"; // 默认为Fill
|
||||
}
|
||||
public partial class MainWindow : Window {
|
||||
private void SymbolIconSaveStrokes_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private void SymbolIconSaveStrokes_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender || inkCanvas.Visibility != Visibility.Visible) return;
|
||||
|
||||
AnimationsHelper.HideWithSlideAndFade(BorderTools);
|
||||
@@ -36,8 +39,10 @@ namespace Ink_Canvas {
|
||||
SaveInkCanvasStrokes(true, true);
|
||||
}
|
||||
|
||||
private void SaveInkCanvasStrokes(bool newNotice = true, bool saveByUser = false) {
|
||||
try {
|
||||
private void SaveInkCanvasStrokes(bool newNotice = true, bool saveByUser = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var savePath = Settings.Automation.AutoSavedStrokesLocation
|
||||
+ (saveByUser ? @"\User Saved - " : @"\Auto Saved - ")
|
||||
+ (currentMode == 0 ? "Annotation Strokes" : "BlackBoard Strokes");
|
||||
@@ -49,13 +54,13 @@ namespace Ink_Canvas {
|
||||
else
|
||||
//savePathWithName = savePath + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".icstk";
|
||||
savePathWithName = savePath + @"\" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-fff") + ".icstk";
|
||||
|
||||
|
||||
if (Settings.Automation.IsSaveFullPageStrokes)
|
||||
{
|
||||
// 全页面保存模式 - 检查是否存在多页面墨迹
|
||||
bool hasMultiplePages = false;
|
||||
List<StrokeCollection> allPageStrokes = new List<StrokeCollection>();
|
||||
|
||||
|
||||
// 检查PPT放映模式下的多页面墨迹
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && _pptManager?.IsConnected == true)
|
||||
{
|
||||
@@ -101,7 +106,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hasMultiplePages && allPageStrokes.Count > 0)
|
||||
{
|
||||
// 多页面墨迹保存为压缩包
|
||||
@@ -142,7 +147,8 @@ namespace Ink_Canvas {
|
||||
if (newNotice) ShowNotification("墨迹成功保存至 " + savePathWithName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotification("墨迹保存失败");
|
||||
LogHelper.WriteLogToFile("墨迹保存失败 | " + ex.ToString(), LogHelper.LogType.Error);
|
||||
}
|
||||
@@ -158,7 +164,7 @@ namespace Ink_Canvas {
|
||||
// 创建临时目录来存放文件
|
||||
string tempDir = Path.Combine(Path.GetTempPath(), $"InkCanvas_MultiPage_{DateTime.Now:yyyyMMdd_HHmmss}");
|
||||
Directory.CreateDirectory(tempDir);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// 保存所有页面的文件到临时目录
|
||||
@@ -173,7 +179,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
strokes.Save(fs);
|
||||
}
|
||||
|
||||
|
||||
// 保存页面图像
|
||||
string imageFileName = Path.Combine(tempDir, $"page_{i + 1:D4}.png");
|
||||
using (var fs = new FileStream(imageFileName, FileMode.Create))
|
||||
@@ -182,7 +188,7 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 保存元数据信息
|
||||
string metadataFile = Path.Combine(tempDir, "metadata.txt");
|
||||
using (var writer = new StreamWriter(metadataFile, false, System.Text.Encoding.UTF8))
|
||||
@@ -201,20 +207,20 @@ namespace Ink_Canvas {
|
||||
writer.WriteLine($"PPT总页数: {pptApplication.SlideShowWindows[1].Presentation.Slides.Count}");
|
||||
writer.WriteLine($"PPT文件路径: {pptApplication.SlideShowWindows[1].Presentation.FullName}");
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < allPageStrokes.Count; i++)
|
||||
{
|
||||
writer.WriteLine($"页面 {i + 1}: {allPageStrokes[i].Count} 条墨迹");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 使用.NET Framework内置的压缩功能创建ZIP文件
|
||||
if (File.Exists(zipFileName))
|
||||
File.Delete(zipFileName);
|
||||
|
||||
|
||||
// 使用System.IO.Compression.FileSystem来创建ZIP
|
||||
System.IO.Compression.ZipFile.CreateFromDirectory(tempDir, zipFileName);
|
||||
|
||||
|
||||
if (newNotice) ShowNotification($"多页面墨迹成功保存至压缩包 {zipFileName}");
|
||||
}
|
||||
finally
|
||||
@@ -245,17 +251,17 @@ namespace Ink_Canvas {
|
||||
{
|
||||
// 全页面保存模式 - 保存整个墨迹页面的图像
|
||||
var bitmap = new System.Drawing.Bitmap(
|
||||
(int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
|
||||
(int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
|
||||
(int)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
|
||||
|
||||
|
||||
using (var g = System.Drawing.Graphics.FromImage(bitmap))
|
||||
{
|
||||
// 创建黑色或透明背景
|
||||
System.Drawing.Color bgColor = Settings.Canvas.UsingWhiteboard
|
||||
? System.Drawing.Color.White
|
||||
System.Drawing.Color bgColor = Settings.Canvas.UsingWhiteboard
|
||||
? System.Drawing.Color.White
|
||||
: System.Drawing.Color.FromArgb(22, 41, 36); // 黑板背景色
|
||||
g.Clear(bgColor);
|
||||
|
||||
|
||||
// 将InkCanvas墨迹渲染到Visual
|
||||
var visual = new DrawingVisual();
|
||||
using (var dc = visual.RenderOpen())
|
||||
@@ -265,41 +271,41 @@ namespace Ink_Canvas {
|
||||
// 绘制矩形并填充为inkCanvas的内容
|
||||
dc.DrawRectangle(visualBrush, null, new Rect(0, 0, inkCanvas.ActualWidth, inkCanvas.ActualHeight));
|
||||
}
|
||||
|
||||
|
||||
// 创建适合墨迹画布尺寸的渲染位图
|
||||
var rtb = new RenderTargetBitmap(
|
||||
(int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight,
|
||||
96, 96,
|
||||
(int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight,
|
||||
96, 96,
|
||||
PixelFormats.Pbgra32);
|
||||
rtb.Render(visual);
|
||||
|
||||
|
||||
// 转换为GDI+ Bitmap并保存
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(rtb));
|
||||
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
encoder.Save(ms);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var imgBitmap = new System.Drawing.Bitmap(ms);
|
||||
|
||||
|
||||
// 将生成的墨迹图像绘制到屏幕截图上
|
||||
// 居中绘制,确保墨迹位于屏幕中央
|
||||
int x = (bitmap.Width - imgBitmap.Width) / 2;
|
||||
int y = (bitmap.Height - imgBitmap.Height) / 2;
|
||||
g.DrawImage(imgBitmap, x, y);
|
||||
|
||||
|
||||
// 保存为PNG
|
||||
string imagePathWithName = Path.ChangeExtension(savePathWithName, "png");
|
||||
bitmap.Save(imagePathWithName, System.Drawing.Imaging.ImageFormat.Png);
|
||||
|
||||
|
||||
// 仍然保存墨迹文件以兼容旧版本
|
||||
var fs = new FileStream(savePathWithName, FileMode.Create);
|
||||
inkCanvas.Strokes.Save(fs);
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 显示提示
|
||||
if (newNotice) ShowNotification("墨迹成功全页面保存至 " + Path.ChangeExtension(savePathWithName, "png"));
|
||||
}
|
||||
@@ -316,14 +322,14 @@ namespace Ink_Canvas {
|
||||
tempCanvas.Strokes = strokes;
|
||||
tempCanvas.Width = inkCanvas.ActualWidth;
|
||||
tempCanvas.Height = inkCanvas.ActualHeight;
|
||||
|
||||
|
||||
// 创建渲染位图
|
||||
var rtb = new RenderTargetBitmap(
|
||||
(int)tempCanvas.Width, (int)tempCanvas.Height,
|
||||
96, 96,
|
||||
(int)tempCanvas.Width, (int)tempCanvas.Height,
|
||||
96, 96,
|
||||
PixelFormats.Pbgra32);
|
||||
rtb.Render(tempCanvas);
|
||||
|
||||
|
||||
// 保存为PNG
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(rtb));
|
||||
@@ -336,7 +342,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void SymbolIconOpenStrokes_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void SymbolIconOpenStrokes_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
AnimationsHelper.HideWithSlideAndFade(BorderTools);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
|
||||
@@ -348,21 +355,26 @@ namespace Ink_Canvas {
|
||||
if (openFileDialog.ShowDialog() != true) return;
|
||||
LogHelper.WriteLogToFile($"Strokes Insert: Name: {openFileDialog.FileName}",
|
||||
LogHelper.LogType.Event);
|
||||
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
string fileExtension = Path.GetExtension(openFileDialog.FileName).ToLower();
|
||||
|
||||
if (fileExtension == ".zip") {
|
||||
|
||||
if (fileExtension == ".zip")
|
||||
{
|
||||
// 处理ICC压缩包
|
||||
OpenICCZipFile(openFileDialog.FileName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 处理单个墨迹文件
|
||||
OpenSingleStrokeFile(openFileDialog.FileName);
|
||||
}
|
||||
|
||||
if (inkCanvas.Visibility != Visibility.Visible) SymbolIconCursor_Click(sender, null);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotification("墨迹打开失败");
|
||||
LogHelper.WriteLogToFile($"墨迹打开失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
}
|
||||
@@ -371,63 +383,76 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 打开ICC创建的.zip压缩包
|
||||
/// </summary>
|
||||
private void OpenICCZipFile(string zipFilePath) {
|
||||
try {
|
||||
private void OpenICCZipFile(string zipFilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建临时目录来解压文件
|
||||
string tempDir = Path.Combine(Path.GetTempPath(), $"InkCanvas_Open_{DateTime.Now:yyyyMMdd_HHmmss}");
|
||||
Directory.CreateDirectory(tempDir);
|
||||
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
// 解压ZIP文件
|
||||
System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, tempDir);
|
||||
|
||||
|
||||
// 读取元数据文件
|
||||
string metadataFile = Path.Combine(tempDir, "metadata.txt");
|
||||
if (!File.Exists(metadataFile)) {
|
||||
if (!File.Exists(metadataFile))
|
||||
{
|
||||
throw new Exception("压缩包中未找到元数据文件");
|
||||
}
|
||||
|
||||
|
||||
var metadata = ReadMetadataFile(metadataFile);
|
||||
|
||||
|
||||
// 根据元数据信息决定恢复模式
|
||||
bool isPPTMode = metadata.ContainsKey("模式") && metadata["模式"].Contains("PPT放映");
|
||||
bool isWhiteboardMode = metadata.ContainsKey("模式") && metadata["模式"].Contains("白板");
|
||||
|
||||
|
||||
// 检查当前是否处于PPT模式
|
||||
bool isCurrentlyInPPTMode = BtnPPTSlideShowEnd.Visibility == Visibility.Visible && pptApplication != null;
|
||||
|
||||
|
||||
// 检查当前是否处于白板模式
|
||||
bool isCurrentlyInWhiteboardMode = currentMode != 0;
|
||||
|
||||
|
||||
// 严格模式隔离:只在对应模式下恢复对应墨迹
|
||||
if (isPPTMode && isCurrentlyInPPTMode) {
|
||||
if (isPPTMode && isCurrentlyInPPTMode)
|
||||
{
|
||||
// 只在PPT放映模式下恢复PPT墨迹
|
||||
RestorePPTStrokesFromZip(tempDir, metadata);
|
||||
} else if (isWhiteboardMode && isCurrentlyInWhiteboardMode) {
|
||||
}
|
||||
else if (isWhiteboardMode && isCurrentlyInWhiteboardMode)
|
||||
{
|
||||
// 只在白板模式下恢复白板墨迹
|
||||
RestoreWhiteboardStrokesFromZip(tempDir, metadata);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// 模式不匹配时,显示提示信息
|
||||
string savedMode = isPPTMode ? "PPT放映" : (isWhiteboardMode ? "白板" : "未知");
|
||||
string currentMode = isCurrentlyInPPTMode ? "PPT放映" : (isCurrentlyInWhiteboardMode ? "白板" : "桌面");
|
||||
ShowNotification($"墨迹保存模式({savedMode})与当前模式({currentMode})不匹配,无法恢复墨迹");
|
||||
LogHelper.WriteLogToFile($"模式不匹配:保存模式={savedMode},当前模式={currentMode}", LogHelper.LogType.Warning);
|
||||
}
|
||||
|
||||
|
||||
ShowNotification($"成功打开ICC压缩包,共{(metadata.ContainsKey("总页数") ? metadata["总页数"] : "0")}页");
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
// 清理临时目录
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(tempDir))
|
||||
Directory.Delete(tempDir, true);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"清理临时目录失败: {ex.ToString()}", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"打开ICC压缩包失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
throw;
|
||||
}
|
||||
@@ -436,68 +461,80 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 读取元数据文件
|
||||
/// </summary>
|
||||
private Dictionary<string, string> ReadMetadataFile(string metadataPath) {
|
||||
private Dictionary<string, string> ReadMetadataFile(string metadataPath)
|
||||
{
|
||||
var metadata = new Dictionary<string, string>();
|
||||
|
||||
using (var reader = new StreamReader(metadataPath, System.Text.Encoding.UTF8)) {
|
||||
|
||||
using (var reader = new StreamReader(metadataPath, System.Text.Encoding.UTF8))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null) {
|
||||
if (line.Contains(":")) {
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
if (line.Contains(":"))
|
||||
{
|
||||
var parts = line.Split(new[] { ':' }, 2);
|
||||
if (parts.Length == 2) {
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
metadata[parts[0].Trim()] = parts[1].Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从ZIP文件恢复PPT墨迹
|
||||
/// </summary>
|
||||
private void RestorePPTStrokesFromZip(string tempDir, Dictionary<string, string> metadata) {
|
||||
try {
|
||||
private void RestorePPTStrokesFromZip(string tempDir, Dictionary<string, string> metadata)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 确保当前处于PPT放映模式
|
||||
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible || pptApplication == null) {
|
||||
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible || pptApplication == null)
|
||||
{
|
||||
throw new InvalidOperationException("当前不在PPT放映模式,无法恢复PPT墨迹");
|
||||
}
|
||||
|
||||
|
||||
// 检查PPT文件路径是否匹配
|
||||
if (metadata.ContainsKey("PPT文件路径"))
|
||||
{
|
||||
string savedPptPath = metadata["PPT文件路径"];
|
||||
string currentPptPath = pptApplication.SlideShowWindows[1].Presentation.FullName;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(savedPptPath) && !string.IsNullOrEmpty(currentPptPath))
|
||||
{
|
||||
// 使用文件路径哈希值进行比较,避免路径格式差异
|
||||
string savedHash = GetFileHash(savedPptPath);
|
||||
string currentHash = GetFileHash(currentPptPath);
|
||||
|
||||
|
||||
if (savedHash != currentHash)
|
||||
{
|
||||
throw new InvalidOperationException($"墨迹文件与当前PPT文件不匹配。保存的PPT: {savedPptPath},当前PPT: {currentPptPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 清空当前墨迹
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
|
||||
|
||||
// 重置PPT墨迹存储
|
||||
_pptInkManager?.ClearAllStrokes();
|
||||
|
||||
// 读取所有页面的墨迹文件
|
||||
var files = Directory.GetFiles(tempDir, "page_*.icstk");
|
||||
foreach (var file in files) {
|
||||
foreach (var file in files)
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(file);
|
||||
if (fileName.StartsWith("page_") && int.TryParse(fileName.Substring(5), out int pageNumber)) {
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
|
||||
if (fileName.StartsWith("page_") && int.TryParse(fileName.Substring(5), out int pageNumber))
|
||||
{
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var strokes = new StrokeCollection(fs);
|
||||
if (strokes.Count > 0) {
|
||||
if (strokes.Count > 0)
|
||||
{
|
||||
_pptInkManager?.SaveCurrentSlideStrokes(pageNumber, strokes);
|
||||
}
|
||||
}
|
||||
@@ -505,17 +542,20 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 恢复当前页面的墨迹
|
||||
if (_pptManager?.IsInSlideShow == true) {
|
||||
if (_pptManager?.IsInSlideShow == true)
|
||||
{
|
||||
int currentSlide = _pptManager.GetCurrentSlideNumber();
|
||||
var currentStrokes = _pptInkManager?.LoadSlideStrokes(currentSlide);
|
||||
if (currentStrokes != null && currentStrokes.Count > 0) {
|
||||
if (currentStrokes != null && currentStrokes.Count > 0)
|
||||
{
|
||||
inkCanvas.Strokes.Add(currentStrokes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile($"成功恢复PPT墨迹,共{files.Length}页");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"恢复PPT墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
throw;
|
||||
}
|
||||
@@ -524,40 +564,49 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 从ZIP文件恢复白板墨迹
|
||||
/// </summary>
|
||||
private void RestoreWhiteboardStrokesFromZip(string tempDir, Dictionary<string, string> metadata) {
|
||||
try {
|
||||
private void RestoreWhiteboardStrokesFromZip(string tempDir, Dictionary<string, string> metadata)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 确保当前处于白板模式
|
||||
if (currentMode == 0) {
|
||||
if (currentMode == 0)
|
||||
{
|
||||
throw new InvalidOperationException("当前不在白板模式,无法恢复白板墨迹");
|
||||
}
|
||||
|
||||
|
||||
// 清空当前墨迹
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
|
||||
|
||||
// 读取总页数
|
||||
int totalPages = 1;
|
||||
if (metadata.ContainsKey("总页数") && int.TryParse(metadata["总页数"], out int parsedPages)) {
|
||||
if (metadata.ContainsKey("总页数") && int.TryParse(metadata["总页数"], out int parsedPages))
|
||||
{
|
||||
totalPages = parsedPages;
|
||||
}
|
||||
|
||||
|
||||
// 重置白板状态
|
||||
WhiteboardTotalCount = totalPages;
|
||||
CurrentWhiteboardIndex = 1;
|
||||
|
||||
|
||||
// 清空历史记录
|
||||
for (int i = 0; i < TimeMachineHistories.Length; i++) {
|
||||
for (int i = 0; i < TimeMachineHistories.Length; i++)
|
||||
{
|
||||
TimeMachineHistories[i] = null;
|
||||
}
|
||||
|
||||
|
||||
// 读取所有页面的墨迹文件
|
||||
var files = Directory.GetFiles(tempDir, "page_*.icstk");
|
||||
foreach (var file in files) {
|
||||
foreach (var file in files)
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(file);
|
||||
if (fileName.StartsWith("page_") && int.TryParse(fileName.Substring(5), out int pageNumber)) {
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
|
||||
if (fileName.StartsWith("page_") && int.TryParse(fileName.Substring(5), out int pageNumber))
|
||||
{
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var strokes = new StrokeCollection(fs);
|
||||
if (strokes.Count > 0) {
|
||||
if (strokes.Count > 0)
|
||||
{
|
||||
// 创建历史记录
|
||||
var history = new TimeMachineHistory(strokes, TimeMachineHistoryType.UserInput, false);
|
||||
TimeMachineHistories[pageNumber] = new TimeMachineHistory[] { history };
|
||||
@@ -565,18 +614,20 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 恢复第一页的墨迹
|
||||
if (TimeMachineHistories[1] != null) {
|
||||
if (TimeMachineHistories[1] != null)
|
||||
{
|
||||
RestoreStrokes();
|
||||
}
|
||||
|
||||
|
||||
// 更新UI显示
|
||||
UpdateIndexInfoDisplay();
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile($"成功恢复白板墨迹,共{totalPages}页");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"恢复白板墨迹失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||
throw;
|
||||
}
|
||||
@@ -585,51 +636,55 @@ namespace Ink_Canvas {
|
||||
/// <summary>
|
||||
/// 打开单个墨迹文件
|
||||
/// </summary>
|
||||
private void OpenSingleStrokeFile(string filePath) {
|
||||
var fileStreamHasNoStroke = false;
|
||||
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) {
|
||||
var strokes = new StrokeCollection(fs);
|
||||
fileStreamHasNoStroke = strokes.Count == 0;
|
||||
if (!fileStreamHasNoStroke) {
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
LogHelper.NewLog($"Strokes Insert: Strokes Count: {inkCanvas.Strokes.Count.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复元素信息
|
||||
var elementsFile = Path.ChangeExtension(filePath, ".elements.json");
|
||||
if (File.Exists(elementsFile))
|
||||
private void OpenSingleStrokeFile(string filePath)
|
||||
{
|
||||
var fileStreamHasNoStroke = false;
|
||||
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var strokes = new StrokeCollection(fs);
|
||||
fileStreamHasNoStroke = strokes.Count == 0;
|
||||
if (!fileStreamHasNoStroke)
|
||||
{
|
||||
var elementInfos = JsonConvert.DeserializeObject<List<CanvasElementInfo>>(File.ReadAllText(elementsFile));
|
||||
foreach (var info in elementInfos)
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
LogHelper.NewLog($"Strokes Insert: Strokes Count: {inkCanvas.Strokes.Count.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复元素信息
|
||||
var elementsFile = Path.ChangeExtension(filePath, ".elements.json");
|
||||
if (File.Exists(elementsFile))
|
||||
{
|
||||
var elementInfos = JsonConvert.DeserializeObject<List<CanvasElementInfo>>(File.ReadAllText(elementsFile));
|
||||
foreach (var info in elementInfos)
|
||||
{
|
||||
if (info.Type == "Image" && File.Exists(info.SourcePath))
|
||||
{
|
||||
if (info.Type == "Image" && File.Exists(info.SourcePath))
|
||||
var img = new Image
|
||||
{
|
||||
var img = new Image
|
||||
{
|
||||
Source = new BitmapImage(new Uri(info.SourcePath)),
|
||||
Width = info.Width,
|
||||
Height = info.Height,
|
||||
Stretch = Enum.TryParse<Stretch>(info.Stretch, out var stretch) ? stretch : Stretch.Fill
|
||||
};
|
||||
InkCanvas.SetLeft(img, info.Left);
|
||||
InkCanvas.SetTop(img, info.Top);
|
||||
inkCanvas.Children.Add(img);
|
||||
}
|
||||
Source = new BitmapImage(new Uri(info.SourcePath)),
|
||||
Width = info.Width,
|
||||
Height = info.Height,
|
||||
Stretch = Enum.TryParse<Stretch>(info.Stretch, out var stretch) ? stretch : Stretch.Fill
|
||||
};
|
||||
InkCanvas.SetLeft(img, info.Left);
|
||||
InkCanvas.SetTop(img, info.Top);
|
||||
inkCanvas.Children.Add(img);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileStreamHasNoStroke)
|
||||
using (var ms = new MemoryStream(File.ReadAllBytes(filePath))) {
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var strokes = new StrokeCollection(ms);
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
LogHelper.NewLog($"Strokes Insert (2): Strokes Count: {strokes.Count.ToString()}");
|
||||
}
|
||||
|
||||
if (fileStreamHasNoStroke)
|
||||
using (var ms = new MemoryStream(File.ReadAllBytes(filePath)))
|
||||
{
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
var strokes = new StrokeCollection(ms);
|
||||
ClearStrokes(true);
|
||||
timeMachine.ClearStrokeHistory();
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
LogHelper.NewLog($"Strokes Insert (2): Strokes Count: {strokes.Count.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
@@ -8,93 +9,103 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Application = System.Windows.Application;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using Size = System.Drawing.Size;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
// 截图结果结构体
|
||||
public struct ScreenshotResult
|
||||
{
|
||||
public System.Drawing.Rectangle Area;
|
||||
public List<System.Windows.Point> Path;
|
||||
|
||||
|
||||
public ScreenshotResult(System.Drawing.Rectangle area, List<System.Windows.Point> path = null)
|
||||
{
|
||||
Area = area;
|
||||
Path = path;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainWindow : Window {
|
||||
private void SaveScreenShot(bool isHideNotification, string fileName = null) {
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private void SaveScreenShot(bool isHideNotification, string fileName = null)
|
||||
{
|
||||
var savePath = Settings.Automation.IsSaveScreenshotsInDateFolders
|
||||
? GetDateFolderPath(fileName)
|
||||
: GetDefaultFolderPath();
|
||||
|
||||
CaptureAndSaveScreenshot(savePath, isHideNotification);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
private void SaveScreenShotToDesktop() {
|
||||
private void SaveScreenShotToDesktop()
|
||||
{
|
||||
var desktopPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
$"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
|
||||
|
||||
CaptureAndSaveScreenshot(desktopPath, false);
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
|
||||
SaveInkCanvasStrokes(false);
|
||||
}
|
||||
|
||||
// 提取公共的截图和保存逻辑
|
||||
private void CaptureAndSaveScreenshot(string savePath, bool isHideNotification) {
|
||||
private void CaptureAndSaveScreenshot(string savePath, bool isHideNotification)
|
||||
{
|
||||
var rc = SystemInformation.VirtualScreen;
|
||||
|
||||
|
||||
using (var bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb))
|
||||
using (var memoryGraphics = Graphics.FromImage(bitmap)) {
|
||||
using (var memoryGraphics = Graphics.FromImage(bitmap))
|
||||
{
|
||||
memoryGraphics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
|
||||
|
||||
|
||||
// 确保目录存在
|
||||
var directory = Path.GetDirectoryName(savePath);
|
||||
if (!Directory.Exists(directory)) {
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
|
||||
bitmap.Save(savePath, ImageFormat.Png);
|
||||
}
|
||||
|
||||
if (!isHideNotification) {
|
||||
|
||||
if (!isHideNotification)
|
||||
{
|
||||
ShowNotification($"截图成功保存至 {savePath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取日期文件夹路径
|
||||
private string GetDateFolderPath(string fileName) {
|
||||
if (string.IsNullOrWhiteSpace(fileName)) {
|
||||
private string GetDateFolderPath(string fileName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
fileName = DateTime.Now.ToString("HH-mm-ss");
|
||||
}
|
||||
|
||||
|
||||
var basePath = Settings.Automation.AutoSavedStrokesLocation;
|
||||
var dateFolder = DateTime.Now.ToString("yyyyMMdd");
|
||||
|
||||
|
||||
return Path.Combine(
|
||||
basePath,
|
||||
"Auto Saved - Screenshots",
|
||||
dateFolder,
|
||||
basePath,
|
||||
"Auto Saved - Screenshots",
|
||||
dateFolder,
|
||||
$"{fileName}.png");
|
||||
}
|
||||
|
||||
// 获取默认文件夹路径
|
||||
private string GetDefaultFolderPath() {
|
||||
private string GetDefaultFolderPath()
|
||||
{
|
||||
var basePath = Settings.Automation.AutoSavedStrokesLocation;
|
||||
var screenshotsFolder = Path.Combine(basePath, "Auto Saved - Screenshots");
|
||||
|
||||
if (!Directory.Exists(screenshotsFolder)) {
|
||||
if (!Directory.Exists(screenshotsFolder))
|
||||
{
|
||||
Directory.CreateDirectory(screenshotsFolder);
|
||||
}
|
||||
|
||||
@@ -104,8 +115,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 截图并复制到剪贴板
|
||||
private async Task CaptureScreenshotToClipboard() {
|
||||
try {
|
||||
private async Task CaptureScreenshotToClipboard()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 隐藏主窗口以避免截图包含窗口本身
|
||||
var originalVisibility = this.Visibility;
|
||||
this.Visibility = Visibility.Hidden;
|
||||
@@ -127,13 +140,13 @@ namespace Ink_Canvas {
|
||||
if (originalBitmap != null)
|
||||
{
|
||||
Bitmap finalBitmap = originalBitmap;
|
||||
|
||||
|
||||
// 如果有路径信息,应用形状遮罩
|
||||
if (screenshotResult.Value.Path != null && screenshotResult.Value.Path.Count > 0)
|
||||
{
|
||||
finalBitmap = ApplyShapeMask(originalBitmap, screenshotResult.Value.Path, screenshotResult.Value.Area);
|
||||
}
|
||||
|
||||
|
||||
// 将截图复制到剪贴板
|
||||
CopyBitmapToClipboard(finalBitmap);
|
||||
|
||||
@@ -148,7 +161,8 @@ namespace Ink_Canvas {
|
||||
ShowNotification("截图已取消");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotification($"截图失败: {ex.Message}");
|
||||
this.Visibility = Visibility.Visible;
|
||||
}
|
||||
@@ -221,32 +235,41 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 自动粘贴截图到画布
|
||||
private async Task AutoPasteScreenshot() {
|
||||
try {
|
||||
private async Task AutoPasteScreenshot()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 只在白板模式下自动粘贴
|
||||
if (currentMode == 1) {
|
||||
if (currentMode == 1)
|
||||
{
|
||||
await PasteImageFromClipboard();
|
||||
ShowNotification("截图已自动插入到画布");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotification("截图已复制到剪贴板,可在白板模式下粘贴");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotification($"自动粘贴截图失败: {ex.Message}");
|
||||
LogHelper.WriteLogToFile($"自动粘贴截图失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 将Bitmap复制到剪贴板
|
||||
private void CopyBitmapToClipboard(Bitmap bitmap) {
|
||||
try {
|
||||
private void CopyBitmapToClipboard(Bitmap bitmap)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 将System.Drawing.Bitmap转换为WPF BitmapSource
|
||||
var bitmapSource = ConvertBitmapToBitmapSource(bitmap);
|
||||
|
||||
// 复制到剪贴板
|
||||
Clipboard.SetImage(bitmapSource);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotification($"复制到剪贴板失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
@@ -259,7 +282,7 @@ namespace Ink_Canvas {
|
||||
// 获取DPI缩放比例
|
||||
var dpiScale = GetDpiScale();
|
||||
var virtualScreen = SystemInformation.VirtualScreen;
|
||||
|
||||
|
||||
// 创建结果位图
|
||||
var resultBitmap = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format32bppArgb);
|
||||
using (var resultGraphics = Graphics.FromImage(resultBitmap))
|
||||
@@ -278,11 +301,11 @@ namespace Ink_Canvas {
|
||||
// 将WPF坐标转换为实际屏幕坐标,然后相对于截图区域计算偏移
|
||||
double screenX = (path[i].X * dpiScale) + virtualScreen.Left;
|
||||
double screenY = (path[i].Y * dpiScale) + virtualScreen.Top;
|
||||
|
||||
|
||||
// 计算相对于截图区域的坐标
|
||||
float relativeX = (float)(screenX - area.X);
|
||||
float relativeY = (float)(screenY - area.Y);
|
||||
|
||||
|
||||
points[i] = new PointF(relativeX, relativeY);
|
||||
}
|
||||
|
||||
@@ -291,7 +314,7 @@ namespace Ink_Canvas {
|
||||
|
||||
// 设置裁剪区域为路径内部
|
||||
resultGraphics.SetClip(pathGraphics);
|
||||
|
||||
|
||||
// 在裁剪区域内绘制原始图像
|
||||
resultGraphics.DrawImage(bitmap, 0, 0);
|
||||
}
|
||||
@@ -318,8 +341,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 将System.Drawing.Bitmap转换为WPF BitmapSource
|
||||
private BitmapSource ConvertBitmapToBitmapSource(Bitmap bitmap) {
|
||||
using (var memory = new MemoryStream()) {
|
||||
private BitmapSource ConvertBitmapToBitmapSource(Bitmap bitmap)
|
||||
{
|
||||
using (var memory = new MemoryStream())
|
||||
{
|
||||
bitmap.Save(memory, ImageFormat.Png);
|
||||
memory.Position = 0;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
@@ -7,21 +8,24 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
#region Floating Control
|
||||
|
||||
private object lastBorderMouseDownObject;
|
||||
|
||||
private void Border_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 如果发送者是 RandomDrawPanel 或 SingleDrawPanel,且它们被隐藏,则不处理事件
|
||||
if (sender is SimpleStackPanel panel) {
|
||||
if ((panel == RandomDrawPanel || panel == SingleDrawPanel) &&
|
||||
panel.Visibility != Visibility.Visible) {
|
||||
if (sender is SimpleStackPanel panel)
|
||||
{
|
||||
if ((panel == RandomDrawPanel || panel == SingleDrawPanel) &&
|
||||
panel.Visibility != Visibility.Visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -30,22 +34,26 @@ namespace Ink_Canvas {
|
||||
|
||||
private bool isStrokeSelectionCloneOn;
|
||||
|
||||
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
if (isStrokeSelectionCloneOn) {
|
||||
if (isStrokeSelectionCloneOn)
|
||||
{
|
||||
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
||||
|
||||
isStrokeSelectionCloneOn = false;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
BorderStrokeSelectionClone.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
|
||||
|
||||
isStrokeSelectionCloneOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void BorderStrokeSelectionCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BorderStrokeSelectionCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
var strokes = inkCanvas.GetSelectedStrokes();
|
||||
@@ -55,23 +63,28 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
}
|
||||
|
||||
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
SymbolIconDelete_MouseUp(sender, e);
|
||||
}
|
||||
|
||||
private void GridPenWidthDecrease_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPenWidthDecrease_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
ChangeStrokeThickness(0.8);
|
||||
}
|
||||
|
||||
private void GridPenWidthIncrease_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPenWidthIncrease_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
ChangeStrokeThickness(1.25);
|
||||
}
|
||||
|
||||
private void ChangeStrokeThickness(double multipler) {
|
||||
foreach (var stroke in inkCanvas.GetSelectedStrokes()) {
|
||||
private void ChangeStrokeThickness(double multipler)
|
||||
{
|
||||
foreach (var stroke in inkCanvas.GetSelectedStrokes())
|
||||
{
|
||||
var newWidth = stroke.DrawingAttributes.Width * multipler;
|
||||
var newHeight = stroke.DrawingAttributes.Height * multipler;
|
||||
if (!(newWidth >= DrawingAttributes.MinWidth) || !(newWidth <= DrawingAttributes.MaxWidth)
|
||||
@@ -92,16 +105,19 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void GridPenWidthRestore_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridPenWidthRestore_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
foreach (var stroke in inkCanvas.GetSelectedStrokes()) {
|
||||
foreach (var stroke in inkCanvas.GetSelectedStrokes())
|
||||
{
|
||||
stroke.DrawingAttributes.Width = inkCanvas.DefaultDrawingAttributes.Width;
|
||||
stroke.DrawingAttributes.Height = inkCanvas.DefaultDrawingAttributes.Height;
|
||||
}
|
||||
}
|
||||
|
||||
private void ImageFlipHorizontal_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void ImageFlipHorizontal_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
var m = new Matrix();
|
||||
@@ -137,7 +153,8 @@ namespace Ink_Canvas {
|
||||
//updateBorderStrokeSelectionControlLocation();
|
||||
}
|
||||
|
||||
private void ImageFlipVertical_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void ImageFlipVertical_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
var m = new Matrix();
|
||||
@@ -166,8 +183,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
// ... existing code ...
|
||||
private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
// ... existing code ...
|
||||
private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
var m = new Matrix();
|
||||
@@ -196,7 +214,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (lastBorderMouseDownObject != sender) return;
|
||||
|
||||
var m = new Matrix();
|
||||
@@ -235,27 +254,33 @@ namespace Ink_Canvas {
|
||||
private bool isGridInkCanvasSelectionCoverMouseDown;
|
||||
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
|
||||
|
||||
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
isGridInkCanvasSelectionCoverMouseDown = true;
|
||||
}
|
||||
|
||||
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!isGridInkCanvasSelectionCoverMouseDown) return;
|
||||
isGridInkCanvasSelectionCoverMouseDown = false;
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void BtnSelect_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnSelect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ExitMultiTouchModeIfNeeded();
|
||||
forceEraser = true;
|
||||
drawingShapeMode = 0;
|
||||
inkCanvas.IsManipulationEnabled = false;
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) {
|
||||
if (inkCanvas.GetSelectedStrokes().Count == inkCanvas.Strokes.Count) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
||||
{
|
||||
if (inkCanvas.GetSelectedStrokes().Count == inkCanvas.Strokes.Count)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
var selectedStrokes = new StrokeCollection();
|
||||
foreach (var stroke in inkCanvas.Strokes)
|
||||
if (stroke.GetBounds().Width > 0 && stroke.GetBounds().Height > 0)
|
||||
@@ -263,7 +288,8 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Select(selectedStrokes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
|
||||
}
|
||||
}
|
||||
@@ -272,14 +298,17 @@ namespace Ink_Canvas {
|
||||
private double BorderStrokeSelectionControlHeight = 80.0;
|
||||
private bool isProgramChangeStrokeSelection;
|
||||
|
||||
private void inkCanvas_SelectionChanged(object sender, EventArgs e) {
|
||||
private void inkCanvas_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (isProgramChangeStrokeSelection) return;
|
||||
if (inkCanvas.GetSelectedStrokes().Count == 0) {
|
||||
if (inkCanvas.GetSelectedStrokes().Count == 0)
|
||||
{
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
// 当没有选中笔画时,检查是否有选中的UIElement
|
||||
CheckUIElementSelection();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
||||
isStrokeSelectionCloneOn = false;
|
||||
@@ -304,7 +333,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBorderStrokeSelectionControlLocation() {
|
||||
private void updateBorderStrokeSelectionControlLocation()
|
||||
{
|
||||
var borderLeft = (inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Right -
|
||||
BorderStrokeSelectionControlWidth) / 2;
|
||||
var borderTop = inkCanvas.GetSelectionBounds().Bottom + 1;
|
||||
@@ -319,11 +349,13 @@ namespace Ink_Canvas {
|
||||
BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0);
|
||||
}
|
||||
|
||||
private void GridInkCanvasSelectionCover_ManipulationStarting(object sender, ManipulationStartingEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
|
||||
{
|
||||
e.Mode = ManipulationModes.All;
|
||||
}
|
||||
|
||||
private void GridInkCanvasSelectionCover_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
|
||||
{
|
||||
if (StrokeManipulationHistory?.Count > 0)
|
||||
{
|
||||
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
|
||||
@@ -344,9 +376,12 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void GridInkCanvasSelectionCover_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
|
||||
try {
|
||||
if (dec.Count >= 1) {
|
||||
private void GridInkCanvasSelectionCover_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dec.Count >= 1)
|
||||
{
|
||||
bool disableScale = dec.Count >= 3;
|
||||
var md = e.DeltaManipulation;
|
||||
var trans = md.Translation; // 获得位移矢量
|
||||
@@ -372,10 +407,12 @@ namespace Ink_Canvas {
|
||||
strokes = StrokesSelectionClone;
|
||||
else if (Settings.Gesture.IsEnableTwoFingerRotationOnSelection)
|
||||
m.RotateAt(rotate, center.X, center.Y); // 旋转
|
||||
foreach (var stroke in strokes) {
|
||||
foreach (var stroke in strokes)
|
||||
{
|
||||
stroke.Transform(m, false);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
stroke.DrawingAttributes.Width *= md.Scale.X;
|
||||
stroke.DrawingAttributes.Height *= md.Scale.Y;
|
||||
}
|
||||
@@ -394,15 +431,18 @@ namespace Ink_Canvas {
|
||||
|
||||
private Point lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
|
||||
|
||||
private void GridInkCanvasSelectionCover_PreviewTouchDown(object sender, TouchEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_PreviewTouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
dec.Add(e.TouchDevice.Id);
|
||||
//设备1个的时候,记录中心点
|
||||
if (dec.Count == 1) {
|
||||
if (dec.Count == 1)
|
||||
{
|
||||
var touchPoint = e.GetTouchPoint(null);
|
||||
centerPoint = touchPoint.Position;
|
||||
lastTouchPointOnGridInkCanvasCover = touchPoint.Position;
|
||||
|
||||
if (isStrokeSelectionCloneOn) {
|
||||
if (isStrokeSelectionCloneOn)
|
||||
{
|
||||
var strokes = inkCanvas.GetSelectedStrokes();
|
||||
isProgramChangeStrokeSelection = true;
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
@@ -411,7 +451,8 @@ namespace Ink_Canvas {
|
||||
isProgramChangeStrokeSelection = false;
|
||||
inkCanvas.Strokes.Add(StrokesSelectionClone);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// 新增:启动套索选择模式
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
@@ -419,11 +460,13 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void GridInkCanvasSelectionCover_PreviewTouchUp(object sender, TouchEventArgs e) {
|
||||
private void GridInkCanvasSelectionCover_PreviewTouchUp(object sender, TouchEventArgs e)
|
||||
{
|
||||
dec.Remove(e.TouchDevice.Id);
|
||||
if (dec.Count >= 1) return;
|
||||
isProgramChangeStrokeSelection = false;
|
||||
if (lastTouchPointOnGridInkCanvasCover == e.GetTouchPoint(null).Position) {
|
||||
if (lastTouchPointOnGridInkCanvasCover == e.GetTouchPoint(null).Position)
|
||||
{
|
||||
if (!(lastTouchPointOnGridInkCanvasCover.X < inkCanvas.GetSelectionBounds().Left) &&
|
||||
!(lastTouchPointOnGridInkCanvasCover.Y < inkCanvas.GetSelectionBounds().Top) &&
|
||||
!(lastTouchPointOnGridInkCanvasCover.X > inkCanvas.GetSelectionBounds().Right) &&
|
||||
@@ -431,17 +474,20 @@ namespace Ink_Canvas {
|
||||
inkCanvas.Select(new StrokeCollection());
|
||||
StrokesSelectionClone = new StrokeCollection();
|
||||
}
|
||||
else if (inkCanvas.GetSelectedStrokes().Count == 0) {
|
||||
else if (inkCanvas.GetSelectedStrokes().Count == 0)
|
||||
{
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||
StrokesSelectionClone = new StrokeCollection();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||
StrokesSelectionClone = new StrokeCollection();
|
||||
}
|
||||
}
|
||||
|
||||
private void LassoSelect_Click(object sender, RoutedEventArgs e) {
|
||||
private void LassoSelect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ExitMultiTouchModeIfNeeded();
|
||||
forceEraser = false;
|
||||
forcePointEraser = false;
|
||||
@@ -450,7 +496,8 @@ namespace Ink_Canvas {
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
}
|
||||
|
||||
private void BtnLassoSelect_Click(object sender, RoutedEventArgs e) {
|
||||
private void BtnLassoSelect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ExitMultiTouchModeIfNeeded();
|
||||
forceEraser = false;
|
||||
forcePointEraser = false;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using OSVersionExtension;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -6,64 +10,80 @@ 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 : Window {
|
||||
private void LoadSettings(bool isStartup = false) {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private void LoadSettings(bool isStartup = false)
|
||||
{
|
||||
AppVersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
try {
|
||||
if (File.Exists(App.RootPath + settingsFileName)) {
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (File.Exists(App.RootPath + settingsFileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = File.ReadAllText(App.RootPath + settingsFileName);
|
||||
Settings = JsonConvert.DeserializeObject<Settings>(text);
|
||||
}
|
||||
catch { }
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnResetToSuggestion_Click(null, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
// Startup
|
||||
if (isStartup) {
|
||||
if (isStartup)
|
||||
{
|
||||
CursorIcon_Click(null, null);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) +
|
||||
"\\Ink Canvas Annotation.lnk")) {
|
||||
"\\Ink Canvas Annotation.lnk"))
|
||||
{
|
||||
ToggleSwitchRunAtStartup.IsOn = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
if (Settings.Startup != null) {
|
||||
if (isStartup) {
|
||||
if (Settings.Automation.AutoDelSavedFiles) {
|
||||
if (Settings.Startup != null)
|
||||
{
|
||||
if (isStartup)
|
||||
{
|
||||
if (Settings.Automation.AutoDelSavedFiles)
|
||||
{
|
||||
DelAutoSavedFiles.DeleteFilesOlder(Settings.Automation.AutoSavedStrokesLocation,
|
||||
Settings.Automation.AutoDelSavedFilesDaysThreshold);
|
||||
}
|
||||
|
||||
if (Settings.Startup.IsFoldAtStartup) {
|
||||
if (Settings.Startup.IsFoldAtStartup)
|
||||
{
|
||||
FoldFloatingBar_MouseUp(Fold_Icon, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.Startup.IsEnableNibMode) {
|
||||
if (Settings.Startup.IsEnableNibMode)
|
||||
{
|
||||
ToggleSwitchEnableNibMode.IsOn = true;
|
||||
BoardToggleSwitchEnableNibMode.IsOn = true;
|
||||
BoundsWidth = Settings.Advanced.NibModeBoundsWidth;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleSwitchEnableNibMode.IsOn = false;
|
||||
BoardToggleSwitchEnableNibMode.IsOn = false;
|
||||
BoundsWidth = Settings.Advanced.FingerModeBoundsWidth;
|
||||
@@ -71,29 +91,36 @@ namespace Ink_Canvas {
|
||||
|
||||
// 设置自动更新相关选项
|
||||
ToggleSwitchIsAutoUpdate.IsOn = Settings.Startup.IsAutoUpdate;
|
||||
|
||||
|
||||
// 只有在启用了自动更新功能时才检查更新
|
||||
if (Settings.Startup.IsAutoUpdate) {
|
||||
if (isStartup) {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Running auto-update check at startup");
|
||||
AutoUpdate();
|
||||
}
|
||||
if (Settings.Startup.IsAutoUpdate)
|
||||
{
|
||||
if (isStartup)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Running auto-update check at startup");
|
||||
AutoUpdate();
|
||||
}
|
||||
// 当设置被修改时也检查更新(非启动时)
|
||||
else {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Running auto-update check after settings change");
|
||||
AutoUpdate();
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Running auto-update check after settings change");
|
||||
AutoUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// ToggleSwitchIsAutoUpdateWithSilence.Visibility = Settings.Startup.IsAutoUpdate ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (Settings.Startup.IsAutoUpdateWithSilence) {
|
||||
if (Settings.Startup.IsAutoUpdateWithSilence)
|
||||
{
|
||||
ToggleSwitchIsAutoUpdateWithSilence.IsOn = true;
|
||||
}
|
||||
|
||||
// 初始化更新通道选择
|
||||
foreach (var radioButton in UpdateChannelSelector.Items) {
|
||||
if (radioButton is RadioButton rb) {
|
||||
if (rb.Tag.ToString() == Settings.Startup.UpdateChannel.ToString()) {
|
||||
foreach (var radioButton in UpdateChannelSelector.Items)
|
||||
{
|
||||
if (radioButton is RadioButton rb)
|
||||
{
|
||||
if (rb.Tag.ToString() == Settings.Startup.UpdateChannel.ToString())
|
||||
{
|
||||
rb.IsChecked = true;
|
||||
break;
|
||||
}
|
||||
@@ -110,7 +137,9 @@ namespace Ink_Canvas {
|
||||
AutoUpdateWithSilenceEndTimeComboBox.SelectedItem = Settings.Startup.AutoUpdateWithSilenceEndTime;
|
||||
|
||||
ToggleSwitchFoldAtStartup.IsOn = Settings.Startup.IsFoldAtStartup;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Startup = new Startup();
|
||||
}
|
||||
|
||||
@@ -131,11 +160,15 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// Appearance
|
||||
if (Settings.Appearance != null) {
|
||||
if (!Settings.Appearance.IsEnableDisPlayNibModeToggler) {
|
||||
if (Settings.Appearance != null)
|
||||
{
|
||||
if (!Settings.Appearance.IsEnableDisPlayNibModeToggler)
|
||||
{
|
||||
NibModeSimpleStackPanel.Visibility = Visibility.Collapsed;
|
||||
BoardNibModeSimpleStackPanel.Visibility = Visibility.Collapsed;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
NibModeSimpleStackPanel.Visibility = Visibility.Visible;
|
||||
BoardNibModeSimpleStackPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
@@ -175,7 +208,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
ComboBoxUnFoldBtnImg.SelectedIndex = Settings.Appearance.UnFoldButtonImageType;
|
||||
switch (Settings.Appearance.UnFoldButtonImageType) {
|
||||
switch (Settings.Appearance.UnFoldButtonImageType)
|
||||
{
|
||||
case 0:
|
||||
RightUnFoldBtnImgChevron.Source =
|
||||
new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/unfold-chevron.png"));
|
||||
@@ -224,7 +258,9 @@ namespace Ink_Canvas {
|
||||
//ViewboxBlackboardRightSideScaleTransform.ScaleY = 0.8;
|
||||
|
||||
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//ViewboxBlackboardLeftSideScaleTransform.ScaleX = 1;
|
||||
//ViewboxBlackboardLeftSideScaleTransform.ScaleY = 1;
|
||||
ViewboxBlackboardCenterSideScaleTransform.ScaleX = 1;
|
||||
@@ -235,9 +271,12 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn = false;
|
||||
}
|
||||
|
||||
if (Settings.Appearance.IsTransparentButtonBackground) {
|
||||
if (Settings.Appearance.IsTransparentButtonBackground)
|
||||
{
|
||||
BtnExit.Background = new SolidColorBrush(StringToColor("#7F909090"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//Light
|
||||
BtnExit.Background = BtnSwitchTheme.Content.ToString() == "深色"
|
||||
? new SolidColorBrush(StringToColor("#FFCCCCCC"))
|
||||
@@ -248,16 +287,16 @@ namespace Ink_Canvas {
|
||||
|
||||
// 更新自定义图标下拉列表
|
||||
UpdateCustomIconsInComboBox();
|
||||
|
||||
|
||||
// 设置选中的图标索引
|
||||
// 如果索引超出范围(自定义图标可能已删除),使用默认图标
|
||||
if (Settings.Appearance.FloatingBarImg >= ComboBoxFloatingBarImg.Items.Count)
|
||||
{
|
||||
Settings.Appearance.FloatingBarImg = 0;
|
||||
}
|
||||
|
||||
|
||||
ComboBoxFloatingBarImg.SelectedIndex = Settings.Appearance.FloatingBarImg;
|
||||
|
||||
|
||||
// 更新浮动栏图标
|
||||
UpdateFloatingBarIcon();
|
||||
|
||||
@@ -268,18 +307,24 @@ namespace Ink_Canvas {
|
||||
Settings.Appearance.EnableChickenSoupInWhiteboardMode;
|
||||
|
||||
SystemEvents_UserPreferenceChanged(null, null);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Appearance = new Appearance();
|
||||
}
|
||||
|
||||
// PowerPointSettings
|
||||
if (Settings.PowerPointSettings != null) {
|
||||
|
||||
|
||||
if (Settings.PowerPointSettings.PowerPointSupport) {
|
||||
if (Settings.PowerPointSettings != null)
|
||||
{
|
||||
|
||||
|
||||
if (Settings.PowerPointSettings.PowerPointSupport)
|
||||
{
|
||||
ToggleSwitchSupportPowerPoint.IsOn = true;
|
||||
// PPT监控将在Window_Loaded中启动
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleSwitchSupportPowerPoint.IsOn = false;
|
||||
// PPT监控将保持停止状态
|
||||
}
|
||||
@@ -306,12 +351,15 @@ namespace Ink_Canvas {
|
||||
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
|
||||
var dopsc = dops.ToCharArray();
|
||||
if ((dopsc[0] == '1' || dopsc[0] == '2') && (dopsc[1] == '1' || dopsc[1] == '2') &&
|
||||
(dopsc[2] == '1' || dopsc[2] == '2') && (dopsc[3] == '1' || dopsc[3] == '2')) {
|
||||
(dopsc[2] == '1' || dopsc[2] == '2') && (dopsc[3] == '1' || dopsc[3] == '2'))
|
||||
{
|
||||
CheckboxEnableLBPPTButton.IsChecked = dopsc[0] == '2';
|
||||
CheckboxEnableRBPPTButton.IsChecked = dopsc[1] == '2';
|
||||
CheckboxEnableLSPPTButton.IsChecked = dopsc[2] == '2';
|
||||
CheckboxEnableRSPPTButton.IsChecked = dopsc[3] == '2';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.PowerPointSettings.PPTButtonsDisplayOption = 2222;
|
||||
CheckboxEnableLBPPTButton.IsChecked = true;
|
||||
CheckboxEnableRBPPTButton.IsChecked = true;
|
||||
@@ -376,12 +424,15 @@ namespace Ink_Canvas {
|
||||
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint;
|
||||
ToggleSwitchEnableWppProcessKill.IsOn = Settings.PowerPointSettings.EnableWppProcessKill;
|
||||
ToggleSwitchAlwaysGoToFirstPageOnReenter.IsOn = Settings.PowerPointSettings.IsAlwaysGoToFirstPageOnReenter;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.PowerPointSettings = new PowerPointSettings();
|
||||
}
|
||||
|
||||
// Gesture
|
||||
if (Settings.Gesture != null) {
|
||||
if (Settings.Gesture != null)
|
||||
{
|
||||
ToggleSwitchEnableMultiTouchMode.IsOn = Settings.Gesture.IsEnableMultiTouchMode;
|
||||
|
||||
ToggleSwitchEnableTwoFingerZoom.IsOn = Settings.Gesture.IsEnableTwoFingerZoom;
|
||||
@@ -400,13 +451,17 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchEnableTwoFingerRotationOnSelection.IsOn =
|
||||
Settings.Gesture.IsEnableTwoFingerRotationOnSelection;
|
||||
|
||||
if (Settings.Gesture.AutoSwitchTwoFingerGesture) {
|
||||
if (Topmost) {
|
||||
if (Settings.Gesture.AutoSwitchTwoFingerGesture)
|
||||
{
|
||||
if (Topmost)
|
||||
{
|
||||
ToggleSwitchEnableTwoFingerTranslate.IsOn = false;
|
||||
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = false;
|
||||
Settings.Gesture.IsEnableTwoFingerTranslate = false;
|
||||
if (!isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleSwitchEnableTwoFingerTranslate.IsOn = true;
|
||||
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = true;
|
||||
Settings.Gesture.IsEnableTwoFingerTranslate = true;
|
||||
@@ -415,12 +470,15 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
CheckEnableTwoFingerGestureBtnColorPrompt();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Gesture = new Gesture();
|
||||
}
|
||||
|
||||
// Canvas
|
||||
if (Settings.Canvas != null) {
|
||||
if (Settings.Canvas != null)
|
||||
{
|
||||
drawingAttributes.Height = Settings.Canvas.InkWidth;
|
||||
drawingAttributes.Width = Settings.Canvas.InkWidth;
|
||||
|
||||
@@ -429,13 +487,16 @@ namespace Ink_Canvas {
|
||||
|
||||
ComboBoxHyperbolaAsymptoteOption.SelectedIndex = (int)Settings.Canvas.HyperbolaAsymptoteOption;
|
||||
|
||||
if (Settings.Canvas.UsingWhiteboard) {
|
||||
if (Settings.Canvas.UsingWhiteboard)
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(Color.FromRgb(234, 235, 237));
|
||||
WaterMarkTime.Foreground = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
WaterMarkDate.Foreground = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
BlackBoardWaterMark.Foreground = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
isUselightThemeColor = false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
GridBackgroundCover.Background = new SolidColorBrush(Color.FromRgb(22, 41, 36));
|
||||
WaterMarkTime.Foreground = new SolidColorBrush(Color.FromRgb(234, 235, 237));
|
||||
WaterMarkDate.Foreground = new SolidColorBrush(Color.FromRgb(234, 235, 237));
|
||||
@@ -443,17 +504,20 @@ namespace Ink_Canvas {
|
||||
isUselightThemeColor = true;
|
||||
}
|
||||
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
if (Settings.Canvas.IsShowCursor)
|
||||
{
|
||||
ToggleSwitchShowCursor.IsOn = true;
|
||||
inkCanvas.ForceCursor = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleSwitchShowCursor.IsOn = false;
|
||||
inkCanvas.ForceCursor = false;
|
||||
}
|
||||
|
||||
// 初始化压感触屏模式开关状态
|
||||
ToggleSwitchEnablePressureTouchMode.IsOn = Settings.Canvas.EnablePressureTouchMode;
|
||||
|
||||
|
||||
// 初始化屏蔽压感开关状态
|
||||
ToggleSwitchDisablePressure.IsOn = Settings.Canvas.DisablePressure;
|
||||
|
||||
@@ -468,49 +532,54 @@ namespace Ink_Canvas {
|
||||
Settings.Canvas.ClearCanvasAndClearTimeMachine;
|
||||
ToggleSwitchClearCanvasAlsoClearImages.IsOn = Settings.Canvas.ClearCanvasAlsoClearImages;
|
||||
|
||||
switch (Settings.Canvas.EraserShapeType) {
|
||||
case 0: {
|
||||
double k = 1;
|
||||
switch (Settings.Canvas.EraserSize) {
|
||||
case 0:
|
||||
k = 0.5;
|
||||
break;
|
||||
case 1:
|
||||
k = 0.8;
|
||||
break;
|
||||
case 3:
|
||||
k = 1.25;
|
||||
break;
|
||||
case 4:
|
||||
k = 1.5;
|
||||
break;
|
||||
}
|
||||
switch (Settings.Canvas.EraserShapeType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
double k = 1;
|
||||
switch (Settings.Canvas.EraserSize)
|
||||
{
|
||||
case 0:
|
||||
k = 0.5;
|
||||
break;
|
||||
case 1:
|
||||
k = 0.8;
|
||||
break;
|
||||
case 3:
|
||||
k = 1.25;
|
||||
break;
|
||||
case 4:
|
||||
k = 1.5;
|
||||
break;
|
||||
}
|
||||
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
double k = 1;
|
||||
switch (Settings.Canvas.EraserSize) {
|
||||
case 0:
|
||||
k = 0.7;
|
||||
break;
|
||||
case 1:
|
||||
k = 0.9;
|
||||
break;
|
||||
case 3:
|
||||
k = 1.2;
|
||||
break;
|
||||
case 4:
|
||||
k = 1.5;
|
||||
break;
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
double k = 1;
|
||||
switch (Settings.Canvas.EraserSize)
|
||||
{
|
||||
case 0:
|
||||
k = 0.7;
|
||||
break;
|
||||
case 1:
|
||||
k = 0.9;
|
||||
break;
|
||||
case 3:
|
||||
k = 1.2;
|
||||
break;
|
||||
case 4:
|
||||
k = 1.5;
|
||||
break;
|
||||
}
|
||||
|
||||
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
break;
|
||||
}
|
||||
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CheckEraserTypeTab();
|
||||
@@ -556,7 +625,7 @@ namespace Ink_Canvas {
|
||||
// 可以添加提示文本说明硬件加速不可用
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// 初始化直线自动拉直相关设置
|
||||
ToggleSwitchAutoStraightenLine.IsOn = Settings.Canvas.AutoStraightenLine;
|
||||
AutoStraightenLineThresholdSlider.Value = Settings.Canvas.AutoStraightenLineThreshold;
|
||||
@@ -564,21 +633,25 @@ namespace Ink_Canvas {
|
||||
LineStraightenSensitivitySlider.Value = Settings.InkToShape.LineStraightenSensitivity;
|
||||
// 初始化高精度直线拉直设置
|
||||
ToggleSwitchHighPrecisionLineStraighten.IsOn = Settings.Canvas.HighPrecisionLineStraighten;
|
||||
|
||||
|
||||
// 初始化直线端点吸附相关设置
|
||||
ToggleSwitchLineEndpointSnapping.IsOn = Settings.Canvas.LineEndpointSnapping;
|
||||
ToggleSwitchCompressPicturesUploaded.IsOn = Settings.Canvas.IsCompressPicturesUploaded;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Canvas = new Canvas();
|
||||
}
|
||||
|
||||
// Palm Eraser
|
||||
if (Settings.Canvas != null) {
|
||||
if (Settings.Canvas != null)
|
||||
{
|
||||
ToggleSwitchEnablePalmEraser.IsOn = Settings.Canvas.EnablePalmEraser;
|
||||
}
|
||||
|
||||
// Advanced
|
||||
if (Settings.Advanced != null) {
|
||||
if (Settings.Advanced != null)
|
||||
{
|
||||
TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier;
|
||||
FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth;
|
||||
NibModeBoundsWidthSlider.Value = Settings.Advanced.NibModeBoundsWidth;
|
||||
@@ -595,25 +668,30 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchIsEnableDPIChangeDetection.IsOn = Settings.Advanced.IsEnableDPIChangeDetection;
|
||||
ToggleSwitchIsEnableAvoidFullScreenHelper.IsOn = Settings.Advanced.IsEnableAvoidFullScreenHelper;
|
||||
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
|
||||
if (Settings.Advanced.IsEnableFullScreenHelper) {
|
||||
if (Settings.Advanced.IsEnableFullScreenHelper)
|
||||
{
|
||||
FullScreenHelper.MarkFullscreenWindowTaskbarList(new WindowInteropHelper(this).Handle, true);
|
||||
}
|
||||
if (Settings.Advanced.IsEnableAvoidFullScreenHelper)
|
||||
{
|
||||
AvoidFullScreenHelper.StartAvoidFullScreen(this);
|
||||
}
|
||||
if (Settings.Advanced.IsEnableEdgeGestureUtil) {
|
||||
if (Settings.Advanced.IsEnableEdgeGestureUtil)
|
||||
{
|
||||
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10)
|
||||
EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, true);
|
||||
}
|
||||
TouchMultiplierSlider.Visibility =
|
||||
ToggleSwitchIsSpecialScreen.IsOn ? Visibility.Visible : Visibility.Collapsed;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Advanced = new Advanced();
|
||||
}
|
||||
|
||||
// InkToShape
|
||||
if (Settings.InkToShape != null) {
|
||||
if (Settings.InkToShape != null)
|
||||
{
|
||||
ToggleSwitchEnableInkToShape.IsOn = Settings.InkToShape.IsInkToShapeEnabled;
|
||||
|
||||
ToggleSwitchEnableInkToShapeNoFakePressureRectangle.IsOn =
|
||||
@@ -627,14 +705,17 @@ namespace Ink_Canvas {
|
||||
ToggleCheckboxEnableInkToShapeRectangle.IsChecked = Settings.InkToShape.IsInkToShapeRectangle;
|
||||
|
||||
ToggleCheckboxEnableInkToShapeRounded.IsChecked = Settings.InkToShape.IsInkToShapeRounded;
|
||||
|
||||
|
||||
// 直线拉直灵敏度在Canvas部分已经初始化,这里不再重复
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.InkToShape = new InkToShape();
|
||||
}
|
||||
|
||||
// RandSettings
|
||||
if (Settings.RandSettings != null) {
|
||||
if (Settings.RandSettings != null)
|
||||
{
|
||||
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
|
||||
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
|
||||
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
|
||||
@@ -642,17 +723,19 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchDirectCallCiRand.IsOn = Settings.RandSettings.DirectCallCiRand;
|
||||
RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
|
||||
SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
|
||||
// 加载自定义点名背景
|
||||
UpdatePickNameBackgroundsInComboBox();
|
||||
|
||||
|
||||
// 设置选择的背景索引
|
||||
if (Settings.RandSettings.SelectedBackgroundIndex >= ComboBoxPickNameBackground.Items.Count)
|
||||
{
|
||||
Settings.RandSettings.SelectedBackgroundIndex = 0;
|
||||
}
|
||||
ComboBoxPickNameBackground.SelectedIndex = Settings.RandSettings.SelectedBackgroundIndex;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.RandSettings = new RandSettings();
|
||||
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
|
||||
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
|
||||
@@ -661,7 +744,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// Automation
|
||||
if (Settings.Automation != null) {
|
||||
if (Settings.Automation != null)
|
||||
{
|
||||
StartOrStoptimerCheckAutoFold();
|
||||
ToggleSwitchAutoFoldInEasiNote.IsOn = Settings.Automation.IsAutoFoldInEasiNote;
|
||||
|
||||
@@ -698,12 +782,13 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchAutoFoldInMaxHubWhiteboard.IsOn = Settings.Automation.IsAutoFoldInMaxHubWhiteboard;
|
||||
|
||||
SettingsPPTInkingAndAutoFoldExplictBorder.Visibility = Visibility.Collapsed;
|
||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow) {
|
||||
if (Settings.Automation.IsAutoFoldInPPTSlideShow)
|
||||
{
|
||||
SettingsPPTInkingAndAutoFoldExplictBorder.Visibility = Visibility.Visible;
|
||||
SettingsShowCanvasAtNewSlideShowStackPanel.Opacity = 0.5;
|
||||
SettingsShowCanvasAtNewSlideShowStackPanel.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ToggleSwitchAutoFoldInPPTSlideShow.IsOn = Settings.Automation.IsAutoFoldInPPTSlideShow;
|
||||
|
||||
@@ -713,9 +798,12 @@ namespace Ink_Canvas {
|
||||
Settings.Automation.IsAutoKillHiteAnnotation || Settings.Automation.IsAutoKillInkCanvas
|
||||
|| Settings.Automation.IsAutoKillICA || Settings.Automation.IsAutoKillIDT ||
|
||||
Settings.Automation.IsAutoKillVComYouJiao
|
||||
|| Settings.Automation.IsAutoKillSeewoLauncher2DesktopAnnotation) {
|
||||
|| Settings.Automation.IsAutoKillSeewoLauncher2DesktopAnnotation)
|
||||
{
|
||||
timerKillProcess.Start();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
timerKillProcess.Stop();
|
||||
}
|
||||
|
||||
@@ -741,7 +829,7 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchSaveScreenshotsInDateFolders.IsOn = Settings.Automation.IsSaveScreenshotsInDateFolders;
|
||||
|
||||
ToggleSwitchAutoSaveStrokesAtScreenshot.IsOn = Settings.Automation.IsAutoSaveStrokesAtScreenshot;
|
||||
|
||||
|
||||
ToggleSwitchSaveFullPageStrokes.IsOn = Settings.Automation.IsSaveFullPageStrokes;
|
||||
|
||||
SideControlMinimumAutomationSlider.Value = Settings.Automation.MinimumAutomationStrokeNumber;
|
||||
@@ -750,17 +838,22 @@ namespace Ink_Canvas {
|
||||
ToggleSwitchAutoDelSavedFiles.IsOn = Settings.Automation.AutoDelSavedFiles;
|
||||
ComboBoxAutoDelSavedFilesDaysThreshold.Text =
|
||||
Settings.Automation.AutoDelSavedFilesDaysThreshold.ToString();
|
||||
|
||||
|
||||
// 加载退出收纳模式自动切换至批注模式设置
|
||||
ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode.IsOn = Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Automation = new Automation();
|
||||
}
|
||||
|
||||
// auto align
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewboxFloatingBarMarginAnimation(100, true);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
@@ -6,11 +7,13 @@ using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
private enum CommitReason {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private enum CommitReason
|
||||
{
|
||||
UserInput,
|
||||
CodeInput,
|
||||
ShapeDrawing,
|
||||
@@ -44,25 +47,34 @@ namespace Ink_Canvas {
|
||||
|
||||
private TimeMachine timeMachine = new TimeMachine();
|
||||
|
||||
private void ApplyHistoryToCanvas(TimeMachineHistory item, InkCanvas applyCanvas = null) {
|
||||
private void ApplyHistoryToCanvas(TimeMachineHistory item, InkCanvas applyCanvas = null)
|
||||
{
|
||||
_currentCommitType = CommitReason.CodeInput;
|
||||
var canvas = inkCanvas;
|
||||
if (applyCanvas != null && applyCanvas is InkCanvas) {
|
||||
if (applyCanvas != null && applyCanvas is InkCanvas)
|
||||
{
|
||||
canvas = applyCanvas;
|
||||
}
|
||||
|
||||
if (item.CommitType == TimeMachineHistoryType.UserInput) {
|
||||
if (!item.StrokeHasBeenCleared) {
|
||||
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
||||
{
|
||||
if (!item.StrokeHasBeenCleared)
|
||||
{
|
||||
foreach (var strokes in item.CurrentStroke)
|
||||
if (!canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Add(strokes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var strokes in item.CurrentStroke)
|
||||
if (canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Remove(strokes);
|
||||
}
|
||||
} else if (item.CommitType == TimeMachineHistoryType.ShapeRecognition) {
|
||||
if (item.StrokeHasBeenCleared) {
|
||||
}
|
||||
else if (item.CommitType == TimeMachineHistoryType.ShapeRecognition)
|
||||
{
|
||||
if (item.StrokeHasBeenCleared)
|
||||
{
|
||||
foreach (var strokes in item.CurrentStroke)
|
||||
if (canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Remove(strokes);
|
||||
@@ -70,7 +82,9 @@ namespace Ink_Canvas {
|
||||
foreach (var strokes in item.ReplacedStroke)
|
||||
if (!canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Add(strokes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var strokes in item.CurrentStroke)
|
||||
if (!canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Add(strokes);
|
||||
@@ -79,36 +93,57 @@ namespace Ink_Canvas {
|
||||
if (canvas.Strokes.Contains(strokes))
|
||||
canvas.Strokes.Remove(strokes);
|
||||
}
|
||||
} else if (item.CommitType == TimeMachineHistoryType.Manipulation) {
|
||||
if (!item.StrokeHasBeenCleared) {
|
||||
foreach (var currentStroke in item.StylusPointDictionary) {
|
||||
if (canvas.Strokes.Contains(currentStroke.Key)) {
|
||||
}
|
||||
else if (item.CommitType == TimeMachineHistoryType.Manipulation)
|
||||
{
|
||||
if (!item.StrokeHasBeenCleared)
|
||||
{
|
||||
foreach (var currentStroke in item.StylusPointDictionary)
|
||||
{
|
||||
if (canvas.Strokes.Contains(currentStroke.Key))
|
||||
{
|
||||
currentStroke.Key.StylusPoints = currentStroke.Value.Item2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (var currentStroke in item.StylusPointDictionary) {
|
||||
if (canvas.Strokes.Contains(currentStroke.Key)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var currentStroke in item.StylusPointDictionary)
|
||||
{
|
||||
if (canvas.Strokes.Contains(currentStroke.Key))
|
||||
{
|
||||
currentStroke.Key.StylusPoints = currentStroke.Value.Item1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (item.CommitType == TimeMachineHistoryType.DrawingAttributes) {
|
||||
if (!item.StrokeHasBeenCleared) {
|
||||
foreach (var currentStroke in item.DrawingAttributes) {
|
||||
if (canvas.Strokes.Contains(currentStroke.Key)) {
|
||||
}
|
||||
else if (item.CommitType == TimeMachineHistoryType.DrawingAttributes)
|
||||
{
|
||||
if (!item.StrokeHasBeenCleared)
|
||||
{
|
||||
foreach (var currentStroke in item.DrawingAttributes)
|
||||
{
|
||||
if (canvas.Strokes.Contains(currentStroke.Key))
|
||||
{
|
||||
currentStroke.Key.DrawingAttributes = currentStroke.Value.Item2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (var currentStroke in item.DrawingAttributes) {
|
||||
if (canvas.Strokes.Contains(currentStroke.Key)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var currentStroke in item.DrawingAttributes)
|
||||
{
|
||||
if (canvas.Strokes.Contains(currentStroke.Key))
|
||||
{
|
||||
currentStroke.Key.DrawingAttributes = currentStroke.Value.Item1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (item.CommitType == TimeMachineHistoryType.Clear) {
|
||||
if (!item.StrokeHasBeenCleared) {
|
||||
}
|
||||
else if (item.CommitType == TimeMachineHistoryType.Clear)
|
||||
{
|
||||
if (!item.StrokeHasBeenCleared)
|
||||
{
|
||||
if (item.CurrentStroke != null)
|
||||
foreach (var currentStroke in item.CurrentStroke)
|
||||
if (!canvas.Strokes.Contains(currentStroke))
|
||||
@@ -118,7 +153,9 @@ namespace Ink_Canvas {
|
||||
foreach (var replacedStroke in item.ReplacedStroke)
|
||||
if (canvas.Strokes.Contains(replacedStroke))
|
||||
canvas.Strokes.Remove(replacedStroke);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.ReplacedStroke != null)
|
||||
foreach (var replacedStroke in item.ReplacedStroke)
|
||||
if (!canvas.Strokes.Contains(replacedStroke))
|
||||
@@ -129,29 +166,39 @@ namespace Ink_Canvas {
|
||||
if (canvas.Strokes.Contains(currentStroke))
|
||||
canvas.Strokes.Remove(currentStroke);
|
||||
}
|
||||
} else if (item.CommitType == TimeMachineHistoryType.ElementInsert) {
|
||||
}
|
||||
else if (item.CommitType == TimeMachineHistoryType.ElementInsert)
|
||||
{
|
||||
// 使用传入的canvas参数,而不是总是使用inkCanvas
|
||||
var targetCanvas = canvas ?? inkCanvas;
|
||||
|
||||
if (item.StrokeHasBeenCleared) {
|
||||
if (item.StrokeHasBeenCleared)
|
||||
{
|
||||
// Undo: 移除元素
|
||||
if (item.InsertedElement != null && targetCanvas.Children.Contains(item.InsertedElement))
|
||||
targetCanvas.Children.Remove(item.InsertedElement);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redo: 添加元素
|
||||
if (item.InsertedElement != null && !targetCanvas.Children.Contains(item.InsertedElement)) {
|
||||
if (item.InsertedElement != null && !targetCanvas.Children.Contains(item.InsertedElement))
|
||||
{
|
||||
targetCanvas.Children.Add(item.InsertedElement);
|
||||
|
||||
// 重新绑定事件处理器(仅对主画布)
|
||||
if (targetCanvas == inkCanvas) {
|
||||
if (item.InsertedElement is Image img) {
|
||||
if (targetCanvas == inkCanvas)
|
||||
{
|
||||
if (item.InsertedElement is Image img)
|
||||
{
|
||||
img.MouseDown -= UIElement_MouseDown;
|
||||
img.MouseDown += UIElement_MouseDown;
|
||||
img.IsManipulationEnabled = true;
|
||||
|
||||
// 重新应用CenterAndScaleElement变换
|
||||
CenterAndScaleElement(img);
|
||||
} else if (item.InsertedElement is MediaElement media) {
|
||||
}
|
||||
else if (item.InsertedElement is MediaElement media)
|
||||
{
|
||||
media.MouseDown -= UIElement_MouseDown;
|
||||
media.MouseDown += UIElement_MouseDown;
|
||||
media.IsManipulationEnabled = true;
|
||||
@@ -167,18 +214,23 @@ namespace Ink_Canvas {
|
||||
_currentCommitType = CommitReason.UserInput;
|
||||
}
|
||||
|
||||
private StrokeCollection ApplyHistoriesToNewStrokeCollection(TimeMachineHistory[] items) {
|
||||
InkCanvas fakeInkCanv = new InkCanvas {
|
||||
private StrokeCollection ApplyHistoriesToNewStrokeCollection(TimeMachineHistory[] items)
|
||||
{
|
||||
InkCanvas fakeInkCanv = new InkCanvas
|
||||
{
|
||||
Width = inkCanvas.ActualWidth,
|
||||
Height = inkCanvas.ActualHeight,
|
||||
EditingMode = InkCanvasEditingMode.None,
|
||||
};
|
||||
|
||||
if (items != null && items.Length > 0) {
|
||||
foreach (var timeMachineHistory in items) {
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (var timeMachineHistory in items)
|
||||
{
|
||||
// 只处理笔画历史,不处理图片元素历史
|
||||
// 因为页面预览只需要显示笔画,图片元素会影响主画布
|
||||
if (timeMachineHistory.CommitType != TimeMachineHistoryType.ElementInsert) {
|
||||
if (timeMachineHistory.CommitType != TimeMachineHistoryType.ElementInsert)
|
||||
{
|
||||
ApplyHistoryToCanvas(timeMachineHistory, fakeInkCanv);
|
||||
}
|
||||
}
|
||||
@@ -188,14 +240,18 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 新增:获取页面的所有图片元素
|
||||
private List<UIElement> GetPageImageElements(TimeMachineHistory[] items) {
|
||||
private List<UIElement> GetPageImageElements(TimeMachineHistory[] items)
|
||||
{
|
||||
var imageElements = new List<UIElement>();
|
||||
|
||||
if (items != null && items.Length > 0) {
|
||||
foreach (var timeMachineHistory in items) {
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (var timeMachineHistory in items)
|
||||
{
|
||||
if (timeMachineHistory.CommitType == TimeMachineHistoryType.ElementInsert &&
|
||||
timeMachineHistory.InsertedElement != null &&
|
||||
!timeMachineHistory.StrokeHasBeenCleared) {
|
||||
!timeMachineHistory.StrokeHasBeenCleared)
|
||||
{
|
||||
imageElements.Add(timeMachineHistory.InsertedElement);
|
||||
}
|
||||
}
|
||||
@@ -204,32 +260,38 @@ namespace Ink_Canvas {
|
||||
return imageElements;
|
||||
}
|
||||
|
||||
private void TimeMachine_OnUndoStateChanged(bool status) {
|
||||
private void TimeMachine_OnUndoStateChanged(bool status)
|
||||
{
|
||||
var result = status ? Visibility.Visible : Visibility.Collapsed;
|
||||
BtnUndo.Visibility = result;
|
||||
BtnUndo.IsEnabled = status;
|
||||
}
|
||||
|
||||
private void TimeMachine_OnRedoStateChanged(bool status) {
|
||||
private void TimeMachine_OnRedoStateChanged(bool status)
|
||||
{
|
||||
var result = status ? Visibility.Visible : Visibility.Collapsed;
|
||||
BtnRedo.Visibility = result;
|
||||
BtnRedo.IsEnabled = status;
|
||||
}
|
||||
|
||||
private void StrokesOnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e) {
|
||||
if (!isHidingSubPanelsWhenInking) {
|
||||
private void StrokesOnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
|
||||
{
|
||||
if (!isHidingSubPanelsWhenInking)
|
||||
{
|
||||
isHidingSubPanelsWhenInking = true;
|
||||
HideSubPanels(); // 书写时自动隐藏二级菜单
|
||||
}
|
||||
|
||||
foreach (var stroke in e?.Removed) {
|
||||
foreach (var stroke in e?.Removed)
|
||||
{
|
||||
stroke.StylusPointsChanged -= Stroke_StylusPointsChanged;
|
||||
stroke.StylusPointsReplaced -= Stroke_StylusPointsReplaced;
|
||||
stroke.DrawingAttributesChanged -= Stroke_DrawingAttributesChanged;
|
||||
StrokeInitialHistory.Remove(stroke);
|
||||
}
|
||||
|
||||
foreach (var stroke in e?.Added) {
|
||||
foreach (var stroke in e?.Added)
|
||||
{
|
||||
stroke.StylusPointsChanged += Stroke_StylusPointsChanged;
|
||||
stroke.StylusPointsReplaced += Stroke_StylusPointsReplaced;
|
||||
stroke.DrawingAttributesChanged += Stroke_DrawingAttributesChanged;
|
||||
@@ -238,7 +300,8 @@ namespace Ink_Canvas {
|
||||
|
||||
if (_currentCommitType == CommitReason.CodeInput || _currentCommitType == CommitReason.ShapeDrawing) return;
|
||||
|
||||
if ((e.Added.Count != 0 || e.Removed.Count != 0) && IsEraseByPoint) {
|
||||
if ((e.Added.Count != 0 || e.Removed.Count != 0) && IsEraseByPoint)
|
||||
{
|
||||
if (AddedStroke == null) AddedStroke = new StrokeCollection();
|
||||
if (ReplacedStroke == null) ReplacedStroke = new StrokeCollection();
|
||||
AddedStroke.Add(e.Added);
|
||||
@@ -248,7 +311,8 @@ namespace Ink_Canvas {
|
||||
|
||||
if (e.Added.Count != 0)
|
||||
{
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition)
|
||||
{
|
||||
timeMachine.CommitStrokeShapeHistory(ReplacedStroke, e.Added);
|
||||
ReplacedStroke = null;
|
||||
return;
|
||||
@@ -258,51 +322,64 @@ namespace Ink_Canvas {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Removed.Count != 0) {
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition) {
|
||||
if (e.Removed.Count != 0)
|
||||
{
|
||||
if (_currentCommitType == CommitReason.ShapeRecognition)
|
||||
{
|
||||
ReplacedStroke = e.Removed;
|
||||
} else if (!IsEraseByPoint || _currentCommitType == CommitReason.ClearingCanvas) {
|
||||
}
|
||||
else if (!IsEraseByPoint || _currentCommitType == CommitReason.ClearingCanvas)
|
||||
{
|
||||
timeMachine.CommitStrokeEraseHistory(e.Removed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Stroke_DrawingAttributesChanged(object sender, PropertyDataChangedEventArgs e) {
|
||||
private void Stroke_DrawingAttributesChanged(object sender, PropertyDataChangedEventArgs e)
|
||||
{
|
||||
var key = sender as Stroke;
|
||||
var currentValue = key.DrawingAttributes.Clone();
|
||||
DrawingAttributesHistory.TryGetValue(key, out var previousTuple);
|
||||
var previousValue = previousTuple?.Item1 ?? currentValue.Clone();
|
||||
var needUpdateValue = !DrawingAttributesHistoryFlag[e.PropertyGuid].Contains(key);
|
||||
if (needUpdateValue) {
|
||||
if (needUpdateValue)
|
||||
{
|
||||
DrawingAttributesHistoryFlag[e.PropertyGuid].Add(key);
|
||||
Debug.Write(e.PreviousValue.ToString());
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.Color && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.Color && needUpdateValue)
|
||||
{
|
||||
previousValue.Color = (Color)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.IsHighlighter && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.IsHighlighter && needUpdateValue)
|
||||
{
|
||||
previousValue.IsHighlighter = (bool)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusHeight && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusHeight && needUpdateValue)
|
||||
{
|
||||
previousValue.Height = (double)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusWidth && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusWidth && needUpdateValue)
|
||||
{
|
||||
previousValue.Width = (double)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusTip && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusTip && needUpdateValue)
|
||||
{
|
||||
previousValue.StylusTip = (StylusTip)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusTipTransform && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.StylusTipTransform && needUpdateValue)
|
||||
{
|
||||
previousValue.StylusTipTransform = (Matrix)e.PreviousValue;
|
||||
}
|
||||
|
||||
if (e.PropertyGuid == DrawingAttributeIds.DrawingFlags && needUpdateValue) {
|
||||
if (e.PropertyGuid == DrawingAttributeIds.DrawingFlags && needUpdateValue)
|
||||
{
|
||||
previousValue.IgnorePressure = (bool)e.PreviousValue;
|
||||
}
|
||||
|
||||
@@ -310,15 +387,18 @@ namespace Ink_Canvas {
|
||||
new Tuple<DrawingAttributes, DrawingAttributes>(previousValue, currentValue);
|
||||
}
|
||||
|
||||
private void Stroke_StylusPointsReplaced(object sender, StylusPointsReplacedEventArgs e) {
|
||||
private void Stroke_StylusPointsReplaced(object sender, StylusPointsReplacedEventArgs e)
|
||||
{
|
||||
StrokeInitialHistory[sender as Stroke] = e.NewStylusPoints.Clone();
|
||||
}
|
||||
|
||||
private void Stroke_StylusPointsChanged(object sender, EventArgs e) {
|
||||
private void Stroke_StylusPointsChanged(object sender, EventArgs e)
|
||||
{
|
||||
var selectedStrokes = inkCanvas.GetSelectedStrokes();
|
||||
var count = selectedStrokes.Count;
|
||||
if (count == 0) count = inkCanvas.Strokes.Count;
|
||||
if (StrokeManipulationHistory == null) {
|
||||
if (StrokeManipulationHistory == null)
|
||||
{
|
||||
StrokeManipulationHistory =
|
||||
new Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>>();
|
||||
}
|
||||
@@ -326,9 +406,11 @@ namespace Ink_Canvas {
|
||||
StrokeManipulationHistory[sender as Stroke] =
|
||||
new Tuple<StylusPointCollection, StylusPointCollection>(StrokeInitialHistory[sender as Stroke],
|
||||
(sender as Stroke).StylusPoints.Clone());
|
||||
if ((StrokeManipulationHistory.Count == count || sender == null) && dec.Count == 0) {
|
||||
if ((StrokeManipulationHistory.Count == count || sender == null) && dec.Count == 0)
|
||||
{
|
||||
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
|
||||
foreach (var item in StrokeManipulationHistory) {
|
||||
foreach (var item in StrokeManipulationHistory)
|
||||
{
|
||||
StrokeInitialHistory[item.Key] = item.Value.Item2;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@@ -11,27 +12,34 @@ 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 {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public class TimeViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _nowTime;
|
||||
private string _nowDate;
|
||||
|
||||
public string nowTime {
|
||||
public string nowTime
|
||||
{
|
||||
get => _nowTime;
|
||||
set {
|
||||
if (_nowTime != value) {
|
||||
set
|
||||
{
|
||||
if (_nowTime != value)
|
||||
{
|
||||
_nowTime = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string nowDate {
|
||||
public string nowDate
|
||||
{
|
||||
get => _nowDate;
|
||||
set {
|
||||
if (_nowDate != value) {
|
||||
set
|
||||
{
|
||||
if (_nowDate != value)
|
||||
{
|
||||
_nowDate = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
@@ -40,12 +48,14 @@ namespace Ink_Canvas {
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainWindow : Window {
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private Timer timerCheckPPT = new Timer();
|
||||
private Timer timerKillProcess = new Timer();
|
||||
private Timer timerCheckAutoFold = new Timer();
|
||||
@@ -88,7 +98,8 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 修改InitTimers方法中的初始时间和日期格式
|
||||
private void InitTimers() {
|
||||
private void InitTimers()
|
||||
{
|
||||
// PPT检查现在由PPTManager处理,不再需要定时器
|
||||
// timerCheckPPT.Elapsed += TimerCheckPPT_Elapsed;
|
||||
// timerCheckPPT.Interval = 500;
|
||||
@@ -123,27 +134,33 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
// 修改TimerDisplayDate_Elapsed方法中的日期格式
|
||||
private void TimerDisplayDate_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
private void TimerDisplayDate_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
nowTimeVM.nowDate = DateTime.Now.ToString("yyyy'年'MM'月'dd'日' dddd");
|
||||
}
|
||||
|
||||
private void TimerKillProcess_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
try {
|
||||
private void TimerKillProcess_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 希沃相关: easinote swenserver RemoteProcess EasiNote.MediaHttpService smartnote.cloud EasiUpdate smartnote EasiUpdate3 EasiUpdate3Protect SeewoP2P CefSharp.BrowserSubprocess SeewoUploadService
|
||||
var arg = "/F";
|
||||
if (Settings.Automation.IsAutoKillPptService) {
|
||||
if (Settings.Automation.IsAutoKillPptService)
|
||||
{
|
||||
var processes = Process.GetProcessesByName("PPTService");
|
||||
if (processes.Length > 0) arg += " /IM PPTService.exe";
|
||||
processes = Process.GetProcessesByName("SeewoIwbAssistant");
|
||||
if (processes.Length > 0) arg += " /IM SeewoIwbAssistant.exe" + " /IM Sia.Guard.exe";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillEasiNote) {
|
||||
if (Settings.Automation.IsAutoKillEasiNote)
|
||||
{
|
||||
var processes = Process.GetProcessesByName("EasiNote");
|
||||
if (processes.Length > 0) arg += " /IM EasiNote.exe";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillHiteAnnotation) {
|
||||
if (Settings.Automation.IsAutoKillHiteAnnotation)
|
||||
{
|
||||
var processes = Process.GetProcessesByName("HiteAnnotation");
|
||||
if (processes.Length > 0) arg += " /IM HiteAnnotation.exe";
|
||||
}
|
||||
@@ -154,101 +171,123 @@ namespace Ink_Canvas {
|
||||
if (processes.Length > 0) arg += " /IM VcomTeach.exe" + " /IM VcomDaemon.exe" + " /IM VcomRender.exe";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillICA) {
|
||||
if (Settings.Automation.IsAutoKillICA)
|
||||
{
|
||||
var processesAnnotation = Process.GetProcessesByName("Ink Canvas Annotation");
|
||||
var processesArtistry = Process.GetProcessesByName("Ink Canvas Artistry");
|
||||
if (processesAnnotation.Length > 0) arg += " /IM \"Ink Canvas Annotation.exe\"";
|
||||
if (processesArtistry.Length > 0) arg += " /IM \"Ink Canvas Artistry.exe\"";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillInkCanvas) {
|
||||
if (Settings.Automation.IsAutoKillInkCanvas)
|
||||
{
|
||||
var processes = Process.GetProcessesByName("Ink Canvas");
|
||||
if (processes.Length > 0) arg += " /IM \"Ink Canvas.exe\"";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillIDT) {
|
||||
if (Settings.Automation.IsAutoKillIDT)
|
||||
{
|
||||
var processes = Process.GetProcessesByName("Inkeys");
|
||||
if (processes.Length > 0) arg += " /IM \"Inkeys.exe\"";
|
||||
}
|
||||
|
||||
if (Settings.Automation.IsAutoKillSeewoLauncher2DesktopAnnotation) {
|
||||
if (Settings.Automation.IsAutoKillSeewoLauncher2DesktopAnnotation)
|
||||
{
|
||||
//由于希沃桌面2.0提供的桌面批注是64位应用程序,32位程序无法访问,目前暂不做精准匹配,只匹配进程名称,后面会考虑封装一套基于P/Invoke和WMI的综合进程识别方案。
|
||||
var processes = Process.GetProcessesByName("DesktopAnnotation");
|
||||
if (processes.Length > 0) arg += " /IM DesktopAnnotation.exe";
|
||||
}
|
||||
|
||||
if (arg != "/F") {
|
||||
if (arg != "/F")
|
||||
{
|
||||
var p = new Process();
|
||||
p.StartInfo = new ProcessStartInfo("taskkill", arg);
|
||||
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
p.Start();
|
||||
|
||||
if (arg.Contains("EasiNote")) {
|
||||
Dispatcher.Invoke(() => {
|
||||
if (arg.Contains("EasiNote"))
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“希沃白板 5”已自动关闭");
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("HiteAnnotation")) {
|
||||
Dispatcher.Invoke(() => {
|
||||
if (arg.Contains("HiteAnnotation"))
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“鸿合屏幕书写”已自动关闭");
|
||||
if (Settings.Automation.IsAutoKillHiteAnnotation && Settings.Automation.IsAutoEnterAnnotationAfterKillHite) {
|
||||
if (Settings.Automation.IsAutoKillHiteAnnotation && Settings.Automation.IsAutoEnterAnnotationAfterKillHite)
|
||||
{
|
||||
// 自动进入批注状态
|
||||
PenIcon_Click(null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("Ink Canvas Annotation") || arg.Contains("Ink Canvas Artistry")) {
|
||||
Dispatcher.Invoke(() => {
|
||||
if (arg.Contains("Ink Canvas Annotation") || arg.Contains("Ink Canvas Artistry"))
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNewMessage("“ICA”已自动关闭");
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("\"Ink Canvas.exe\"")) {
|
||||
Dispatcher.Invoke(() => {
|
||||
if (arg.Contains("\"Ink Canvas.exe\""))
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“Ink Canvas”已自动关闭");
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("Inkeys")) {
|
||||
Dispatcher.Invoke(() => {
|
||||
if (arg.Contains("Inkeys"))
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“智绘教Inkeys”已自动关闭");
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("VcomTeach"))
|
||||
{
|
||||
Dispatcher.Invoke(() => {
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“优教授课端”已自动关闭");
|
||||
});
|
||||
}
|
||||
|
||||
if (arg.Contains("DesktopAnnotation"))
|
||||
{
|
||||
Dispatcher.Invoke(() => {
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
ShowNotification("“希沃桌面2.0 桌面批注”已自动关闭");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
private bool foldFloatingBarByUser, // 保持收纳操作不受自动收纳的控制
|
||||
unfoldFloatingBarByUser; // 允许用户在希沃软件内进行展开操作
|
||||
|
||||
private void timerCheckAutoFold_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
private void timerCheckAutoFold_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (isFloatingBarChangingHideMode) return;
|
||||
try {
|
||||
try
|
||||
{
|
||||
var windowProcessName = ForegroundWindowInfo.ProcessName();
|
||||
var windowTitle = ForegroundWindowInfo.WindowTitle();
|
||||
//LogHelper.WriteLogToFile("windowTitle | " + windowTitle + " | windowProcessName | " + windowProcessName);
|
||||
|
||||
if (windowProcessName == "EasiNote") {
|
||||
if (windowProcessName == "EasiNote")
|
||||
{
|
||||
// 检测到有可能是EasiNote5或者EasiNote3/3C
|
||||
if (ForegroundWindowInfo.ProcessPath() != "Unknown") {
|
||||
if (ForegroundWindowInfo.ProcessPath() != "Unknown")
|
||||
{
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(ForegroundWindowInfo.ProcessPath());
|
||||
string version = versionInfo.FileVersion;
|
||||
string prodName = versionInfo.ProductName;
|
||||
@@ -256,93 +295,131 @@ namespace Ink_Canvas {
|
||||
Trace.WriteLine(version);
|
||||
Trace.WriteLine(prodName);
|
||||
if (version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote && (!(windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500) ||
|
||||
!Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno)) { // EasiNote5
|
||||
!Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno))
|
||||
{ // EasiNote5
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
} else if (version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3) { // EasiNote3
|
||||
}
|
||||
else if (version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3)
|
||||
{ // EasiNote3
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
} else if (prodName.Contains("3C") && Settings.Automation.IsAutoFoldInEasiNote3C &&
|
||||
}
|
||||
else if (prodName.Contains("3C") && Settings.Automation.IsAutoFoldInEasiNote3C &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) { // EasiNote3C
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{ // EasiNote3C
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
}
|
||||
}
|
||||
// EasiCamera
|
||||
} else if (Settings.Automation.IsAutoFoldInEasiCamera && windowProcessName == "EasiCamera" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInEasiCamera && windowProcessName == "EasiCamera" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// EasiNote5C
|
||||
} else if (Settings.Automation.IsAutoFoldInEasiNote5C && windowProcessName == "EasiNote5C" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInEasiNote5C && windowProcessName == "EasiNote5C" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// SeewoPinco
|
||||
} else if (Settings.Automation.IsAutoFoldInSeewoPincoTeacher && (windowProcessName == "BoardService" || windowProcessName == "seewoPincoTeacher")) {
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInSeewoPincoTeacher && (windowProcessName == "BoardService" || windowProcessName == "seewoPincoTeacher"))
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// HiteCamera
|
||||
} else if (Settings.Automation.IsAutoFoldInHiteCamera && windowProcessName == "HiteCamera" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInHiteCamera && windowProcessName == "HiteCamera" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// HiteTouchPro
|
||||
} else if (Settings.Automation.IsAutoFoldInHiteTouchPro && windowProcessName == "HiteTouchPro" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInHiteTouchPro && windowProcessName == "HiteTouchPro" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// WxBoardMain
|
||||
} else if (Settings.Automation.IsAutoFoldInWxBoardMain && windowProcessName == "WxBoardMain" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInWxBoardMain && windowProcessName == "WxBoardMain" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// MSWhiteboard
|
||||
} else if (Settings.Automation.IsAutoFoldInMSWhiteboard && (windowProcessName == "MicrosoftWhiteboard" ||
|
||||
windowProcessName == "msedgewebview2")) {
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInMSWhiteboard && (windowProcessName == "MicrosoftWhiteboard" ||
|
||||
windowProcessName == "msedgewebview2"))
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// OldZyBoard
|
||||
} else if (Settings.Automation.IsAutoFoldInOldZyBoard && // 中原旧白板
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInOldZyBoard && // 中原旧白板
|
||||
(WinTabWindowsChecker.IsWindowExisted("WhiteBoard - DrawingWindow")
|
||||
|| WinTabWindowsChecker.IsWindowExisted("InstantAnnotationWindow"))) {
|
||||
|| WinTabWindowsChecker.IsWindowExisted("InstantAnnotationWindow")))
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// HiteLightBoard
|
||||
} else if (Settings.Automation.IsAutoFoldInHiteLightBoard && windowProcessName == "HiteLightBoard" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInHiteLightBoard && windowProcessName == "HiteLightBoard" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// AdmoxWhiteboard
|
||||
} else if (Settings.Automation.IsAutoFoldInAdmoxWhiteboard && windowProcessName == "Amdox.WhiteBoard" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInAdmoxWhiteboard && windowProcessName == "Amdox.WhiteBoard" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// AdmoxBooth
|
||||
} else if (Settings.Automation.IsAutoFoldInAdmoxBooth && windowProcessName == "Amdox.Booth" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInAdmoxBooth && windowProcessName == "Amdox.Booth" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// QPoint
|
||||
} else if (Settings.Automation.IsAutoFoldInQPoint && windowProcessName == "QPoint" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInQPoint && windowProcessName == "QPoint" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// YiYunVisualPresenter
|
||||
} else if (Settings.Automation.IsAutoFoldInYiYunVisualPresenter && windowProcessName == "YiYunVisualPresenter" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInYiYunVisualPresenter && windowProcessName == "YiYunVisualPresenter" &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
// MaxHubWhiteboard
|
||||
} else if (Settings.Automation.IsAutoFoldInMaxHubWhiteboard && windowProcessName == "WhiteBoard" &&
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInMaxHubWhiteboard && windowProcessName == "WhiteBoard" &&
|
||||
WinTabWindowsChecker.IsWindowExisted("白板书写") &&
|
||||
ForegroundWindowInfo.WindowRect().Height >= SystemParameters.WorkArea.Height - 16 &&
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16) {
|
||||
if (ForegroundWindowInfo.ProcessPath() != "Unknown") {
|
||||
ForegroundWindowInfo.WindowRect().Width >= SystemParameters.WorkArea.Width - 16)
|
||||
{
|
||||
if (ForegroundWindowInfo.ProcessPath() != "Unknown")
|
||||
{
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(ForegroundWindowInfo.ProcessPath());
|
||||
var version = versionInfo.FileVersion; var prodName = versionInfo.ProductName;
|
||||
if (version.StartsWith("6.") && prodName=="WhiteBoard") if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
if (version.StartsWith("6.") && prodName == "WhiteBoard") if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
|
||||
}
|
||||
} else if (WinTabWindowsChecker.IsWindowExisted("幻灯片放映", false)) {
|
||||
}
|
||||
else if (WinTabWindowsChecker.IsWindowExisted("幻灯片放映", false))
|
||||
{
|
||||
// 处于幻灯片放映状态
|
||||
if (!Settings.Automation.IsAutoFoldInPPTSlideShow && isFloatingBarFolded && !foldFloatingBarByUser)
|
||||
UnFoldFloatingBar_MouseUp(new object(), null);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isFloatingBarFolded && !foldFloatingBarByUser) UnFoldFloatingBar_MouseUp(new object(), null);
|
||||
unfoldFloatingBarByUser = false;
|
||||
}
|
||||
@@ -350,34 +427,40 @@ namespace Ink_Canvas {
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void timerCheckAutoUpdateWithSilence_Elapsed(object sender, ElapsedEventArgs e) {
|
||||
private void timerCheckAutoUpdateWithSilence_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
// 停止计时器,避免重复触发
|
||||
timerCheckAutoUpdateWithSilence.Stop();
|
||||
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
// 检查是否有可用的更新
|
||||
if (string.IsNullOrEmpty(AvailableLatestVersion)) {
|
||||
if (string.IsNullOrEmpty(AvailableLatestVersion))
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | No available update version found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 检查是否启用了静默更新
|
||||
if (!Settings.Startup.IsAutoUpdateWithSilence) {
|
||||
if (!Settings.Startup.IsAutoUpdateWithSilence)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Silent update is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 检查更新文件是否已下载
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
string statusFilePath = Path.Combine(updatesFolderPath, $"DownloadV{AvailableLatestVersion}Status.txt");
|
||||
|
||||
if (!File.Exists(statusFilePath) || File.ReadAllText(statusFilePath).Trim().ToLower() != "true") {
|
||||
|
||||
if (!File.Exists(statusFilePath) || File.ReadAllText(statusFilePath).Trim().ToLower() != "true")
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update file not downloaded yet");
|
||||
|
||||
|
||||
// 尝试下载更新文件,使用多线路组下载功能
|
||||
Task.Run(async () => {
|
||||
Task.Run(async () =>
|
||||
{
|
||||
bool isDownloadSuccessful = false;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// 如果主要线路组可用,直接使用
|
||||
@@ -386,7 +469,7 @@ namespace Ink_Canvas {
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 使用主要线路组下载: {AvailableLatestLineGroup.GroupName}");
|
||||
isDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFile(AvailableLatestVersion, AvailableLatestLineGroup);
|
||||
}
|
||||
|
||||
|
||||
// 如果主要线路组不可用或下载失败,获取所有可用线路组
|
||||
if (!isDownloadSuccessful)
|
||||
{
|
||||
@@ -403,76 +486,94 @@ namespace Ink_Canvas {
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 下载更新时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
if (isDownloadSuccessful) {
|
||||
|
||||
if (isDownloadSuccessful)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update downloaded successfully, will check again for installation");
|
||||
// 重新启动计时器,下次检查时安装
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Failed to download update", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 检查是否在静默更新时间段内
|
||||
bool isInSilencePeriod = AutoUpdateWithSilenceTimeComboBox.CheckIsInSilencePeriod(
|
||||
Settings.Startup.AutoUpdateWithSilenceStartTime,
|
||||
Settings.Startup.AutoUpdateWithSilenceEndTime);
|
||||
|
||||
if (!isInSilencePeriod) {
|
||||
|
||||
if (!isInSilencePeriod)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Not in silence update time period");
|
||||
// 重新启动计时器,稍后再检查
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 检查应用程序状态,确保可以安全更新
|
||||
// 空闲状态的判定为不处于批注模式和画板模式
|
||||
bool canSafelyUpdate = false;
|
||||
|
||||
Dispatcher.Invoke(() => {
|
||||
try {
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// 判断是否处于批注模式(inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||
// 判断是否处于画板模式(!Topmost)
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.Ink && Topmost) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.Ink && Topmost)
|
||||
{
|
||||
// 检查是否有未保存的内容或正在进行的操作
|
||||
if (!isHidingSubPanelsWhenInking) {
|
||||
if (!isHidingSubPanelsWhenInking)
|
||||
{
|
||||
canSafelyUpdate = true;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Application is in a safe state for update - not in ink or board mode");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Application is currently performing operations");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Application is in ink or board mode, cannot update now");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error checking application state: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
});
|
||||
|
||||
if (canSafelyUpdate) {
|
||||
|
||||
if (canSafelyUpdate)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Installing update now");
|
||||
|
||||
|
||||
// 设置为用户主动退出,避免被看门狗判定为崩溃
|
||||
App.IsAppExitByUser = true;
|
||||
|
||||
|
||||
// 执行更新安装
|
||||
AutoUpdateHelper.InstallNewVersionApp(AvailableLatestVersion, true);
|
||||
|
||||
|
||||
// 关闭应用程序
|
||||
Dispatcher.Invoke(() => {
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Cannot safely update now, will try again later");
|
||||
// 重新启动计时器,稍后再检查
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error in silent update check: {ex.Message}", LogHelper.LogType.Error);
|
||||
// 出错时重新启动计时器,稍后再检查
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -7,11 +8,12 @@ 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 {
|
||||
public partial class MainWindow : Window {
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
#region Multi-Touch
|
||||
|
||||
private bool isInMultiTouchMode;
|
||||
@@ -60,14 +62,17 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void BorderMultiTouchMode_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (isInMultiTouchMode) {
|
||||
private void BorderMultiTouchMode_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (isInMultiTouchMode)
|
||||
{
|
||||
inkCanvas.StylusDown -= MainWindow_StylusDown;
|
||||
inkCanvas.StylusMove -= MainWindow_StylusMove;
|
||||
inkCanvas.StylusUp -= MainWindow_StylusUp;
|
||||
inkCanvas.TouchDown -= MainWindow_TouchDown;
|
||||
inkCanvas.TouchDown += Main_Grid_TouchDown;
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
// 保存非笔画元素(如图片)
|
||||
@@ -78,14 +83,16 @@ namespace Ink_Canvas {
|
||||
isInMultiTouchMode = false;
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
inkCanvas.StylusDown += MainWindow_StylusDown;
|
||||
inkCanvas.StylusMove += MainWindow_StylusMove;
|
||||
inkCanvas.StylusUp += MainWindow_StylusUp;
|
||||
inkCanvas.TouchDown += MainWindow_TouchDown;
|
||||
inkCanvas.TouchDown -= Main_Grid_TouchDown;
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
}
|
||||
// 保存非笔画元素(如图片)
|
||||
@@ -97,12 +104,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_TouchDown(object sender, TouchEventArgs e) {
|
||||
private void MainWindow_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
|
||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
|
||||
|| inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
|
||||
|
||||
if (!isHidingSubPanelsWhenInking) {
|
||||
if (!isHidingSubPanelsWhenInking)
|
||||
{
|
||||
isHidingSubPanelsWhenInking = true;
|
||||
HideSubPanels(); // 书写时自动隐藏二级菜单
|
||||
}
|
||||
@@ -110,12 +119,14 @@ namespace Ink_Canvas {
|
||||
// 只保留普通橡皮逻辑
|
||||
TouchDownPointsList[e.TouchDevice.Id] = InkCanvasEditingMode.None;
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(50, 50);
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_StylusDown(object sender, StylusDownEventArgs e) {
|
||||
private void MainWindow_StylusDown(object sender, StylusDownEventArgs e)
|
||||
{
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
|
||||
inkCanvas.CaptureStylus();
|
||||
@@ -123,19 +134,23 @@ namespace Ink_Canvas {
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||
|
||||
// 确保手写笔模式下显示光标
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
if (Settings.Canvas.IsShowCursor)
|
||||
{
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
|
||||
|
||||
// 根据当前编辑模式设置不同的光标
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.Cursor = Cursors.Cross;
|
||||
} else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
}
|
||||
else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||
{
|
||||
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
|
||||
if (sri != null)
|
||||
inkCanvas.Cursor = new Cursor(sri.Stream);
|
||||
}
|
||||
|
||||
|
||||
// 强制显示光标
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
}
|
||||
@@ -147,8 +162,10 @@ namespace Ink_Canvas {
|
||||
TouchDownPointsList[e.StylusDevice.Id] = InkCanvasEditingMode.None;
|
||||
}
|
||||
|
||||
private async void MainWindow_StylusUp(object sender, StylusEventArgs e) {
|
||||
try {
|
||||
private async void MainWindow_StylusUp(object sender, StylusEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
inkCanvas.Strokes.Add(GetStrokeVisual(e.StylusDevice.Id).Stroke);
|
||||
await Task.Delay(5); // 避免渲染墨迹完成前预览墨迹被删除导致墨迹闪烁
|
||||
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
|
||||
@@ -156,18 +173,23 @@ namespace Ink_Canvas {
|
||||
inkCanvas_StrokeCollected(inkCanvas,
|
||||
new InkCanvasStrokeCollectedEventArgs(GetStrokeVisual(e.StylusDevice.Id).Stroke));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
Label.Content = ex.ToString();
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
StrokeVisualList.Remove(e.StylusDevice.Id);
|
||||
VisualCanvasList.Remove(e.StylusDevice.Id);
|
||||
TouchDownPointsList.Remove(e.StylusDevice.Id);
|
||||
if (StrokeVisualList.Count == 0 || VisualCanvasList.Count == 0 || TouchDownPointsList.Count == 0) {
|
||||
if (StrokeVisualList.Count == 0 || VisualCanvasList.Count == 0 || TouchDownPointsList.Count == 0)
|
||||
{
|
||||
// 只清除手写笔预览相关的Canvas,不清除所有子元素
|
||||
foreach (var canvas in VisualCanvasList.Values.ToList()) {
|
||||
if (inkCanvas.Children.Contains(canvas)) {
|
||||
foreach (var canvas in VisualCanvasList.Values.ToList())
|
||||
{
|
||||
if (inkCanvas.Children.Contains(canvas))
|
||||
{
|
||||
inkCanvas.Children.Remove(canvas);
|
||||
}
|
||||
}
|
||||
@@ -183,16 +205,20 @@ namespace Ink_Canvas {
|
||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||
}
|
||||
|
||||
private void MainWindow_StylusMove(object sender, StylusEventArgs e) {
|
||||
try {
|
||||
private void MainWindow_StylusMove(object sender, StylusEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
|
||||
try {
|
||||
try
|
||||
{
|
||||
if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
|
||||
}
|
||||
catch { }
|
||||
|
||||
// 确保手写笔移动时光标保持可见
|
||||
if (Settings.Canvas.IsShowCursor) {
|
||||
if (Settings.Canvas.IsShowCursor)
|
||||
{
|
||||
inkCanvas.ForceCursor = true;
|
||||
inkCanvas.UseCustomCursor = true;
|
||||
System.Windows.Forms.Cursor.Show();
|
||||
@@ -207,7 +233,8 @@ namespace Ink_Canvas {
|
||||
catch { }
|
||||
}
|
||||
|
||||
private StrokeVisual GetStrokeVisual(int id) {
|
||||
private StrokeVisual GetStrokeVisual(int id)
|
||||
{
|
||||
if (StrokeVisualList.TryGetValue(id, out var visual)) return visual;
|
||||
|
||||
var strokeVisual = new StrokeVisual(inkCanvas.DefaultDrawingAttributes.Clone());
|
||||
@@ -220,11 +247,13 @@ namespace Ink_Canvas {
|
||||
return strokeVisual;
|
||||
}
|
||||
|
||||
private VisualCanvas GetVisualCanvas(int id) {
|
||||
private VisualCanvas GetVisualCanvas(int id)
|
||||
{
|
||||
return VisualCanvasList.TryGetValue(id, out var visualCanvas) ? visualCanvas : null;
|
||||
}
|
||||
|
||||
private InkCanvasEditingMode GetTouchDownPointsList(int id) {
|
||||
private InkCanvasEditingMode GetTouchDownPointsList(int id)
|
||||
{
|
||||
return TouchDownPointsList.TryGetValue(id, out var inkCanvasEditingMode) ? inkCanvasEditingMode : inkCanvas.EditingMode;
|
||||
}
|
||||
|
||||
@@ -241,32 +270,40 @@ namespace Ink_Canvas {
|
||||
|
||||
private Point iniP = new Point(0, 0);
|
||||
|
||||
private void Main_Grid_TouchDown(object sender, TouchEventArgs e) {
|
||||
private void Main_Grid_TouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
inkCanvas.CaptureTouch(e.TouchDevice);
|
||||
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
// 橡皮状态下只return,保证橡皮状态可保持
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
|
||||
{
|
||||
// 套索选状态下只return,保证套索选可用
|
||||
return;
|
||||
}
|
||||
if (drawingShapeMode == 9) {
|
||||
if (isFirstTouchCuboid) {
|
||||
if (drawingShapeMode == 9)
|
||||
{
|
||||
if (isFirstTouchCuboid)
|
||||
{
|
||||
CuboidFrontRectIniP = e.GetTouchPoint(inkCanvas).Position;
|
||||
}
|
||||
// 允许MouseTouchMove在TouchMove时处理
|
||||
return;
|
||||
}
|
||||
if (drawingShapeMode != 0) {
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
}
|
||||
@@ -277,9 +314,11 @@ namespace Ink_Canvas {
|
||||
private bool palmEraserLastIsHighlighter;
|
||||
private bool palmEraserWasEnabledBeforeMultiTouch;
|
||||
|
||||
private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e) {
|
||||
private void inkCanvas_PreviewTouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
@@ -290,10 +329,12 @@ namespace Ink_Canvas {
|
||||
|
||||
dec.Add(e.TouchDevice.Id);
|
||||
// Palm Eraser 逻辑
|
||||
if (Settings.Canvas.EnablePalmEraser && dec.Count >= 2 && !isPalmEraserActive) {
|
||||
if (Settings.Canvas.EnablePalmEraser && dec.Count >= 2 && !isPalmEraserActive)
|
||||
{
|
||||
var bounds = e.GetTouchPoint(inkCanvas).Bounds;
|
||||
double palmThreshold = 40; // 触摸面积阈值,可根据实际调整
|
||||
if (bounds.Width >= palmThreshold || bounds.Height >= palmThreshold) {
|
||||
if (bounds.Width >= palmThreshold || bounds.Height >= palmThreshold)
|
||||
{
|
||||
// 记录当前编辑模式和高光状态
|
||||
palmEraserLastEditingMode = inkCanvas.EditingMode;
|
||||
palmEraserLastIsHighlighter = drawingAttributes.IsHighlighter;
|
||||
@@ -303,12 +344,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
}
|
||||
//设备1个的时候,记录中心点
|
||||
if (dec.Count == 1) {
|
||||
if (dec.Count == 1)
|
||||
{
|
||||
var touchPoint = e.GetTouchPoint(inkCanvas);
|
||||
centerPoint = touchPoint.Position;
|
||||
|
||||
// 新增:几何绘制模式下,记录初始点
|
||||
if (drawingShapeMode != 0) {
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
iniP = touchPoint.Position;
|
||||
}
|
||||
|
||||
@@ -316,20 +359,24 @@ namespace Ink_Canvas {
|
||||
lastTouchDownStrokeCollection = inkCanvas.Strokes.Clone();
|
||||
}
|
||||
//设备两个及两个以上,将画笔功能关闭
|
||||
if (dec.Count > 1 || isSingleFingerDragMode || !Settings.Gesture.IsEnableTwoFingerGesture) {
|
||||
if (dec.Count > 1 || isSingleFingerDragMode || !Settings.Gesture.IsEnableTwoFingerGesture)
|
||||
{
|
||||
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None ||
|
||||
inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
|
||||
lastInkCanvasEditingMode = inkCanvas.EditingMode;
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void inkCanvas_PreviewTouchUp(object sender, TouchEventArgs e) {
|
||||
private void inkCanvas_PreviewTouchUp(object sender, TouchEventArgs e)
|
||||
{
|
||||
// 橡皮状态下不做任何切换,直接return,保证橡皮可持续
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint && !isPalmEraserActive) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint && !isPalmEraserActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
inkCanvas.ReleaseAllTouchCaptures();
|
||||
@@ -338,23 +385,31 @@ namespace Ink_Canvas {
|
||||
|
||||
// Palm Eraser 逻辑:所有点抬起后恢复原编辑模式
|
||||
dec.Remove(e.TouchDevice.Id);
|
||||
if (isPalmEraserActive && dec.Count == 0) {
|
||||
if (isPalmEraserActive && dec.Count == 0)
|
||||
{
|
||||
// 恢复高光状态
|
||||
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
||||
// 恢复编辑模式
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint) {
|
||||
if (palmEraserLastEditingMode == InkCanvasEditingMode.Ink) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
if (palmEraserLastEditingMode == InkCanvasEditingMode.Ink)
|
||||
{
|
||||
PenIcon_Click(null, null);
|
||||
} else if (palmEraserLastEditingMode == InkCanvasEditingMode.Select) {
|
||||
}
|
||||
else if (palmEraserLastEditingMode == InkCanvasEditingMode.Select)
|
||||
{
|
||||
SymbolIconSelect_MouseUp(null, null);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
inkCanvas.EditingMode = palmEraserLastEditingMode;
|
||||
}
|
||||
}
|
||||
isPalmEraserActive = false;
|
||||
}
|
||||
// 新增:几何绘制模式下,触摸抬手时自动落笔
|
||||
if (drawingShapeMode != 0) {
|
||||
if (drawingShapeMode != 0)
|
||||
{
|
||||
var mouseArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
|
||||
{
|
||||
RoutedEvent = MouseLeftButtonUpEvent,
|
||||
@@ -365,18 +420,24 @@ namespace Ink_Canvas {
|
||||
|
||||
//手势完成后切回之前的状态
|
||||
// 修复:改进多指手势恢复逻辑,确保从橡皮擦切换到笔时多指手势能正确恢复
|
||||
if (dec.Count > 1) {
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None) {
|
||||
if (lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (dec.Count > 1)
|
||||
{
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
|
||||
{
|
||||
if (lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = lastInkCanvasEditingMode;
|
||||
}
|
||||
}
|
||||
} else if (dec.Count == 0) {
|
||||
}
|
||||
else if (dec.Count == 0)
|
||||
{
|
||||
// 当所有触摸点都抬起时,确保正确恢复编辑模式
|
||||
// 这对于从橡皮擦切换到笔后恢复多指手势功能很重要
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.None &&
|
||||
lastInkCanvasEditingMode != InkCanvasEditingMode.None &&
|
||||
lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
lastInkCanvasEditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = lastInkCanvasEditingMode;
|
||||
}
|
||||
}
|
||||
@@ -384,29 +445,34 @@ namespace Ink_Canvas {
|
||||
|
||||
if (dec.Count == 0)
|
||||
if (lastTouchDownStrokeCollection.Count() != inkCanvas.Strokes.Count() &&
|
||||
!(drawingShapeMode == 9 && !isFirstTouchCuboid)) {
|
||||
!(drawingShapeMode == 9 && !isFirstTouchCuboid))
|
||||
{
|
||||
var whiteboardIndex = CurrentWhiteboardIndex;
|
||||
if (currentMode == 0) whiteboardIndex = 0;
|
||||
strokeCollections[whiteboardIndex] = lastTouchDownStrokeCollection;
|
||||
}
|
||||
}
|
||||
|
||||
private void inkCanvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e) {
|
||||
private void inkCanvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
|
||||
{
|
||||
e.Mode = ManipulationModes.All;
|
||||
}
|
||||
|
||||
private void inkCanvas_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e) { }
|
||||
|
||||
private void Main_Grid_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
|
||||
private void Main_Grid_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
|
||||
{
|
||||
if (e.Manipulators.Count() != 0) return;
|
||||
if (drawingShapeMode == 0 && inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint) {
|
||||
if (drawingShapeMode == 0 && inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
// 修复:确保多指手势完成后正确更新lastInkCanvasEditingMode
|
||||
lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
}
|
||||
|
||||
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
|
||||
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
||||
{
|
||||
// 手掌擦时禁止移动/缩放
|
||||
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||
return;
|
||||
@@ -416,7 +482,8 @@ namespace Ink_Canvas {
|
||||
if ((dec.Count >= 2 && (Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode ||
|
||||
StackPanelPPTControls.Visibility != Visibility.Visible ||
|
||||
StackPanelPPTButtons.Visibility == Visibility.Collapsed)) ||
|
||||
isSingleFingerDragMode) {
|
||||
isSingleFingerDragMode)
|
||||
{
|
||||
var md = e.DeltaManipulation;
|
||||
var trans = md.Translation; // 获得位移矢量
|
||||
|
||||
@@ -425,7 +492,8 @@ namespace Ink_Canvas {
|
||||
if (Settings.Gesture.IsEnableTwoFingerTranslate)
|
||||
m.Translate(trans.X, trans.Y); // 移动
|
||||
|
||||
if (Settings.Gesture.IsEnableTwoFingerGestureTranslateOrRotation) {
|
||||
if (Settings.Gesture.IsEnableTwoFingerGestureTranslateOrRotation)
|
||||
{
|
||||
var rotate = md.Rotation; // 获得旋转角度
|
||||
var scale = md.Scale; // 获得缩放倍数
|
||||
|
||||
@@ -441,12 +509,15 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
var strokes = inkCanvas.GetSelectedStrokes();
|
||||
if (strokes.Count != 0) {
|
||||
foreach (var stroke in strokes) {
|
||||
if (strokes.Count != 0)
|
||||
{
|
||||
foreach (var stroke in strokes)
|
||||
{
|
||||
stroke.Transform(m, false);
|
||||
|
||||
foreach (var circle in circles)
|
||||
if (stroke == circle.Stroke) {
|
||||
if (stroke == circle.Stroke)
|
||||
{
|
||||
circle.R = GetDistance(circle.Stroke.StylusPoints[0].ToPoint(),
|
||||
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].ToPoint()) / 2;
|
||||
circle.Centroid = new Point(
|
||||
@@ -458,18 +529,23 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
if (!Settings.Gesture.IsEnableTwoFingerZoom) continue;
|
||||
try {
|
||||
try
|
||||
{
|
||||
stroke.DrawingAttributes.Width *= md.Scale.X;
|
||||
stroke.DrawingAttributes.Height *= md.Scale.Y;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Settings.Gesture.IsEnableTwoFingerZoom) {
|
||||
foreach (var stroke in inkCanvas.Strokes) {
|
||||
else
|
||||
{
|
||||
if (Settings.Gesture.IsEnableTwoFingerZoom)
|
||||
{
|
||||
foreach (var stroke in inkCanvas.Strokes)
|
||||
{
|
||||
stroke.Transform(m, false);
|
||||
try {
|
||||
try
|
||||
{
|
||||
stroke.DrawingAttributes.Width *= md.Scale.X;
|
||||
stroke.DrawingAttributes.Height *= md.Scale.Y;
|
||||
}
|
||||
@@ -478,12 +554,14 @@ namespace Ink_Canvas {
|
||||
|
||||
;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
foreach (var stroke in inkCanvas.Strokes) stroke.Transform(m, false);
|
||||
;
|
||||
}
|
||||
|
||||
foreach (var circle in circles) {
|
||||
foreach (var circle in circles)
|
||||
{
|
||||
circle.R = GetDistance(circle.Stroke.StylusPoints[0].ToPoint(),
|
||||
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].ToPoint()) / 2;
|
||||
circle.Centroid = new Point(
|
||||
@@ -518,7 +596,8 @@ namespace Ink_Canvas {
|
||||
RestoreNonStrokeElements(preservedElements);
|
||||
isInMultiTouchMode = false;
|
||||
// 关闭多指书写时,恢复手掌擦开关
|
||||
if (palmEraserWasEnabledBeforeMultiTouch) {
|
||||
if (palmEraserWasEnabledBeforeMultiTouch)
|
||||
{
|
||||
Settings.Canvas.EnablePalmEraser = true;
|
||||
if (ToggleSwitchEnablePalmEraser != null)
|
||||
ToggleSwitchEnablePalmEraser.IsOn = true;
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
using System;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
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
|
||||
{
|
||||
public partial class App : Application {
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
private void SysTrayMenu_Opened(object sender, RoutedEventArgs e) {
|
||||
private void SysTrayMenu_Opened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var s = (ContextMenu)sender;
|
||||
var FoldFloatingBarTrayIconMenuItemIconEyeOff =
|
||||
(Image)((Grid)((MenuItem)s.Items[s.Items.Count-5]).Icon).Children[0];
|
||||
(Image)((Grid)((MenuItem)s.Items[s.Items.Count - 5]).Icon).Children[0];
|
||||
var FoldFloatingBarTrayIconMenuItemIconEyeOn =
|
||||
(Image)((Grid)((MenuItem)s.Items[s.Items.Count - 5]).Icon).Children[1];
|
||||
var FoldFloatingBarTrayIconMenuItemHeaderText =
|
||||
@@ -26,64 +28,79 @@ namespace Ink_Canvas
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
var HideICCMainWindowTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 9];
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
// 判斷是否在收納模式中
|
||||
if (mainWin.isFloatingBarFolded) {
|
||||
if (mainWin.isFloatingBarFolded)
|
||||
{
|
||||
FoldFloatingBarTrayIconMenuItemIconEyeOff.Visibility = Visibility.Hidden;
|
||||
FoldFloatingBarTrayIconMenuItemIconEyeOn.Visibility = Visibility.Visible;
|
||||
FoldFloatingBarTrayIconMenuItemHeaderText.Text = "退出收纳模式";
|
||||
if (!HideICCMainWindowTrayIconMenuItem.IsChecked) {
|
||||
if (!HideICCMainWindowTrayIconMenuItem.IsChecked)
|
||||
{
|
||||
ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = false;
|
||||
ResetFloatingBarPositionTrayIconMenuItem.Opacity = 0.5;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
FoldFloatingBarTrayIconMenuItemIconEyeOff.Visibility = Visibility.Visible;
|
||||
FoldFloatingBarTrayIconMenuItemIconEyeOn.Visibility = Visibility.Hidden;
|
||||
FoldFloatingBarTrayIconMenuItemHeaderText.Text = "切换为收纳模式";
|
||||
if (!HideICCMainWindowTrayIconMenuItem.IsChecked) {
|
||||
if (!HideICCMainWindowTrayIconMenuItem.IsChecked)
|
||||
{
|
||||
ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = true;
|
||||
ResetFloatingBarPositionTrayIconMenuItem.Opacity = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
private void CloseAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
IsAppExitByUser = true;
|
||||
Current.Shutdown();
|
||||
// mainWin.BtnExit_Click(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
IsAppExitByUser = true;
|
||||
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
// 启动新实例
|
||||
string exePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = exePath;
|
||||
startInfo.UseShellExecute = true;
|
||||
|
||||
|
||||
// 启动进程但不等待
|
||||
Process.Start(startInfo);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.NewLog($"重启程序时出错: {ex.Message}");
|
||||
}
|
||||
|
||||
|
||||
// 退出当前实例
|
||||
Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) {
|
||||
private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
Ink_Canvas.MainWindow.MoveWindow(new WindowInteropHelper(mainWin).Handle, 0, 0,
|
||||
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})");
|
||||
@@ -94,29 +111,34 @@ namespace Ink_Canvas
|
||||
{
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded)
|
||||
if (mainWin.isFloatingBarFolded) mainWin.UnFoldFloatingBar_MouseUp(new object(),null);
|
||||
else mainWin.FoldFloatingBar_MouseUp(new object(),null);
|
||||
if (mainWin.isFloatingBarFolded) mainWin.UnFoldFloatingBar_MouseUp(new object(), null);
|
||||
else mainWin.FoldFloatingBar_MouseUp(new object(), null);
|
||||
}
|
||||
|
||||
private void ResetFloatingBarPositionTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
var isInPPTPresentationMode = false;
|
||||
Dispatcher.Invoke(() => {
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
isInPPTPresentationMode = mainWin.BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
|
||||
});
|
||||
if (!mainWin.isFloatingBarFolded) {
|
||||
if (!mainWin.isFloatingBarFolded)
|
||||
{
|
||||
if (!isInPPTPresentationMode) mainWin.PureViewboxFloatingBarMarginAnimationInDesktopMode();
|
||||
else mainWin.PureViewboxFloatingBarMarginAnimationInPPTMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_Checked(object sender, RoutedEventArgs e) {
|
||||
private void HideICCMainWindowTrayIconMenuItem_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
mainWin.Hide();
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
@@ -128,16 +150,20 @@ namespace Ink_Canvas
|
||||
ResetFloatingBarPositionTrayIconMenuItem.Opacity = 0.5;
|
||||
FoldFloatingBarTrayIconMenuItem.Opacity = 0.5;
|
||||
ForceFullScreenTrayIconMenuItem.Opacity = 0.5;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.IsChecked = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void HideICCMainWindowTrayIconMenuItem_UnChecked(object sender, RoutedEventArgs e) {
|
||||
private void HideICCMainWindowTrayIconMenuItem_UnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mi = (MenuItem)sender;
|
||||
var mainWin = (MainWindow)Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
if (mainWin.IsLoaded)
|
||||
{
|
||||
mainWin.Show();
|
||||
var s = ((TaskbarIcon)Current.Resources["TaskbarTrayIcon"]).ContextMenu;
|
||||
var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4];
|
||||
@@ -149,7 +175,9 @@ namespace Ink_Canvas
|
||||
ResetFloatingBarPositionTrayIconMenuItem.Opacity = 1;
|
||||
FoldFloatingBarTrayIconMenuItem.Opacity = 1;
|
||||
ForceFullScreenTrayIconMenuItem.Opacity = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user