代码优化

This commit is contained in:
2026-02-21 16:51:34 +08:00
parent 469dbd1497
commit 99ec2d7609
31 changed files with 171 additions and 158 deletions
+14 -14
View File
@@ -420,7 +420,7 @@ namespace Ink_Canvas
$"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 记录未处理异常时发生错误: {ex.Message}\r\n" $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] 记录未处理异常时发生错误: {ex.Message}\r\n"
); );
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -576,7 +576,7 @@ namespace Ink_Canvas
// 同时记录到主日志 // 同时记录到主日志
LogHelper.WriteLogToFile(message, LogHelper.LogType.Error); LogHelper.WriteLogToFile(message, LogHelper.LogType.Error);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 增加字段保存崩溃后操作设置 // 增加字段保存崩溃后操作设置
@@ -593,7 +593,7 @@ namespace Ink_Canvas
var json = File.ReadAllText(settingsPath); var json = File.ReadAllText(settingsPath);
dynamic obj = JsonConvert.DeserializeObject(json); dynamic obj = JsonConvert.DeserializeObject(json);
int crashAction = 0; int crashAction = 0;
try { crashAction = (int)(obj["startup"]["crashAction"] ?? 0); } catch { } try { crashAction = (int)(obj["startup"]["crashAction"] ?? 0); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
CrashAction = (CrashActionType)crashAction; CrashAction = (CrashActionType)crashAction;
} }
// 从主窗口同步 // 从主窗口同步
@@ -602,7 +602,7 @@ namespace Ink_Canvas
CrashAction = (CrashActionType)Ink_Canvas.MainWindow.Settings.Startup.CrashAction; CrashAction = (CrashActionType)Ink_Canvas.MainWindow.Settings.Startup.CrashAction;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
@@ -657,7 +657,7 @@ namespace Ink_Canvas
string exePath = Process.GetCurrentProcess().MainModule.FileName; string exePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(exePath); Process.Start(exePath);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(1); Environment.Exit(1);
} }
// CrashActionType.NoAction 时不做处理 // CrashActionType.NoAction 时不做处理
@@ -909,7 +909,7 @@ namespace Ink_Canvas
LogHelper.WriteLogToFile("App | 清理损坏的更新标记文件"); LogHelper.WriteLogToFile("App | 清理损坏的更新标记文件");
} }
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -1002,7 +1002,7 @@ namespace Ink_Canvas
watchdogProcess.Kill(); watchdogProcess.Kill();
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(0); Environment.Exit(0);
} }
} }
@@ -1138,9 +1138,9 @@ namespace Ink_Canvas
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * SystemInformation.MouseWheelScrollLines / (double)120); SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * SystemInformation.MouseWheelScrollLines / (double)120);
e.Handled = true; e.Handled = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 用于设置崩溃后操作类型 // 用于设置崩溃后操作类型
@@ -1198,7 +1198,7 @@ namespace Ink_Canvas
string exePath = Process.GetCurrentProcess().MainModule.FileName; string exePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(exePath); Process.Start(exePath);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(1); Environment.Exit(1);
} }
return; return;
@@ -1223,7 +1223,7 @@ namespace Ink_Canvas
string exePath = Process.GetCurrentProcess().MainModule.FileName; string exePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(exePath); Process.Start(exePath);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(1); Environment.Exit(1);
} }
} }
@@ -1264,7 +1264,7 @@ namespace Ink_Canvas
// 检查退出信号文件 // 检查退出信号文件
if (File.Exists(exitSignalFile)) if (File.Exists(exitSignalFile))
{ {
try { File.Delete(exitSignalFile); } catch { } try { File.Delete(exitSignalFile); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(0); Environment.Exit(0);
} }
Thread.Sleep(2000); Thread.Sleep(2000);
@@ -1293,7 +1293,7 @@ namespace Ink_Canvas
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
Environment.Exit(0); Environment.Exit(0);
} }
} }
@@ -1401,7 +1401,7 @@ namespace Ink_Canvas
{ {
LogHelper.WriteLogToFile($"退出处理时发生错误: {ex.Message}", LogHelper.LogType.Error); LogHelper.WriteLogToFile($"退出处理时发生错误: {ex.Message}", LogHelper.LogType.Error);
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
} }
+6 -6
View File
@@ -1,4 +1,4 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
@@ -73,7 +73,7 @@ namespace Ink_Canvas.Helpers
sb.Begin((FrameworkElement)element); sb.Begin((FrameworkElement)element);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static void ShowWithSlideFromLeftAndFade(UIElement element, double duration = 0.25) public static void ShowWithSlideFromLeftAndFade(UIElement element, double duration = 0.25)
@@ -113,7 +113,7 @@ namespace Ink_Canvas.Helpers
sb.Begin((FrameworkElement)element); sb.Begin((FrameworkElement)element);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static void ShowWithScaleFromLeft(UIElement element, double duration = 0.2) public static void ShowWithScaleFromLeft(UIElement element, double duration = 0.2)
@@ -156,7 +156,7 @@ namespace Ink_Canvas.Helpers
sb.Begin((FrameworkElement)element); sb.Begin((FrameworkElement)element);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static void ShowWithScaleFromRight(UIElement element, double duration = 0.2) public static void ShowWithScaleFromRight(UIElement element, double duration = 0.2)
@@ -200,7 +200,7 @@ namespace Ink_Canvas.Helpers
sb.Begin((FrameworkElement)element); sb.Begin((FrameworkElement)element);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static void HideWithSlideAndFade(UIElement element, double duration = 0.15) public static void HideWithSlideAndFade(UIElement element, double duration = 0.15)
@@ -246,7 +246,7 @@ namespace Ink_Canvas.Helpers
element.RenderTransform = new TranslateTransform(); element.RenderTransform = new TranslateTransform();
sb.Begin((FrameworkElement)element); sb.Begin((FrameworkElement)element);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static void HideWithFadeOut(UIElement element, double duration = 0.15) public static void HideWithFadeOut(UIElement element, double duration = 0.15)
+8 -8
View File
@@ -288,7 +288,7 @@ namespace Ink_Canvas.Helpers
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return -1; return -1;
} }
@@ -1130,7 +1130,7 @@ namespace Ink_Canvas.Helpers
// 清理可能损坏的分块文件 // 清理可能损坏的分块文件
if (File.Exists(tempPath)) if (File.Exists(tempPath))
{ {
try { File.Delete(tempPath); } catch { } try { File.Delete(tempPath); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
// 增加重试间隔,避免频繁重试 // 增加重试间隔,避免频繁重试
@@ -1316,7 +1316,7 @@ namespace Ink_Canvas.Helpers
return resp.Content.Headers.ContentLength.Value; return resp.Content.Headers.ContentLength.Value;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return -1; return -1;
} }
@@ -1358,7 +1358,7 @@ namespace Ink_Canvas.Helpers
App.IsUpdateInstalling = true; App.IsUpdateInstalling = true;
if (wasProcessProtectionEnabled) if (wasProcessProtectionEnabled)
{ {
try { ProcessProtectionManager.SetEnabled(false); } catch { } try { ProcessProtectionManager.SetEnabled(false); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 在更新前备份设置文件 // 在更新前备份设置文件
@@ -2086,16 +2086,16 @@ namespace Ink_Canvas.Helpers
{ {
foreach (string file in Directory.GetFiles(updatesFolderPath, "*", SearchOption.AllDirectories)) foreach (string file in Directory.GetFiles(updatesFolderPath, "*", SearchOption.AllDirectories))
{ {
try { File.Delete(file); } catch { } try { File.Delete(file); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
foreach (string dir in Directory.GetDirectories(updatesFolderPath)) foreach (string dir in Directory.GetDirectories(updatesFolderPath))
{ {
try { Directory.Delete(dir, true); } catch { } try { Directory.Delete(dir, true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
try { Directory.Delete(updatesFolderPath, true); } catch { } try { Directory.Delete(updatesFolderPath, true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 版本修复方法,强制下载并安装指定通道的最新版本 // 版本修复方法,强制下载并安装指定通道的最新版本
+4 -4
View File
@@ -146,7 +146,7 @@ namespace Ink_Canvas.Helpers
var disposeMethod = searcher.GetType().GetMethod("Dispose"); var disposeMethod = searcher.GetType().GetMethod("Dispose");
disposeMethod?.Invoke(searcher, null); disposeMethod?.Invoke(searcher, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 主板序列号 // 主板序列号
try try
@@ -170,7 +170,7 @@ namespace Ink_Canvas.Helpers
var disposeMethod = searcher.GetType().GetMethod("Dispose"); var disposeMethod = searcher.GetType().GetMethod("Dispose");
disposeMethod?.Invoke(searcher, null); disposeMethod?.Invoke(searcher, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// BIOS序列号 // BIOS序列号
try try
@@ -194,7 +194,7 @@ namespace Ink_Canvas.Helpers
var disposeMethod = searcher.GetType().GetMethod("Dispose"); var disposeMethod = searcher.GetType().GetMethod("Dispose");
disposeMethod?.Invoke(searcher, null); disposeMethod?.Invoke(searcher, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 主硬盘序列号 // 主硬盘序列号
try try
@@ -218,7 +218,7 @@ namespace Ink_Canvas.Helpers
var disposeMethod = searcher.GetType().GetMethod("Dispose"); var disposeMethod = searcher.GetType().GetMethod("Dispose");
disposeMethod?.Invoke(searcher, null); disposeMethod?.Invoke(searcher, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
catch catch
+4 -4
View File
@@ -519,7 +519,7 @@ namespace Ink_Canvas.Helpers
File.Delete(ipcFile); File.Delete(ipcFile);
} }
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -570,7 +570,7 @@ namespace Ink_Canvas.Helpers
File.Delete(ipcFile); File.Delete(ipcFile);
} }
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -625,7 +625,7 @@ namespace Ink_Canvas.Helpers
File.Delete(ipcFile); File.Delete(ipcFile);
} }
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -675,7 +675,7 @@ namespace Ink_Canvas.Helpers
File.Delete(ipcFile); File.Delete(ipcFile);
} }
} }
catch { } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
} }
+12 -3
View File
@@ -86,7 +86,10 @@ namespace Ink_Canvas.Helpers
} }
}); });
} }
catch { } catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[LogHelper] WriteLogToFile failed: {ex.Message}");
}
} }
private static void CheckAndCleanLogsFolder(string logsPath) private static void CheckAndCleanLogsFolder(string logsPath)
@@ -114,7 +117,10 @@ namespace Ink_Canvas.Helpers
{ {
file.Delete(); file.Delete();
} }
catch { } catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[LogHelper] Delete log file failed: {ex.Message}");
}
} }
// 记录清理操作 // 记录清理操作
@@ -129,7 +135,10 @@ namespace Ink_Canvas.Helpers
}); });
} }
} }
catch { } catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[LogHelper] CheckAndCleanLogsFolder failed: {ex.Message}");
}
} }
internal static void WriteLogToFile(string v, object warning) internal static void WriteLogToFile(string v, object warning)
+1 -1
View File
@@ -190,7 +190,7 @@ namespace Ink_Canvas.Helpers
_lastDrawnPointCount = currentPointCount; _lastDrawnPointCount = currentPointCount;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
+2 -2
View File
@@ -391,7 +391,7 @@ namespace Ink_Canvas.Helpers
string path = Path.Combine(folderPath, slideIndex.ToString("0000") + StrokeFileExtension); string path = Path.Combine(folderPath, slideIndex.ToString("0000") + StrokeFileExtension);
if (File.Exists(path)) File.Delete(path); if (File.Exists(path)) File.Delete(path);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void CheckAndPerformMemoryCleanup() private void CheckAndPerformMemoryCleanup()
@@ -433,7 +433,7 @@ namespace Ink_Canvas.Helpers
if (_memoryStreams[i] != null) if (_memoryStreams[i] != null)
{ {
long len = _memoryStreams[i].Length; long len = _memoryStreams[i].Length;
try { _memoryStreams[i].Dispose(); freed += len; cleaned++; } catch { } try { _memoryStreams[i].Dispose(); freed += len; cleaned++; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
finally { _memoryStreams[i] = null; } finally { _memoryStreams[i] = null; }
} }
} }
+8 -8
View File
@@ -451,7 +451,7 @@ namespace Ink_Canvas.Helpers
refCount = Marshal.ReleaseComObject(PPTApplication); refCount = Marshal.ReleaseComObject(PPTApplication);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
@@ -517,7 +517,7 @@ namespace Ink_Canvas.Helpers
Marshal.ReleaseComObject(comObject); Marshal.ReleaseComObject(comObject);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void SafeReleaseComObject(object comObject, string objectName) private void SafeReleaseComObject(object comObject, string objectName)
@@ -1559,7 +1559,7 @@ namespace Ink_Canvas.Helpers
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return true; return true;
}, IntPtr.Zero); }, IntPtr.Zero);
@@ -1697,19 +1697,19 @@ namespace Ink_Canvas.Helpers
// 确保清理状态 // 确保清理状态
if (CurrentSlide != null && Marshal.IsComObject(CurrentSlide)) if (CurrentSlide != null && Marshal.IsComObject(CurrentSlide))
{ {
try { Marshal.ReleaseComObject(CurrentSlide); } catch { } try { Marshal.ReleaseComObject(CurrentSlide); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
if (CurrentSlides != null && Marshal.IsComObject(CurrentSlides)) if (CurrentSlides != null && Marshal.IsComObject(CurrentSlides))
{ {
try { Marshal.ReleaseComObject(CurrentSlides); } catch { } try { Marshal.ReleaseComObject(CurrentSlides); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
if (CurrentPresentation != null && Marshal.IsComObject(CurrentPresentation)) if (CurrentPresentation != null && Marshal.IsComObject(CurrentPresentation))
{ {
try { Marshal.ReleaseComObject(CurrentPresentation); } catch { } try { Marshal.ReleaseComObject(CurrentPresentation); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
if (PPTApplication != null && Marshal.IsComObject(PPTApplication)) if (PPTApplication != null && Marshal.IsComObject(PPTApplication))
{ {
try { Marshal.ReleaseComObject(PPTApplication); } catch { } try { Marshal.ReleaseComObject(PPTApplication); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
CurrentSlide = null; CurrentSlide = null;
@@ -1858,7 +1858,7 @@ namespace Ink_Canvas.Helpers
var proc = Process.GetProcessById((int)processId); var proc = Process.GetProcessById((int)processId);
windowInfo.ProcessName = proc.ProcessName.ToLower(); windowInfo.ProcessName = proc.ProcessName.ToLower();
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return windowInfo; return windowInfo;
} }
+8 -8
View File
@@ -175,7 +175,7 @@ namespace Ink_Canvas.Helpers
object appObj = comObject.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, comObject, null); object appObj = comObject.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, comObject, null);
candidateApp = appObj; candidateApp = appObj;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
bool isDuplicate = false; bool isDuplicate = false;
@@ -213,7 +213,7 @@ namespace Ink_Canvas.Helpers
{ {
activePres = candidateApp.ActivePresentation; activePres = candidateApp.ActivePresentation;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
if (activePres != null) if (activePres != null)
{ {
@@ -223,7 +223,7 @@ namespace Ink_Canvas.Helpers
{ {
ssWindow = activePres.SlideShowWindow; ssWindow = activePres.SlideShowWindow;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
if (ssWindow != null) if (ssWindow != null)
{ {
@@ -238,7 +238,7 @@ namespace Ink_Canvas.Helpers
if (val is int && (int)val == -1) isActive = true; if (val is int && (int)val == -1) isActive = true;
else if (val is bool && (bool)val == true) isActive = true; else if (val is bool && (bool)val == true) isActive = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
if (isActive) if (isActive)
{ {
@@ -252,7 +252,7 @@ namespace Ink_Canvas.Helpers
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
@@ -397,7 +397,7 @@ namespace Ink_Canvas.Helpers
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return false; return false;
} }
@@ -420,7 +420,7 @@ namespace Ink_Canvas.Helpers
hwnd = new IntPtr(hwndVal); hwnd = new IntPtr(hwndVal);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return hwnd; return hwnd;
} }
@@ -435,7 +435,7 @@ namespace Ink_Canvas.Helpers
{ {
Marshal.ReleaseComObject(comObj); Marshal.ReleaseComObject(comObj);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
@@ -207,7 +207,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
{ {
Dispatcher.BeginInvoke(new Action(() => Dispatcher.BeginInvoke(new Action(() =>
{ {
try { Close(); } catch { } try { Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 启动应用程序任务 // 启动应用程序任务
launchTask.Start(); launchTask.Start();
@@ -224,7 +224,7 @@ namespace Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.WriteLogToFile($"应用按钮点击事件出错: {ex.Message}", LogHelper.LogType.Error); LogHelper.WriteLogToFile($"应用按钮点击事件出错: {ex.Message}", LogHelper.LogType.Error);
try { IsClosing = true; Close(); } catch { } try { IsClosing = true; Close(); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
@@ -37,8 +37,9 @@ namespace Ink_Canvas.Helpers
var enabled = settings?.Security != null && settings.Security.EnableProcessProtection; var enabled = settings?.Security != null && settings.Security.EnableProcessProtection;
SetEnabled(enabled); SetEnabled(enabled);
} }
catch catch (Exception ex)
{ {
LogHelper.WriteLogToFile($"ProcessProtectionManager.ApplyFromSettings 失败: {ex.Message}", LogHelper.LogType.Warning);
} }
} }
@@ -72,8 +73,9 @@ namespace Ink_Canvas.Helpers
LogHelper.WriteLogToFile($"ProcessProtectionManager.WithWriteAccess: 获取写入门闩超时({gateTimeoutMs}ms),将降级直接执行写入动作。目标: {targetPath}", LogHelper.WriteLogToFile($"ProcessProtectionManager.WithWriteAccess: 获取写入门闩超时({gateTimeoutMs}ms),将降级直接执行写入动作。目标: {targetPath}",
LogHelper.LogType.Warning); LogHelper.LogType.Warning);
} }
catch catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"[ProcessProtectionManager] 写日志失败: {ex.Message}");
} }
action(); action();
@@ -113,14 +115,14 @@ namespace Ink_Canvas.Helpers
{ {
foreach (var kv in releasedFiles) foreach (var kv in releasedFiles)
{ {
try { kv.Value.Dispose(); } catch { } try { kv.Value.Dispose(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
if (releasedDirs != null) if (releasedDirs != null)
{ {
foreach (var kv in releasedDirs) foreach (var kv in releasedDirs)
{ {
try { kv.Value.Dispose(); } catch { } try { kv.Value.Dispose(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
@@ -217,13 +219,13 @@ namespace Ink_Canvas.Helpers
{ {
foreach (var kv in _lockedFiles) foreach (var kv in _lockedFiles)
{ {
try { kv.Value.Dispose(); } catch { } try { kv.Value.Dispose(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
_lockedFiles.Clear(); _lockedFiles.Clear();
foreach (var kv in _lockedDirs) foreach (var kv in _lockedDirs)
{ {
try { kv.Value.Dispose(); } catch { } try { kv.Value.Dispose(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
_lockedDirs.Clear(); _lockedDirs.Clear();
} }
+1 -1
View File
@@ -435,7 +435,7 @@ namespace Ink_Canvas.Helpers
refCount = Marshal.ReleaseComObject(appToRelease); refCount = Marshal.ReleaseComObject(appToRelease);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
+4 -3
View File
@@ -1,3 +1,4 @@
using System;
using System.IO; using System.IO;
namespace Ink_Canvas.Helpers namespace Ink_Canvas.Helpers
@@ -18,7 +19,7 @@ namespace Ink_Canvas.Helpers
return count; return count;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return 0; return 0;
} }
@@ -31,7 +32,7 @@ namespace Ink_Canvas.Helpers
{ {
File.WriteAllText(CountFilePath, count.ToString()); File.WriteAllText(CountFilePath, count.ToString());
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
@@ -44,7 +45,7 @@ namespace Ink_Canvas.Helpers
if (File.Exists(CountFilePath)) if (File.Exists(CountFilePath))
File.Delete(CountFilePath); File.Delete(CountFilePath);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
+5 -5
View File
@@ -544,7 +544,7 @@ namespace Ink_Canvas
inkCanvas.Gesture += InkCanvas_Gesture; inkCanvas.Gesture += InkCanvas_Gesture;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
@@ -586,7 +586,7 @@ namespace Ink_Canvas
return Color.FromArgb(alpha, r, g, b); return Color.FromArgb(alpha, r, g, b);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return Color.FromArgb(alpha, 255, 0, 0); return Color.FromArgb(alpha, 255, 0, 0);
} }
@@ -866,7 +866,7 @@ namespace Ink_Canvas
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
if (!nextInterval.HasValue) if (!nextInterval.HasValue)
{ {
@@ -975,7 +975,7 @@ namespace Ink_Canvas
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void inkCanvas_EditingModeChanged(object sender, RoutedEventArgs e) private void inkCanvas_EditingModeChanged(object sender, RoutedEventArgs e)
@@ -1595,7 +1595,7 @@ namespace Ink_Canvas
_lastFrame = null; _lastFrame = null;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 释放PPT管理器资源 // 释放PPT管理器资源
DisposePPTManagers(); DisposePPTManagers();
+1 -1
View File
@@ -357,7 +357,7 @@ namespace Ink_Canvas
if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme"); if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme");
if (keyValue == 1) light = true; if (keyValue == 1) light = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return light; return light;
} }
@@ -1380,7 +1380,7 @@ namespace Ink_Canvas
{ {
InkCanvasForInkReplay.Strokes.Remove(s); InkCanvasForInkReplay.Strokes.Remove(s);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
stylusPoints.Add(stylusPoint); stylusPoints.Add(stylusPoint);
s = new Stroke(stylusPoints.Clone()) s = new Stroke(stylusPoints.Clone())
@@ -1417,7 +1417,7 @@ namespace Ink_Canvas
{ {
InkCanvasForInkReplay.Strokes.Remove(s); InkCanvasForInkReplay.Strokes.Remove(s);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
stylusPoints.Add(stylusPoint); stylusPoints.Add(stylusPoint);
s = new Stroke(stylusPoints.Clone()) s = new Stroke(stylusPoints.Clone())
@@ -2759,7 +2759,7 @@ namespace Ink_Canvas
else else
((UIElement)((Button)sender).Content).Opacity = 0.25; ((UIElement)((Button)sender).Content).Opacity = 0.25;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
#endregion Left Side Panel #endregion Left Side Panel
+4 -3
View File
@@ -1,4 +1,5 @@
using System.Windows; using System;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
namespace Ink_Canvas namespace Ink_Canvas
@@ -39,7 +40,7 @@ namespace Ink_Canvas
{ {
SymbolIconUndo_MouseUp(lastBorderMouseDownObject, null); SymbolIconUndo_MouseUp(lastBorderMouseDownObject, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void HotKey_Redo(object sender, ExecutedRoutedEventArgs e) private void HotKey_Redo(object sender, ExecutedRoutedEventArgs e)
@@ -48,7 +49,7 @@ namespace Ink_Canvas
{ {
SymbolIconRedo_MouseUp(lastBorderMouseDownObject, null); SymbolIconRedo_MouseUp(lastBorderMouseDownObject, null);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void HotKey_Clear(object sender, ExecutedRoutedEventArgs e) private void HotKey_Clear(object sender, ExecutedRoutedEventArgs e)
+5 -5
View File
@@ -416,7 +416,7 @@ namespace Ink_Canvas
{ {
pptApplication.Presentations[i].Close(); pptApplication.Presentations[i].Close();
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
@@ -444,17 +444,17 @@ namespace Ink_Canvas
{ {
if (presentation != null) if (presentation != null)
{ {
try { if (Marshal.IsComObject(presentation)) Marshal.ReleaseComObject(presentation); } catch { } try { if (Marshal.IsComObject(presentation)) Marshal.ReleaseComObject(presentation); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
presentation = null; presentation = null;
} }
if (slides != null) if (slides != null)
{ {
try { if (Marshal.IsComObject(slides)) Marshal.ReleaseComObject(slides); } catch { } try { if (Marshal.IsComObject(slides)) Marshal.ReleaseComObject(slides); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
slides = null; slides = null;
} }
if (slide != null) if (slide != null)
{ {
try { if (Marshal.IsComObject(slide)) Marshal.ReleaseComObject(slide); } catch { } try { if (Marshal.IsComObject(slide)) Marshal.ReleaseComObject(slide); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
slide = null; slide = null;
} }
slidescount = 0; slidescount = 0;
@@ -1030,7 +1030,7 @@ namespace Ink_Canvas
currentPage = pres.SlideShowWindow.View.CurrentShowPosition; currentPage = pres.SlideShowWindow.View.CurrentShowPosition;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
+4 -4
View File
@@ -977,7 +977,7 @@ namespace Ink_Canvas
LogHelper.WriteLogToFile($"更新白板名言时出错: {ex.Message}", LogHelper.LogType.Warning); LogHelper.WriteLogToFile($"更新白板名言时出错: {ex.Message}", LogHelper.LogType.Warning);
if (Settings.Appearance.ChickenSoupSource == 3 && BlackBoardWaterMark != null) if (Settings.Appearance.ChickenSoupSource == 3 && BlackBoardWaterMark != null)
{ {
try { BlackBoardWaterMark.Text = "一言功能不可用"; } catch { } try { BlackBoardWaterMark.Text = "一言功能不可用"; } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
} }
@@ -3344,7 +3344,7 @@ namespace Ink_Canvas
ToggleSwitchRunAtStartup.IsOn = false; ToggleSwitchRunAtStartup.IsOn = false;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
ShowNotification("设置已重置为默认推荐设置~"); ShowNotification("设置已重置为默认推荐设置~");
} }
@@ -3363,7 +3363,7 @@ namespace Ink_Canvas
LoadSettings(isStartup: false, skipAutoUpdateCheck: true); LoadSettings(isStartup: false, skipAutoUpdateCheck: true);
isLoaded = true; isLoaded = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
#endregion #endregion
@@ -4423,7 +4423,7 @@ namespace Ink_Canvas
var path = App.RootPath + settingsFileName; var path = App.RootPath + settingsFileName;
ProcessProtectionManager.WithWriteAccess(path, () => File.WriteAllText(path, text)); ProcessProtectionManager.WithWriteAccess(path, () => File.WriteAllText(path, text));
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void SCManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e) private void SCManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
+12 -12
View File
@@ -623,7 +623,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -681,7 +681,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -870,7 +870,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -895,7 +895,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -912,7 +912,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -931,7 +931,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -957,7 +957,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStroke); inkCanvas.Strokes.Remove(lastTempStroke);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStroke = stroke; lastTempStroke = stroke;
inkCanvas.Strokes.Add(stroke); inkCanvas.Strokes.Add(stroke);
@@ -1019,7 +1019,7 @@ namespace Ink_Canvas
{ {
inkCanvas.Strokes.Remove(lastTempStrokeCollection); inkCanvas.Strokes.Remove(lastTempStrokeCollection);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
lastTempStrokeCollection = strokes; lastTempStrokeCollection = strokes;
inkCanvas.Strokes.Add(strokes); inkCanvas.Strokes.Add(strokes);
@@ -1554,10 +1554,10 @@ namespace Ink_Canvas
// 如果更新失败,确保清理状态 // 如果更新失败,确保清理状态
if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke)) if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke))
{ {
try { inkCanvas.Strokes.Remove(lastTempStroke); } catch { } try { inkCanvas.Strokes.Remove(lastTempStroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
lastTempStroke = newStroke; lastTempStroke = newStroke;
try { inkCanvas.Strokes.Add(newStroke); } catch { } try { inkCanvas.Strokes.Add(newStroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
}), DispatcherPriority.Render); }), DispatcherPriority.Render);
} }
@@ -1612,11 +1612,11 @@ namespace Ink_Canvas
{ {
foreach (var stroke in lastTempStrokeCollection) foreach (var stroke in lastTempStrokeCollection)
{ {
try { inkCanvas.Strokes.Remove(stroke); } catch { } try { inkCanvas.Strokes.Remove(stroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
} }
lastTempStrokeCollection = newStrokeCollection; lastTempStrokeCollection = newStrokeCollection;
try { inkCanvas.Strokes.Add(newStrokeCollection); } catch { } try { inkCanvas.Strokes.Add(newStrokeCollection); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
} }
}), DispatcherPriority.Render); }), DispatcherPriority.Render);
} }
@@ -1,4 +1,4 @@
using Ink_Canvas.Helpers; using Ink_Canvas.Helpers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -162,7 +162,7 @@ namespace Ink_Canvas
e.Stroke.StylusPoints = stylusPoints; e.Stroke.StylusPoints = stylusPoints;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
break; break;
case 0: case 0:
if (penType == 0) if (penType == 0)
@@ -210,7 +210,7 @@ namespace Ink_Canvas
e.Stroke.StylusPoints = stylusPoints; e.Stroke.StylusPoints = stylusPoints;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
break; break;
} }
} }
@@ -603,7 +603,7 @@ namespace Ink_Canvas
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
InkToShapeProcess(); InkToShapeProcess();
@@ -630,7 +630,7 @@ namespace Ink_Canvas
RandWindow.randSeed = (int)(_speed * 100000 * 1000); RandWindow.randSeed = (int)(_speed * 100000 * 1000);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
switch (Settings.Canvas.InkStyle) switch (Settings.Canvas.InkStyle)
{ {
@@ -663,7 +663,7 @@ namespace Ink_Canvas
e.Stroke.StylusPoints = stylusPoints; e.Stroke.StylusPoints = stylusPoints;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
break; break;
case 0: case 0:
@@ -712,12 +712,12 @@ namespace Ink_Canvas
e.Stroke.StylusPoints = stylusPoints; e.Stroke.StylusPoints = stylusPoints;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
break; break;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时) // 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时)
Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}"); Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}");
+5 -5
View File
@@ -453,7 +453,7 @@ namespace Ink_Canvas
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
@@ -550,7 +550,7 @@ namespace Ink_Canvas
return true; return true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
else if (Settings.Automation.IsAutoFoldInEasiCamera && windowProcessName == "EasiCamera") else if (Settings.Automation.IsAutoFoldInEasiCamera && windowProcessName == "EasiCamera")
@@ -617,7 +617,7 @@ namespace Ink_Canvas
return true; return true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
@@ -699,7 +699,7 @@ namespace Ink_Canvas
return true; return true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
// 检查EasiCamera // 检查EasiCamera
@@ -809,7 +809,7 @@ namespace Ink_Canvas
return true; return true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }
+5 -5
View File
@@ -388,7 +388,7 @@ namespace Ink_Canvas
TouchDownPointsList.Clear(); TouchDownPointsList.Clear();
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
inkCanvas.ReleaseStylusCapture(); inkCanvas.ReleaseStylusCapture();
ViewboxFloatingBar.IsHitTestVisible = true; ViewboxFloatingBar.IsHitTestVisible = true;
@@ -415,7 +415,7 @@ namespace Ink_Canvas
{ {
if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return; if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id); var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
@@ -424,7 +424,7 @@ namespace Ink_Canvas
strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor)); strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
strokeVisual.Redraw(); strokeVisual.Redraw();
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private StrokeVisual GetStrokeVisual(int id) private StrokeVisual GetStrokeVisual(int id)
@@ -729,7 +729,7 @@ namespace Ink_Canvas
stroke.DrawingAttributes.Width *= md.Scale.X; stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y; stroke.DrawingAttributes.Height *= md.Scale.Y;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
else else
@@ -744,7 +744,7 @@ namespace Ink_Canvas
stroke.DrawingAttributes.Width *= md.Scale.X; stroke.DrawingAttributes.Width *= md.Scale.X;
stroke.DrawingAttributes.Height *= md.Scale.Y; stroke.DrawingAttributes.Height *= md.Scale.Y;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 同时变换画布上的图片元素 // 同时变换画布上的图片元素
+10 -10
View File
@@ -95,7 +95,7 @@ namespace Ink_Canvas
{ {
LogHelper.WriteLogToFile($"视频展台摄像头错误: {e}", LogHelper.LogType.Error); LogHelper.WriteLogToFile($"视频展台摄像头错误: {e}", LogHelper.LogType.Error);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void CameraService_FrameReceived(object sender, Bitmap frame) private void CameraService_FrameReceived(object sender, Bitmap frame)
@@ -169,7 +169,7 @@ namespace Ink_Canvas
img.Source = preview; img.Source = preview;
img.Visibility = Visibility.Visible; img.Visibility = Visibility.Visible;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private const double VideoPresenterLiveFrameScreenRatio = 0.75; private const double VideoPresenterLiveFrameScreenRatio = 0.75;
@@ -201,7 +201,7 @@ namespace Ink_Canvas
InitializeElementTransform(img); InitializeElementTransform(img);
BindElementEvents(img); BindElementEvents(img);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
_liveFrameImageByPage[page] = img; _liveFrameImageByPage[page] = img;
return img; return img;
@@ -323,7 +323,7 @@ namespace Ink_Canvas
UpdateCurrentToolMode("select"); UpdateCurrentToolMode("select");
HideSubPanels("select"); HideSubPanels("select");
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 立即用侧栏预览刷新一次 // 立即用侧栏预览刷新一次
if (VideoPresenterPreviewImage?.Source is BitmapImage bi) if (VideoPresenterPreviewImage?.Source is BitmapImage bi)
@@ -346,7 +346,7 @@ namespace Ink_Canvas
inkCanvas.Children.Remove(img); inkCanvas.Children.Remove(img);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
@@ -365,7 +365,7 @@ namespace Ink_Canvas
_liveFrameLayoutByPage[page] = (left, top, img.Width); _liveFrameLayoutByPage[page] = (left, top, img.Width);
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
// 翻页后调用:根据该页状态恢复实时画面,并同步设备选择 // 翻页后调用:根据该页状态恢复实时画面,并同步设备选择
@@ -404,7 +404,7 @@ namespace Ink_Canvas
_cameraService?.StartPreview(idx); _cameraService?.StartPreview(idx);
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void BtnCapturePhoto_Click(object sender, RoutedEventArgs e) private void BtnCapturePhoto_Click(object sender, RoutedEventArgs e)
@@ -595,13 +595,13 @@ namespace Ink_Canvas
} }
img.Visibility = Visibility.Collapsed; img.Visibility = Visibility.Collapsed;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
try { _cameraService?.StopPreview(); } catch { } try { _cameraService?.StopPreview(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private static BitmapImage ConvertBitmapToBitmapImage(Bitmap bitmap) private static BitmapImage ConvertBitmapToBitmapImage(Bitmap bitmap)
+17 -17
View File
@@ -124,7 +124,7 @@ namespace Ink_Canvas.Windows
CheckBoxHideStrokeWhenSelecting.IsChecked = _settings.Canvas.HideStrokeWhenSelecting; CheckBoxHideStrokeWhenSelecting.IsChecked = _settings.Canvas.HideStrokeWhenSelecting;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 手势操作 // 手势操作
try try
@@ -137,7 +137,7 @@ namespace Ink_Canvas.Windows
CheckBoxEnablePalmEraser.IsChecked = _settings.Canvas != null && _settings.Canvas.EnablePalmEraser; CheckBoxEnablePalmEraser.IsChecked = _settings.Canvas != null && _settings.Canvas.EnablePalmEraser;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 墨迹纠正 // 墨迹纠正
try try
@@ -147,7 +147,7 @@ namespace Ink_Canvas.Windows
CheckBoxInkToShapeEnabled.IsChecked = _settings.InkToShape.IsInkToShapeEnabled; CheckBoxInkToShapeEnabled.IsChecked = _settings.InkToShape.IsInkToShapeEnabled;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 快捷键(外观) // 快捷键(外观)
try try
@@ -157,7 +157,7 @@ namespace Ink_Canvas.Windows
CheckBoxEnableHotkeysInMouseMode.IsChecked = _settings.Appearance.EnableHotkeysInMouseMode; CheckBoxEnableHotkeysInMouseMode.IsChecked = _settings.Appearance.EnableHotkeysInMouseMode;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 崩溃处理 // 崩溃处理
try try
@@ -165,7 +165,7 @@ namespace Ink_Canvas.Windows
RadioCrashSilentRestart.IsChecked = _settings.Startup.CrashAction == 0; RadioCrashSilentRestart.IsChecked = _settings.Startup.CrashAction == 0;
RadioCrashNoAction.IsChecked = _settings.Startup.CrashAction != 0; RadioCrashNoAction.IsChecked = _settings.Startup.CrashAction != 0;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 自动化行为 // 自动化行为
try try
@@ -180,7 +180,7 @@ namespace Ink_Canvas.Windows
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 随机点名 // 随机点名
try try
@@ -190,7 +190,7 @@ namespace Ink_Canvas.Windows
CheckBoxShowRandomAndSingleDraw.IsChecked = _settings.RandSettings.ShowRandomAndSingleDraw; CheckBoxShowRandomAndSingleDraw.IsChecked = _settings.RandSettings.ShowRandomAndSingleDraw;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 高级选项 // 高级选项
try try
@@ -200,7 +200,7 @@ namespace Ink_Canvas.Windows
CheckBoxIsLogEnabled.IsChecked = _settings.Advanced.IsLogEnabled; CheckBoxIsLogEnabled.IsChecked = _settings.Advanced.IsLogEnabled;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 截图(自动化中的截图相关) // 截图(自动化中的截图相关)
try try
@@ -211,7 +211,7 @@ namespace Ink_Canvas.Windows
CheckBoxSaveScreenshotsInDateFolders.IsChecked = _settings.Automation.IsSaveScreenshotsInDateFolders; CheckBoxSaveScreenshotsInDateFolders.IsChecked = _settings.Automation.IsSaveScreenshotsInDateFolders;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
private void ApplySelection() private void ApplySelection()
@@ -312,7 +312,7 @@ namespace Ink_Canvas.Windows
_settings.Canvas.EnablePalmEraser = CheckBoxEnablePalmEraser.IsChecked == true; _settings.Canvas.EnablePalmEraser = CheckBoxEnablePalmEraser.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回手势操作 // 写回手势操作
try try
@@ -324,7 +324,7 @@ namespace Ink_Canvas.Windows
_settings.Gesture.AutoSwitchTwoFingerGesture = CheckBoxAutoSwitchTwoFingerGesture.IsChecked == true; _settings.Gesture.AutoSwitchTwoFingerGesture = CheckBoxAutoSwitchTwoFingerGesture.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回墨迹纠正 // 写回墨迹纠正
try try
@@ -334,7 +334,7 @@ namespace Ink_Canvas.Windows
_settings.InkToShape.IsInkToShapeEnabled = CheckBoxInkToShapeEnabled.IsChecked == true; _settings.InkToShape.IsInkToShapeEnabled = CheckBoxInkToShapeEnabled.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回快捷键(外观) // 写回快捷键(外观)
try try
@@ -344,14 +344,14 @@ namespace Ink_Canvas.Windows
_settings.Appearance.EnableHotkeysInMouseMode = CheckBoxEnableHotkeysInMouseMode.IsChecked == true; _settings.Appearance.EnableHotkeysInMouseMode = CheckBoxEnableHotkeysInMouseMode.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回崩溃处理(0=静默重启,1=无操作) // 写回崩溃处理(0=静默重启,1=无操作)
try try
{ {
_settings.Startup.CrashAction = RadioCrashNoAction.IsChecked == true ? 1 : 0; _settings.Startup.CrashAction = RadioCrashNoAction.IsChecked == true ? 1 : 0;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回自动化行为 // 写回自动化行为
try try
@@ -368,7 +368,7 @@ namespace Ink_Canvas.Windows
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回随机点名 // 写回随机点名
try try
@@ -378,7 +378,7 @@ namespace Ink_Canvas.Windows
_settings.RandSettings.ShowRandomAndSingleDraw = CheckBoxShowRandomAndSingleDraw.IsChecked == true; _settings.RandSettings.ShowRandomAndSingleDraw = CheckBoxShowRandomAndSingleDraw.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 写回高级选项 // 写回高级选项
try try
@@ -388,7 +388,7 @@ namespace Ink_Canvas.Windows
_settings.Advanced.IsLogEnabled = CheckBoxIsLogEnabled.IsChecked == true; _settings.Advanced.IsLogEnabled = CheckBoxIsLogEnabled.IsChecked == true;
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 标记用户已经阅读并确认过隐私说明 // 标记用户已经阅读并确认过隐私说明
_settings.Startup.HasAcceptedTelemetryPrivacy = true; _settings.Startup.HasAcceptedTelemetryPrivacy = true;
@@ -1,4 +1,4 @@
using Ink_Canvas.Helpers; using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern; using iNKORE.UI.WPF.Modern;
using System; using System;
using System.Windows; using System.Windows;
@@ -89,7 +89,7 @@ namespace Ink_Canvas
if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme"); if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme");
if (keyValue == 1) light = true; if (keyValue == 1) light = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return light; return light;
} }
+2 -2
View File
@@ -1399,7 +1399,7 @@ namespace Ink_Canvas.Windows
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
presentation = currentPresentationProperty?.GetValue(pptManager) as Microsoft.Office.Interop.PowerPoint.Presentation; presentation = currentPresentationProperty?.GetValue(pptManager) as Microsoft.Office.Interop.PowerPoint.Presentation;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
// 如果 CurrentPresentation 不可用,尝试 GetCurrentActivePresentation // 如果 CurrentPresentation 不可用,尝试 GetCurrentActivePresentation
if (presentation == null) if (presentation == null)
@@ -1409,7 +1409,7 @@ namespace Ink_Canvas.Windows
var getCurrentActivePresentationMethod = pptManager.GetType().GetMethod("GetCurrentActivePresentation"); var getCurrentActivePresentationMethod = pptManager.GetType().GetMethod("GetCurrentActivePresentation");
presentation = getCurrentActivePresentationMethod?.Invoke(pptManager, null) as Microsoft.Office.Interop.PowerPoint.Presentation; presentation = getCurrentActivePresentationMethod?.Invoke(pptManager, null) as Microsoft.Office.Interop.PowerPoint.Presentation;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
if (presentation != null) if (presentation != null)
+2 -2
View File
@@ -1,4 +1,4 @@
using Ink_Canvas.Helpers; using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls; using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using System; using System;
@@ -131,7 +131,7 @@ namespace Ink_Canvas
if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme"); if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme");
if (keyValue == 1) light = true; if (keyValue == 1) light = true;
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
return light; return light;
} }
@@ -1,4 +1,4 @@
using iNKORE.UI.WPF.Helpers; using iNKORE.UI.WPF.Helpers;
using Ink_Canvas.Helpers; using Ink_Canvas.Helpers;
using OSVersionExtension; using OSVersionExtension;
using System; using System;
@@ -38,7 +38,7 @@ namespace Ink_Canvas.Windows.SettingsViews
CopyrightBannerImage.Source = CopyrightBannerImage.Source =
new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}")); new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}"));
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
else else
{ {
@@ -173,7 +173,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
public static class TouchTabletDetectHelper public static class TouchTabletDetectHelper
@@ -171,7 +171,7 @@ namespace Ink_Canvas.Windows.SettingsViews
ThemeHelper.ApplyThemeToControl(this); ThemeHelper.ApplyThemeToControl(this);
LoadSettings(); LoadSettings();
} }
catch { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
} }
} }
} }