From 85d98c0b707fe47cdde7c84ce15165e0836ab573 Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Tue, 10 Jun 2025 16:48:45 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E6=94=B9=E8=BF=9B=E4=BA=86=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/LogHelper.cs | 47 +++++++++++------- Ink Canvas/Windows/RandWindow.xaml | 2 +- Ink Canvas/Windows/RandWindow.xaml.cs | 12 +++++ ...vasForClass.csproj.AssemblyReference.cache | Bin 35069 -> 34889 bytes .../net472/InkCanvasForClass.g.resources | Bin 5156754 -> 5156753 bytes .../obj/Debug/net472/Windows/RandWindow.g.cs | 2 +- .../Debug/net472/Windows/RandWindow.g.i.cs | 2 +- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/Ink Canvas/Helpers/LogHelper.cs b/Ink Canvas/Helpers/LogHelper.cs index 0e1129b2..a2c6ce66 100644 --- a/Ink Canvas/Helpers/LogHelper.cs +++ b/Ink Canvas/Helpers/LogHelper.cs @@ -1,5 +1,7 @@ using System; +using System.Diagnostics; using System.IO; +using System.Threading; namespace Ink_Canvas.Helpers { @@ -14,24 +16,19 @@ namespace Ink_Canvas.Helpers public static void NewLog(Exception ex) { - + if (ex == null) return; + var stackTrace = ex.StackTrace ?? ""; + var msg = $"[Exception] Type: {ex.GetType().FullName}\nMessage: {ex.Message}\nStackTrace: {stackTrace}"; + if (ex.InnerException != null) + { + msg += $"\nInnerException: {ex.InnerException.GetType().FullName} - {ex.InnerException.Message}\n{ex.InnerException.StackTrace}"; + } + WriteLogToFile(msg, LogType.Error); } public static void WriteLogToFile(string str, LogType logType = LogType.Info) { - string strLogType = "Info"; - switch (logType) - { - case LogType.Event: - strLogType = "Event"; - break; - case LogType.Trace: - strLogType = "Trace"; - break; - case LogType.Error: - strLogType = "Error"; - break; - } + string strLogType = logType.ToString(); try { var file = App.RootPath + LogFile; @@ -39,16 +36,30 @@ namespace Ink_Canvas.Helpers { Directory.CreateDirectory(App.RootPath); } - StreamWriter sw = new StreamWriter(file, true); - sw.WriteLine(string.Format("{0} [{1}] {2}", DateTime.Now.ToString("O"), strLogType, str)); - sw.Close(); + var threadId = Thread.CurrentThread.ManagedThreadId; + var callingMethod = new StackTrace(2, true).GetFrame(0); + string callerInfo = ""; + if (callingMethod != null) + { + var method = callingMethod.GetMethod(); + if (method != null) + { + var className = method.DeclaringType != null ? method.DeclaringType.FullName : ""; + callerInfo = $"{className}.{method.Name}"; + } + } + string logLine = string.Format("{0} [T{1}] [{2}] [{3}] {4}", DateTime.Now.ToString("O"), threadId, strLogType, callerInfo, str); + using (StreamWriter sw = new StreamWriter(file, true)) + { + sw.WriteLine(logLine); + } } catch { } } internal static void WriteLogToFile(string v, object warning) { - throw new NotImplementedException(); + WriteLogToFile($"[Warning] {v}", LogType.Warning); } public enum LogType diff --git a/Ink Canvas/Windows/RandWindow.xaml b/Ink Canvas/Windows/RandWindow.xaml index 62dddffb..253d13d4 100644 --- a/Ink Canvas/Windows/RandWindow.xaml +++ b/Ink Canvas/Windows/RandWindow.xaml @@ -106,7 +106,7 @@ - + diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index b061c064..631af792 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -207,8 +207,20 @@ namespace Ink_Canvas { Close(); } + private bool isIslandCallerFirstClick = true; + private void BorderBtnIslandCaller_MouseUp(object sender, MouseButtonEventArgs e) { + if (isIslandCallerFirstClick) + { + MessageBox.Show( + "首次使用ClassIsland点名功能,请确保已安装ClassIsland和Island caller插件。\n" + + "如未安装,请前往官网下载并安装后再使用。", + "提示", MessageBoxButton.OK, MessageBoxImage.Information); + isIslandCallerFirstClick = false; + return; + } + try { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache index ef098d717d7bde04bde765fa54f75e80668538ed..f9524d04c3d7b4b6b2acaf625cf14e16742d3641 100644 GIT binary patch delta 54 xcmex6k?G_FrVVzCj0}?tLsd7=XPm?YVNRaU*tc1U^#|kR$8Ca0Led(f$8r=rVVzC7K~PDnK`Le`uh5=R{EaK&I-=1P)Z>;F*6Uu)&&XWWh*!*=9MKD z>w7vn=NF|;F67gkEW^^b`4b}xlNF;4>8AMPC#Iwpfy~(~!_vm&#l*nCz*r9?SQ>x~ WAkAn^x}o8jd2SJKx23Z`Y5)Mn8| diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources index 096bb1e4176034eeba17b2766f64baa0e2311432..04f1ddd79c8fccf815eb2daf1e14e112ae814dd8 100644 GIT binary patch delta 432 zcmWmA%Ps=}0EOYspxU}r>(WxU(qS;ALyfw%HN~jQ#1oh_v1}wVdy!gLNvOrd#xvMW zFz?_2EUbi=XvXj4e5%Ak;W9Jk%5F6%tFQ-=CJ?;SuA1+IjC613i4QmhBXwh zjty*L3)?87gfe#U|3d}4*uy>y9H5Fr9N`!zuBV%yMNvvSR>`y-%P?g(-!QLIMxyD* zD)pLeSM7T3;{2!a`h9=*)Y9ZYAP|f^`oE&!lT66*MYSON+9^XO`r(JOszUQh?y{ww OIhJH5-T1S49s2{gGqLIb delta 423 zcmWmAyEDT80LSq*DAm%3SE-^@1qp3LJlm3@>XFshsf)p#$83;0W<4hplc8g`+>ym* z^9LAA4u6D;Z|{DeyM_hjw(pk4^*-L>IadLKqQ5 z(Su&}p&tW?VGu)zV;BjHU=(9WVjL4lVG?OfLBup>FbfGX<}i;8vQV%96^qcYgk`K? z6>C^W4tW%?flV|!6tRVE?4X2Ql(C0>9N^G)bmJp0q?1;qV4Pc(k|Emam2nvl$7*i$ zr(u5I)xVzZf6cn}`d}nvMG;-C?D2R~p?B9WXCmf|Bc$NqyPW_ diff --git a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs index bc5d3198..75a000f4 100644 --- a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs +++ b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "695B3561F1F2C3284724BFAA9122C85C2EF5221A" +#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A29F1514A9DC6332F074303F230464CD5C24A898" //------------------------------------------------------------------------------ // // 此代码由工具生成。 diff --git a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs index bc5d3198..75a000f4 100644 --- a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs +++ b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "695B3561F1F2C3284724BFAA9122C85C2EF5221A" +#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A29F1514A9DC6332F074303F230464CD5C24A898" //------------------------------------------------------------------------------ // // 此代码由工具生成。