Loading CountDownList/App.config +19 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="CountDownList.MiscSetting" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="CountDownList.MiscSetting" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <CountDownList.MiscSetting> Loading Loading @@ -52,6 +55,21 @@ <setting name="AutoUpdate" serializeAs="String"> <value>False</value> </setting> <setting name="Domain" serializeAs="String"> <value>lc.shrabbit.com</value> </setting> <setting name="LogLevel" serializeAs="String"> <value>2</value> </setting> </CountDownList.MiscSetting> </userSettings> <applicationSettings> <CountDownList.MiscSetting> <setting name="StopSupport" serializeAs="String"> <value>05/13/2025 21:42:00</value> </setting> </CountDownList.MiscSetting> </applicationSettings> </configuration> CountDownList/App.xaml.cs +38 −18 Original line number Diff line number Diff line using System.Configuration; using CountDownList.Class; using System.Configuration; using System.Data; using System.Diagnostics; using System.Text; using System.Windows; using System.Windows.Threading; Loading @@ -11,14 +13,18 @@ namespace CountDownList /// </summary> public partial class App : Application { #if !DEBUG public static LogFile logFile; public App() { logFile = new((LogLevel)MiscSetting.Default.LogLevel); //首先注册开始和退出事件 this.Startup += new StartupEventHandler(App_Startup); this.Exit += new ExitEventHandler(App_Exit); } void App_Startup(object sender, StartupEventArgs e) { //UI线程未捕获异常处理事件 Loading @@ -32,10 +38,20 @@ namespace CountDownList void App_Exit(object sender, ExitEventArgs e) { //程序退出时需要处理的业务 logFile.Close(); } void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { Type t = e.Exception.GetType(); logFile.Fatel($"{t.FullName}: {e.Exception.Message}\n{e.Exception.StackTrace}"); logFile.Close(); #if DEBUG //throw e.Exception; #endif #if !DEBUG try { e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出 Loading @@ -48,36 +64,40 @@ namespace CountDownList CountDownList.UI.WindowFrame.Excption window = new(ex, "UI上出现的异常"); window.ShowDialog(); } #endif } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { //StringBuilder sbEx = new StringBuilder(); //if (e.IsTerminating) //{ // sbEx.Append("非UI线程发生致命错误"); //} //sbEx.Append("非UI线程异常:"); //if (e.ExceptionObject is Exception) //{ // sbEx.Append(.Message); //} //else //{ // sbEx.Append(e.ExceptionObject); //} Type t = ((Exception)e.ExceptionObject).GetType(); logFile.Fatel($"{t.FullName}: {((Exception)e.ExceptionObject).Message}\n{((Exception)e.ExceptionObject).StackTrace}"); logFile.Close(); #if DEBUG //throw (Exception)e.ExceptionObject; #endif #if !DEBUG CountDownList.UI.WindowFrame.Excption window = new((Exception)e.ExceptionObject, "程序异常"); window.ShowDialog(); #endif } void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { Type t = e.Exception.GetType(); logFile.Fatel($"{t.FullName}: {e.Exception.Message}\n{e.Exception.StackTrace}"); logFile.Close(); #if DEBUG //throw e.Exception; #endif #if !DEBUG //task线程内未处理捕获 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "其他线程出现异常"); window.ShowDialog(); //e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃) } #endif } } } CountDownList/Class/ClassName.cs 0 → 100644 +24 −0 Original line number Diff line number Diff line using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CountDownList.Class { /// <summary> /// 继承此类以获取类名 /// </summary> public class ClassName { public static string className = string.Empty; public ClassName() { System.Diagnostics.StackTrace ss = new System.Diagnostics.StackTrace(true); System.Reflection.MethodBase mb = ss.GetFrame(1).GetMethod(); className = mb.DeclaringType.FullName; } } } CountDownList/Class/Json.cs +4 −1 Original line number Diff line number Diff line Loading @@ -10,13 +10,14 @@ namespace CountDownList.Class /// <summary> /// 解析json /// </summary> public class UpdateFileJson public class UpdateFileJson:ClassName { public JsonContent.Rootobject ConvertToClass(string JsonString) { //JsonContent.Rootobject obj = new(); var dict = JsonSerializer.Deserialize<JsonContent.Rootobject>(JsonString); App.logFile.Info($"反序列化JSON完成", className); return dict; } } Loading @@ -42,6 +43,8 @@ namespace CountDownList.Class public string source { get; set; } public string fileName { get; set; } public string updateMsg { get; set; } public string link { get; set; } public string date { get; set; } } } #pragma warning disable IDE1006, CS8618 Loading CountDownList/Class/ListCore.cs +58 −5 Original line number Diff line number Diff line #pragma warning disable CA1416 #pragma warning disable CA1416, CS8602 using System; using System.Collections; using System.Collections.Generic; Loading @@ -14,6 +14,7 @@ using System.Windows.Automation.Peers; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Xml.Linq; using CountDownList.Controls; using CountDownList.UI.Window; using HandyControl.Controls; Loading @@ -24,7 +25,7 @@ namespace CountDownList.Class /// <summary> /// 次类提供了CountDownList的基本操作,如创建、修改、删除、查找、分享等功能 /// </summary> public class ListCore public class ListCore:ClassName { public StackPanel DoingPanel , WcPanel, CountPanel; public Expander DoingE, WcE, CountE; Loading @@ -44,6 +45,7 @@ namespace CountDownList.Class FrameworkElement Window ) { App.logFile.Info("开始初始化", className); DoingPanel = doingPanel; WcPanel = wcPanel; CountPanel = countPanel; Loading @@ -53,6 +55,7 @@ namespace CountDownList.Class RootWindow = Window; RefreshNumber(); App.logFile.Info("初始化结束", className); } /// <summary> Loading @@ -62,7 +65,6 @@ namespace CountDownList.Class { while (true) { DoingE.Header = $"进行中({DoingPanel.Children.Count})"; WcE.Header = $"已完成({WcPanel.Children.Count})"; CountE.Header = $"正计时({CountPanel.Children.Count})"; Loading Loading @@ -95,6 +97,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加倒计时Label ({t})", className); if (InsertIndex != null) { try Loading Loading @@ -143,6 +147,8 @@ namespace CountDownList.Class { await Task.Delay(250); } App.logFile.Info($"Label {t} 已移入“已完成”区域", className); } if (WcE.IsExpanded && IsOpen && IsUserVisible(lb, RootWindow)) Loading Loading @@ -193,6 +199,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加倒计时Label ({label.Title})", className); if (InsertIndex != null) { try Loading Loading @@ -244,6 +252,7 @@ namespace CountDownList.Class await Task.Delay(250); } } App.logFile.Info($"Label {label.Title} 已移入“已完成”区域", className); } if (WcE.IsExpanded && IsOpen && IsUserVisible(lb, RootWindow)) Loading Loading @@ -286,6 +295,7 @@ namespace CountDownList.Class private void CountDown_OnShare(object? sender, EventArgs e) { new Share((ListLabel)sender, DateTime.Now).ShowDialog(); App.logFile.Info($"打开分享({((ListLabel)sender).Title})", className); } /// <summary> Loading @@ -300,10 +310,12 @@ namespace CountDownList.Class if (((Controls.ListLabel)sender).IsReadOnly == false) { DeleteForElement((Controls.ListLabel)sender); App.logFile.Info($"已删除({((ListLabel)sender).Title})", className); } else { HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除\n须将该标签的xml属性IsReadOnly设为false", $"删除 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error); App.logFile.Warn($"删除失败,标签为只读({((ListLabel)sender).Title})", className); } } } Loading @@ -326,6 +338,7 @@ namespace CountDownList.Class HandyControl.Controls.MessageBox.Show("编辑失败,此标签禁止编辑\n须将该标签的xml属性IsReadOnly设为false", $"编辑 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error); } } App.logFile.Info($"编辑标签({((ListLabel)sender).Title})", className); } /// <summary> Loading @@ -348,6 +361,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加正计时Label ({t})", className); if (InsertIndex != null) { try Loading Loading @@ -407,6 +422,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加正计时Label ({label.Title})", className); if (InsertIndex != null) { try Loading Loading @@ -498,6 +515,7 @@ namespace CountDownList.Class DoingPanel.Children.Remove(element); WcPanel.Children.Remove(element); CountPanel.Children.Remove(element); App.logFile.Info($"已删除“{element.Title}”", className); } public List<ListLabel> ScanToCollection() Loading Loading @@ -529,6 +547,7 @@ namespace CountDownList.Class { List<ListP> l = new(); App.logFile.Info($"开始收集Labels信息并转成列表", className); //扫描进行中 foreach (Controls.ListLabel item in DoingPanel.Children) { Loading Loading @@ -569,9 +588,14 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(倒计时容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } catch (Exception) { App.logFile.Error($"Label资源损坏,正在重启并删除CountDownList.xml", className); System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动 Loading Loading @@ -632,6 +656,7 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(正计时容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } //扫描已完成 Loading Loading @@ -672,6 +697,7 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(已完成容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } return l; } Loading @@ -683,6 +709,7 @@ namespace CountDownList.Class public void OpenMainWindow() { Home home = new(ScanToListP()); App.logFile.Info($"绑定主页操作事件", className); home.OnAdd += Home_OnAdd; home.OnEdit += Home_OnEdit; home.OnDelete += Home_OnDelete; Loading @@ -704,6 +731,7 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { shareElement = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发分享({shareElement.Title})", className); Share share = new(shareElement, DateTime.Now); share.ShowDialog(); } Loading @@ -711,7 +739,6 @@ namespace CountDownList.Class catch { } } /// <summary> Loading @@ -727,6 +754,7 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { delElememt = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发编辑({delElememt.Title})", className); if (delElememt.IsReadOnly == false) { Loading Loading @@ -760,6 +788,8 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { editElement = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发删除({editElement.Title})", className); if (editElement.IsReadOnly == false) { EditAndChange(editElement); Loading Loading @@ -913,6 +943,22 @@ namespace CountDownList.Class return rect.Contains(bounds.TopLeft) || rect.Contains(bounds.BottomRight); } /// <summary> /// 控件是否在窗口上显示,代码来自 https://cloud.tencent.com/developer/ask/sof/116724 /// </summary> /// <param name="element">要判定的元素</param> /// <param name="container">父元素</param> /// <returns>如果控件被父元素遮住,返回false</returns> public static bool IsUserVisibleS(FrameworkElement element, FrameworkElement container) { if (!element.IsVisible) return false; Rect bounds = element.TransformToAncestor(container).TransformBounds(new Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight)); Rect rect = new Rect(0.0, 0.0, container.ActualWidth, container.ActualHeight); return rect.Contains(bounds.TopLeft) || rect.Contains(bounds.BottomRight); } /// <summary> /// 生成随机图片 /// <param name="ExtraMode"> Loading @@ -923,12 +969,15 @@ namespace CountDownList.Class { try { App.logFile.Info($"调用GenerateRandomImage", className); switch (ExtraMode) { case ExtraMode.MinecraftOnly: ImageBrush mcO = new(); mcO.ImageSource = new BitmapImage(new Uri($@"UI\test.png", UriKind.Relative)); mcO.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:MinecraftOnly -> {mcO.ImageSource}", "CountDownList.ListCore"); return mcO; case ExtraMode.Minecraft: Loading @@ -946,6 +995,7 @@ namespace CountDownList.Class ImageBrush mc = new(); mc.ImageSource = new BitmapImage(new Uri(file, UriKind.Relative)); mc.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:Minecraft -> {mc.ImageSource}", "CountDownList.ListCore"); return mc; case ExtraMode.GenshinExtra: Loading @@ -963,6 +1013,7 @@ namespace CountDownList.Class ImageBrush mcYsE = new(); mcYsE.ImageSource = new BitmapImage(new Uri(fileYsE, UriKind.Relative)); mcYsE.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:GenshinExtra -> {mcYsE.ImageSource}", "CountDownList.ListCore"); return mcYsE; case ExtraMode.GenshinNormal: Loading @@ -980,6 +1031,7 @@ namespace CountDownList.Class ImageBrush mcYs = new(); mcYs.ImageSource = new BitmapImage(new Uri(fileYs, UriKind.Relative)); mcYs.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:GenshinNormal -> {mcYs.ImageSource}", "CountDownList.ListCore"); return mcYs; case ExtraMode.Custom: Loading @@ -997,6 +1049,7 @@ namespace CountDownList.Class ImageBrush mcc = new(); mcc.ImageSource = new BitmapImage(new Uri(filec, UriKind.Relative)); mcc.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:Custom -> {mcc.ImageSource}", "CountDownList.ListCore"); return mcc; default: Loading Loading
CountDownList/App.config +19 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="CountDownList.MiscSetting" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="CountDownList.MiscSetting" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <CountDownList.MiscSetting> Loading Loading @@ -52,6 +55,21 @@ <setting name="AutoUpdate" serializeAs="String"> <value>False</value> </setting> <setting name="Domain" serializeAs="String"> <value>lc.shrabbit.com</value> </setting> <setting name="LogLevel" serializeAs="String"> <value>2</value> </setting> </CountDownList.MiscSetting> </userSettings> <applicationSettings> <CountDownList.MiscSetting> <setting name="StopSupport" serializeAs="String"> <value>05/13/2025 21:42:00</value> </setting> </CountDownList.MiscSetting> </applicationSettings> </configuration>
CountDownList/App.xaml.cs +38 −18 Original line number Diff line number Diff line using System.Configuration; using CountDownList.Class; using System.Configuration; using System.Data; using System.Diagnostics; using System.Text; using System.Windows; using System.Windows.Threading; Loading @@ -11,14 +13,18 @@ namespace CountDownList /// </summary> public partial class App : Application { #if !DEBUG public static LogFile logFile; public App() { logFile = new((LogLevel)MiscSetting.Default.LogLevel); //首先注册开始和退出事件 this.Startup += new StartupEventHandler(App_Startup); this.Exit += new ExitEventHandler(App_Exit); } void App_Startup(object sender, StartupEventArgs e) { //UI线程未捕获异常处理事件 Loading @@ -32,10 +38,20 @@ namespace CountDownList void App_Exit(object sender, ExitEventArgs e) { //程序退出时需要处理的业务 logFile.Close(); } void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { Type t = e.Exception.GetType(); logFile.Fatel($"{t.FullName}: {e.Exception.Message}\n{e.Exception.StackTrace}"); logFile.Close(); #if DEBUG //throw e.Exception; #endif #if !DEBUG try { e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出 Loading @@ -48,36 +64,40 @@ namespace CountDownList CountDownList.UI.WindowFrame.Excption window = new(ex, "UI上出现的异常"); window.ShowDialog(); } #endif } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { //StringBuilder sbEx = new StringBuilder(); //if (e.IsTerminating) //{ // sbEx.Append("非UI线程发生致命错误"); //} //sbEx.Append("非UI线程异常:"); //if (e.ExceptionObject is Exception) //{ // sbEx.Append(.Message); //} //else //{ // sbEx.Append(e.ExceptionObject); //} Type t = ((Exception)e.ExceptionObject).GetType(); logFile.Fatel($"{t.FullName}: {((Exception)e.ExceptionObject).Message}\n{((Exception)e.ExceptionObject).StackTrace}"); logFile.Close(); #if DEBUG //throw (Exception)e.ExceptionObject; #endif #if !DEBUG CountDownList.UI.WindowFrame.Excption window = new((Exception)e.ExceptionObject, "程序异常"); window.ShowDialog(); #endif } void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { Type t = e.Exception.GetType(); logFile.Fatel($"{t.FullName}: {e.Exception.Message}\n{e.Exception.StackTrace}"); logFile.Close(); #if DEBUG //throw e.Exception; #endif #if !DEBUG //task线程内未处理捕获 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "其他线程出现异常"); window.ShowDialog(); //e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃) } #endif } } }
CountDownList/Class/ClassName.cs 0 → 100644 +24 −0 Original line number Diff line number Diff line using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CountDownList.Class { /// <summary> /// 继承此类以获取类名 /// </summary> public class ClassName { public static string className = string.Empty; public ClassName() { System.Diagnostics.StackTrace ss = new System.Diagnostics.StackTrace(true); System.Reflection.MethodBase mb = ss.GetFrame(1).GetMethod(); className = mb.DeclaringType.FullName; } } }
CountDownList/Class/Json.cs +4 −1 Original line number Diff line number Diff line Loading @@ -10,13 +10,14 @@ namespace CountDownList.Class /// <summary> /// 解析json /// </summary> public class UpdateFileJson public class UpdateFileJson:ClassName { public JsonContent.Rootobject ConvertToClass(string JsonString) { //JsonContent.Rootobject obj = new(); var dict = JsonSerializer.Deserialize<JsonContent.Rootobject>(JsonString); App.logFile.Info($"反序列化JSON完成", className); return dict; } } Loading @@ -42,6 +43,8 @@ namespace CountDownList.Class public string source { get; set; } public string fileName { get; set; } public string updateMsg { get; set; } public string link { get; set; } public string date { get; set; } } } #pragma warning disable IDE1006, CS8618 Loading
CountDownList/Class/ListCore.cs +58 −5 Original line number Diff line number Diff line #pragma warning disable CA1416 #pragma warning disable CA1416, CS8602 using System; using System.Collections; using System.Collections.Generic; Loading @@ -14,6 +14,7 @@ using System.Windows.Automation.Peers; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Xml.Linq; using CountDownList.Controls; using CountDownList.UI.Window; using HandyControl.Controls; Loading @@ -24,7 +25,7 @@ namespace CountDownList.Class /// <summary> /// 次类提供了CountDownList的基本操作,如创建、修改、删除、查找、分享等功能 /// </summary> public class ListCore public class ListCore:ClassName { public StackPanel DoingPanel , WcPanel, CountPanel; public Expander DoingE, WcE, CountE; Loading @@ -44,6 +45,7 @@ namespace CountDownList.Class FrameworkElement Window ) { App.logFile.Info("开始初始化", className); DoingPanel = doingPanel; WcPanel = wcPanel; CountPanel = countPanel; Loading @@ -53,6 +55,7 @@ namespace CountDownList.Class RootWindow = Window; RefreshNumber(); App.logFile.Info("初始化结束", className); } /// <summary> Loading @@ -62,7 +65,6 @@ namespace CountDownList.Class { while (true) { DoingE.Header = $"进行中({DoingPanel.Children.Count})"; WcE.Header = $"已完成({WcPanel.Children.Count})"; CountE.Header = $"正计时({CountPanel.Children.Count})"; Loading Loading @@ -95,6 +97,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加倒计时Label ({t})", className); if (InsertIndex != null) { try Loading Loading @@ -143,6 +147,8 @@ namespace CountDownList.Class { await Task.Delay(250); } App.logFile.Info($"Label {t} 已移入“已完成”区域", className); } if (WcE.IsExpanded && IsOpen && IsUserVisible(lb, RootWindow)) Loading Loading @@ -193,6 +199,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加倒计时Label ({label.Title})", className); if (InsertIndex != null) { try Loading Loading @@ -244,6 +252,7 @@ namespace CountDownList.Class await Task.Delay(250); } } App.logFile.Info($"Label {label.Title} 已移入“已完成”区域", className); } if (WcE.IsExpanded && IsOpen && IsUserVisible(lb, RootWindow)) Loading Loading @@ -286,6 +295,7 @@ namespace CountDownList.Class private void CountDown_OnShare(object? sender, EventArgs e) { new Share((ListLabel)sender, DateTime.Now).ShowDialog(); App.logFile.Info($"打开分享({((ListLabel)sender).Title})", className); } /// <summary> Loading @@ -300,10 +310,12 @@ namespace CountDownList.Class if (((Controls.ListLabel)sender).IsReadOnly == false) { DeleteForElement((Controls.ListLabel)sender); App.logFile.Info($"已删除({((ListLabel)sender).Title})", className); } else { HandyControl.Controls.MessageBox.Show("删除失败,此标签禁止删除\n须将该标签的xml属性IsReadOnly设为false", $"删除 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error); App.logFile.Warn($"删除失败,标签为只读({((ListLabel)sender).Title})", className); } } } Loading @@ -326,6 +338,7 @@ namespace CountDownList.Class HandyControl.Controls.MessageBox.Show("编辑失败,此标签禁止编辑\n须将该标签的xml属性IsReadOnly设为false", $"编辑 {((Controls.ListLabel)sender).Title}", button: MessageBoxButton.OK, icon: MessageBoxImage.Error); } } App.logFile.Info($"编辑标签({((ListLabel)sender).Title})", className); } /// <summary> Loading @@ -348,6 +361,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加正计时Label ({t})", className); if (InsertIndex != null) { try Loading Loading @@ -407,6 +422,8 @@ namespace CountDownList.Class lb.OnDelete += CountDown_OnDelete; lb.OnShare += CountDown_OnShare; App.logFile.Info($"成功添加正计时Label ({label.Title})", className); if (InsertIndex != null) { try Loading Loading @@ -498,6 +515,7 @@ namespace CountDownList.Class DoingPanel.Children.Remove(element); WcPanel.Children.Remove(element); CountPanel.Children.Remove(element); App.logFile.Info($"已删除“{element.Title}”", className); } public List<ListLabel> ScanToCollection() Loading Loading @@ -529,6 +547,7 @@ namespace CountDownList.Class { List<ListP> l = new(); App.logFile.Info($"开始收集Labels信息并转成列表", className); //扫描进行中 foreach (Controls.ListLabel item in DoingPanel.Children) { Loading Loading @@ -569,9 +588,14 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(倒计时容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } catch (Exception) { App.logFile.Error($"Label资源损坏,正在重启并删除CountDownList.xml", className); System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动 Loading Loading @@ -632,6 +656,7 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(正计时容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } //扫描已完成 Loading Loading @@ -672,6 +697,7 @@ namespace CountDownList.Class DarkText = d, Own = item }); App.logFile.Info($"(已完成容器)标题:{t}\n开始时间:{st}\n结束时间:{et}\n背景资源:{bg}\n深色文本{d}", className); } return l; } Loading @@ -683,6 +709,7 @@ namespace CountDownList.Class public void OpenMainWindow() { Home home = new(ScanToListP()); App.logFile.Info($"绑定主页操作事件", className); home.OnAdd += Home_OnAdd; home.OnEdit += Home_OnEdit; home.OnDelete += Home_OnDelete; Loading @@ -704,6 +731,7 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { shareElement = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发分享({shareElement.Title})", className); Share share = new(shareElement, DateTime.Now); share.ShowDialog(); } Loading @@ -711,7 +739,6 @@ namespace CountDownList.Class catch { } } /// <summary> Loading @@ -727,6 +754,7 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { delElememt = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发编辑({delElememt.Title})", className); if (delElememt.IsReadOnly == false) { Loading Loading @@ -760,6 +788,8 @@ namespace CountDownList.Class if ((ListP)((Home)sender).listView.SelectedItem != null) { editElement = ((ListP)((Home)sender).listView.SelectedItem).Own; App.logFile.Info($"在主页触发删除({editElement.Title})", className); if (editElement.IsReadOnly == false) { EditAndChange(editElement); Loading Loading @@ -913,6 +943,22 @@ namespace CountDownList.Class return rect.Contains(bounds.TopLeft) || rect.Contains(bounds.BottomRight); } /// <summary> /// 控件是否在窗口上显示,代码来自 https://cloud.tencent.com/developer/ask/sof/116724 /// </summary> /// <param name="element">要判定的元素</param> /// <param name="container">父元素</param> /// <returns>如果控件被父元素遮住,返回false</returns> public static bool IsUserVisibleS(FrameworkElement element, FrameworkElement container) { if (!element.IsVisible) return false; Rect bounds = element.TransformToAncestor(container).TransformBounds(new Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight)); Rect rect = new Rect(0.0, 0.0, container.ActualWidth, container.ActualHeight); return rect.Contains(bounds.TopLeft) || rect.Contains(bounds.BottomRight); } /// <summary> /// 生成随机图片 /// <param name="ExtraMode"> Loading @@ -923,12 +969,15 @@ namespace CountDownList.Class { try { App.logFile.Info($"调用GenerateRandomImage", className); switch (ExtraMode) { case ExtraMode.MinecraftOnly: ImageBrush mcO = new(); mcO.ImageSource = new BitmapImage(new Uri($@"UI\test.png", UriKind.Relative)); mcO.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:MinecraftOnly -> {mcO.ImageSource}", "CountDownList.ListCore"); return mcO; case ExtraMode.Minecraft: Loading @@ -946,6 +995,7 @@ namespace CountDownList.Class ImageBrush mc = new(); mc.ImageSource = new BitmapImage(new Uri(file, UriKind.Relative)); mc.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:Minecraft -> {mc.ImageSource}", "CountDownList.ListCore"); return mc; case ExtraMode.GenshinExtra: Loading @@ -963,6 +1013,7 @@ namespace CountDownList.Class ImageBrush mcYsE = new(); mcYsE.ImageSource = new BitmapImage(new Uri(fileYsE, UriKind.Relative)); mcYsE.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:GenshinExtra -> {mcYsE.ImageSource}", "CountDownList.ListCore"); return mcYsE; case ExtraMode.GenshinNormal: Loading @@ -980,6 +1031,7 @@ namespace CountDownList.Class ImageBrush mcYs = new(); mcYs.ImageSource = new BitmapImage(new Uri(fileYs, UriKind.Relative)); mcYs.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:GenshinNormal -> {mcYs.ImageSource}", "CountDownList.ListCore"); return mcYs; case ExtraMode.Custom: Loading @@ -997,6 +1049,7 @@ namespace CountDownList.Class ImageBrush mcc = new(); mcc.ImageSource = new BitmapImage(new Uri(filec, UriKind.Relative)); mcc.Stretch = Stretch.UniformToFill; App.logFile.Info($"随机背景图返回结果:Custom -> {mcc.ImageSource}", "CountDownList.ListCore"); return mcc; default: Loading