Loading CountDownList/App.xaml.cs +68 −1 Original line number Diff line number Diff line using System.Configuration; using System.Data; using System.Text; using System.Windows; using System.Windows.Threading; namespace CountDownList { Loading @@ -9,6 +11,71 @@ namespace CountDownList /// </summary> public partial class App : Application { public App() { //首先注册开始和退出事件 this.Startup += new StartupEventHandler(App_Startup); this.Exit += new ExitEventHandler(App_Exit); } void App_Startup(object sender, StartupEventArgs e) { //UI线程未捕获异常处理事件 this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); //Task线程内未捕获异常处理事件 TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; //非UI线程未捕获异常处理事件 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } void App_Exit(object sender, ExitEventArgs e) { //程序退出时需要处理的业务 } void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { try { e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "UI上出现的异常"); window.ShowDialog(); } catch (Exception ex) { //此时程序出现严重异常,将强制结束退出 CountDownList.UI.WindowFrame.Excption window = new(ex, "UI上出现的异常"); window.ShowDialog(); } } 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); //} CountDownList.UI.WindowFrame.Excption window = new((Exception)e.ExceptionObject, "程序异常"); window.ShowDialog(); } void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { //task线程内未处理捕获 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "其他线程出现异常"); window.ShowDialog(); //e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃) } } } CountDownList/AssemblyInfo.cs +2 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ using System.Windows; // 公司 [assembly: AssemblyCompany("shRabbit")] // 版权 [assembly: AssemblyCopyright("Copyright shRabbit 2014")] [assembly: AssemblyCopyright("Copyright shRabbit 2024")] // 配置文件,如零售、发布、调试等信息。程序集在运行时不会使用该信息 [assembly: AssemblyConfiguration("")] // 程序集的版本信息由下面四个值组成: Loading @@ -31,7 +31,7 @@ using System.Windows; // // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: [assembly: AssemblyVersion("1.1.7.*")] [assembly: AssemblyVersion("1.1.10.*")] /// <summary> /// 使用此类前需要把[assembly: ComVisible(false)]改为true Loading CountDownList/Class/ScrollViewer.cs +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ namespace CountDownList //可以更改一次滚动的距离倍数 (WheelChange可能为正负数!) double newOffset = LastLocation - (WheelChange); //Animation并不会改变真正的VerticalOffset(只是它的依赖属性) 所以将VOffset设置到上一次的滚动位置 (相当于衔接上一个动画) ScrollToVerticalOffset(LastLocation); ScrollToVerticalOffset(LastLocation * 0.75); //碰到底部和顶部时的处理 if (newOffset < 0) newOffset = 0; Loading CountDownList/CountDownList.csproj +9 −0 Original line number Diff line number Diff line <Project Sdk="Microsoft.NET.Sdk"> <Import Condition=" '$(EAZFUSCATOR_NET_HOME)' != '' and Exists('$(EAZFUSCATOR_NET_HOME)\Integration\MSBuild\Eazfuscator.NET.targets') " Project="$(EAZFUSCATOR_NET_HOME)\Integration\MSBuild\Eazfuscator.NET.targets" /> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net8.0-windows7.0</TargetFramework> Loading @@ -11,6 +13,13 @@ <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> </PropertyGroup> <PropertyGroup> <!-- Eazfuscator.NET is integrated with this project at MSBuild level: https://help.gapotchenko.com/eazfuscator.net/kb/100036 --> <EazfuscatorIntegration>MSBuild</EazfuscatorIntegration> <EazfuscatorActiveConfiguration>Release</EazfuscatorActiveConfiguration> <EazfuscatorCompatibilityVersion>2024.2</EazfuscatorCompatibilityVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <Deterministic>False</Deterministic> </PropertyGroup> Loading CountDownList/UI/WindowFrame/EditWindow.xaml.cs +14 −7 Original line number Diff line number Diff line Loading @@ -191,6 +191,8 @@ namespace CountDownList.UI.Window } // 创建文件流并读取文件 try { ImageBrush i = new(); i.ImageSource = new BitmapImage(new Uri($@"Data\Image\{Path.GetFileName(dialog.FileName)}", UriKind.Relative)); i.Stretch = Stretch.UniformToFill; Loading @@ -201,6 +203,11 @@ namespace CountDownList.UI.Window preview.LabelBackground = i; imageView.Background = pre; } catch (Exception ex) { HandyControl.Controls.MessageBox.Show($"打开失败\n{ex.Message}\n\n{ex}\n{ex.Source}\n{ex.StackTrace}", "获取图片异常", MessageBoxButton.OK, MessageBoxImage.Error); } } } } Loading Loading
CountDownList/App.xaml.cs +68 −1 Original line number Diff line number Diff line using System.Configuration; using System.Data; using System.Text; using System.Windows; using System.Windows.Threading; namespace CountDownList { Loading @@ -9,6 +11,71 @@ namespace CountDownList /// </summary> public partial class App : Application { public App() { //首先注册开始和退出事件 this.Startup += new StartupEventHandler(App_Startup); this.Exit += new ExitEventHandler(App_Exit); } void App_Startup(object sender, StartupEventArgs e) { //UI线程未捕获异常处理事件 this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); //Task线程内未捕获异常处理事件 TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; //非UI线程未捕获异常处理事件 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } void App_Exit(object sender, ExitEventArgs e) { //程序退出时需要处理的业务 } void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { try { e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "UI上出现的异常"); window.ShowDialog(); } catch (Exception ex) { //此时程序出现严重异常,将强制结束退出 CountDownList.UI.WindowFrame.Excption window = new(ex, "UI上出现的异常"); window.ShowDialog(); } } 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); //} CountDownList.UI.WindowFrame.Excption window = new((Exception)e.ExceptionObject, "程序异常"); window.ShowDialog(); } void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { //task线程内未处理捕获 CountDownList.UI.WindowFrame.Excption window = new(e.Exception, "其他线程出现异常"); window.ShowDialog(); //e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃) } } }
CountDownList/AssemblyInfo.cs +2 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ using System.Windows; // 公司 [assembly: AssemblyCompany("shRabbit")] // 版权 [assembly: AssemblyCopyright("Copyright shRabbit 2014")] [assembly: AssemblyCopyright("Copyright shRabbit 2024")] // 配置文件,如零售、发布、调试等信息。程序集在运行时不会使用该信息 [assembly: AssemblyConfiguration("")] // 程序集的版本信息由下面四个值组成: Loading @@ -31,7 +31,7 @@ using System.Windows; // // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: [assembly: AssemblyVersion("1.1.7.*")] [assembly: AssemblyVersion("1.1.10.*")] /// <summary> /// 使用此类前需要把[assembly: ComVisible(false)]改为true Loading
CountDownList/Class/ScrollViewer.cs +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ namespace CountDownList //可以更改一次滚动的距离倍数 (WheelChange可能为正负数!) double newOffset = LastLocation - (WheelChange); //Animation并不会改变真正的VerticalOffset(只是它的依赖属性) 所以将VOffset设置到上一次的滚动位置 (相当于衔接上一个动画) ScrollToVerticalOffset(LastLocation); ScrollToVerticalOffset(LastLocation * 0.75); //碰到底部和顶部时的处理 if (newOffset < 0) newOffset = 0; Loading
CountDownList/CountDownList.csproj +9 −0 Original line number Diff line number Diff line <Project Sdk="Microsoft.NET.Sdk"> <Import Condition=" '$(EAZFUSCATOR_NET_HOME)' != '' and Exists('$(EAZFUSCATOR_NET_HOME)\Integration\MSBuild\Eazfuscator.NET.targets') " Project="$(EAZFUSCATOR_NET_HOME)\Integration\MSBuild\Eazfuscator.NET.targets" /> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net8.0-windows7.0</TargetFramework> Loading @@ -11,6 +13,13 @@ <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> </PropertyGroup> <PropertyGroup> <!-- Eazfuscator.NET is integrated with this project at MSBuild level: https://help.gapotchenko.com/eazfuscator.net/kb/100036 --> <EazfuscatorIntegration>MSBuild</EazfuscatorIntegration> <EazfuscatorActiveConfiguration>Release</EazfuscatorActiveConfiguration> <EazfuscatorCompatibilityVersion>2024.2</EazfuscatorCompatibilityVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <Deterministic>False</Deterministic> </PropertyGroup> Loading
CountDownList/UI/WindowFrame/EditWindow.xaml.cs +14 −7 Original line number Diff line number Diff line Loading @@ -191,6 +191,8 @@ namespace CountDownList.UI.Window } // 创建文件流并读取文件 try { ImageBrush i = new(); i.ImageSource = new BitmapImage(new Uri($@"Data\Image\{Path.GetFileName(dialog.FileName)}", UriKind.Relative)); i.Stretch = Stretch.UniformToFill; Loading @@ -201,6 +203,11 @@ namespace CountDownList.UI.Window preview.LabelBackground = i; imageView.Background = pre; } catch (Exception ex) { HandyControl.Controls.MessageBox.Show($"打开失败\n{ex.Message}\n\n{ex}\n{ex.Source}\n{ex.StackTrace}", "获取图片异常", MessageBoxButton.OK, MessageBoxImage.Error); } } } } Loading