From 62b85a4bbd526762cab0a6b1c1cc701535adf47f Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 10 Jan 2026 23:00:52 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettingsViews/AboutPanel.xaml | 20 +- .../SettingsViews/AboutPanel.xaml.cs | 211 +++++++++++++++--- 2 files changed, 189 insertions(+), 42 deletions(-) diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml index a74ffefa..a2505e31 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml @@ -73,8 +73,8 @@ - - + + @@ -84,8 +84,8 @@ - - + + @@ -113,13 +113,13 @@ - + - + @@ -128,7 +128,7 @@ - + @@ -146,7 +146,7 @@ - + @@ -164,7 +164,7 @@ - + @@ -181,7 +181,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs index ec925479..8cf4bdfb 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs @@ -1,7 +1,9 @@ using iNKORE.UI.WPF.Helpers; +using Ink_Canvas.Helpers; using OSVersionExtension; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Management; using System.Reflection; @@ -14,6 +16,7 @@ using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using Microsoft.Win32; namespace Ink_Canvas.Windows.SettingsViews { @@ -42,24 +45,78 @@ namespace Ink_Canvas.Windows.SettingsViews CopyrightBannerImage.Visibility = Visibility.Collapsed; } - // 关于页面构建时间 - var buildTime = FileBuildTimeHelper.GetBuildDateTime(Assembly.GetExecutingAssembly()); - if (buildTime != null) + try { - var bt = ((DateTimeOffset)buildTime).LocalDateTime; - var m = bt.Month.ToString().PadLeft(2, '0'); - var d = bt.Day.ToString().PadLeft(2, '0'); - var h = bt.Hour.ToString().PadLeft(2, '0'); - var min = bt.Minute.ToString().PadLeft(2, '0'); - var s = bt.Second.ToString().PadLeft(2, '0'); - AboutBuildTime.Text = - $"build-{bt.Year}-{m}-{d}-{h}:{min}:{s}"; + var version = Assembly.GetExecutingAssembly().GetName().Version; + AboutAppVersion.Text = $"InkCanvasForClass v{version}"; + } + catch (Exception ex) + { + AboutAppVersion.Text = "InkCanvasForClass v未知"; + System.Diagnostics.Debug.WriteLine($"获取软件版本失败: {ex.Message}"); + } + + try + { + string deviceId = DeviceIdentifier.GetDeviceId(); + AboutDeviceID.Text = deviceId; + } + catch (Exception ex) + { + AboutDeviceID.Text = "获取失败"; + System.Diagnostics.Debug.WriteLine($"获取设备ID失败: {ex.Message}"); + } + + try + { + var copyright = Assembly.GetExecutingAssembly().GetCustomAttribute(); + if (copyright != null && !string.IsNullOrEmpty(copyright.Copyright)) + { + var copyrightText = copyright.Copyright; + AboutCopyright.Text = copyrightText; + AboutBottomCopyright.Text = copyrightText.Replace("Copyright ©", "© Copyright") + " 所有"; + } + else + { + AboutCopyright.Text = "© Copyright 2024 Dubi906w 所有"; + AboutBottomCopyright.Text = "© Copyright 2024 Dubi906w(Doubx690i/kriastans) 所有"; + } + } + catch (Exception ex) + { + AboutCopyright.Text = "© Copyright 2024 Dubi906w 所有"; + AboutBottomCopyright.Text = "© Copyright 2024 Dubi906w(Doubx690i/kriastans) 所有"; + System.Diagnostics.Debug.WriteLine($"获取版权信息失败: {ex.Message}"); + } + + try + { + var assembly = Assembly.GetExecutingAssembly(); + var filePath = assembly.Location; + + if (File.Exists(filePath)) + { + var bt = File.GetCreationTime(filePath); + var m = bt.Month.ToString().PadLeft(2, '0'); + var d = bt.Day.ToString().PadLeft(2, '0'); + var h = bt.Hour.ToString().PadLeft(2, '0'); + var min = bt.Minute.ToString().PadLeft(2, '0'); + var s = bt.Second.ToString().PadLeft(2, '0'); + AboutBuildTime.Text = $"{bt.Year}-{m}-{d} {h}:{min}:{s}"; + } + else + { + AboutBuildTime.Text = "获取失败"; + } + } + catch (Exception ex) + { + AboutBuildTime.Text = "获取失败"; + System.Diagnostics.Debug.WriteLine($"获取构建时间失败: {ex.Message}"); } - // 关于页面系统版本 AboutSystemVersion.Text = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}"; - // 关于页面触摸设备 var _t_touch = new Thread(() => { var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count; @@ -68,6 +125,29 @@ namespace Ink_Canvas.Windows.SettingsViews AboutTouchTabletText.Text = $"{touchcount}个设备,{(support ? "支持触摸设备" : "无触摸支持")}"); }); _t_touch.Start(); + + CheckUpdateStatus(); + } + + private void CheckUpdateStatus() + { + try + { + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow != null) + { + var field = typeof(MainWindow).GetField("AvailableLatestVersion", BindingFlags.NonPublic | BindingFlags.Instance); + if (field != null) + { + var availableVersion = field.GetValue(mainWindow) as string; + if (!string.IsNullOrEmpty(availableVersion)) + { + UpdateAvailableIcon.Visibility = Visibility.Visible; + } + } + } + } + catch { } } public static class TouchTabletDetectHelper @@ -135,30 +215,48 @@ namespace Ink_Canvas.Windows.SettingsViews public static DateTimeOffset? GetBuildDateTime(Assembly assembly) { - var path = assembly.Location; - if (File.Exists(path)) + try { - var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)]; - using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) + var path = assembly.Location; + if (string.IsNullOrEmpty(path) || !File.Exists(path)) { + return null; + } + + using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + var peHeader = new byte[4]; fileStream.Position = 0x3C; - fileStream.Read(buffer, 0, 4); - fileStream.Position = BitConverter.ToUInt32(buffer, 0); // COFF header offset - fileStream.Read(buffer, 0, 4); // "PE\0\0" - fileStream.Read(buffer, 0, buffer.Length); - } - var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned); - try - { - var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER)); - return DateTimeOffset.FromUnixTimeSeconds(coffHeader.TimeDateStamp); - } - finally - { - pinnedBuffer.Free(); + fileStream.Read(peHeader, 0, 4); + var peHeaderOffset = BitConverter.ToUInt32(peHeader, 0); + + fileStream.Position = peHeaderOffset; + var signature = new byte[4]; + fileStream.Read(signature, 0, 4); + + if (signature[0] != 0x50 || signature[1] != 0x45 || signature[2] != 0x00 || signature[3] != 0x00) + { + return null; + } + + var fileHeader = new byte[Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER))]; + fileStream.Read(fileHeader, 0, fileHeader.Length); + + var pinnedBuffer = GCHandle.Alloc(fileHeader, GCHandleType.Pinned); + try + { + var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER)); + var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + var buildTime = epoch.AddSeconds(coffHeader.TimeDateStamp); + return new DateTimeOffset(buildTime.ToLocalTime()); + } + finally + { + pinnedBuffer.Free(); + } } } - else + catch { return null; } @@ -260,6 +358,55 @@ namespace Ink_Canvas.Windows.SettingsViews ((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138)); } + + private void LinkOfficialWebsite_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + Process.Start(new ProcessStartInfo + { + FileName = "https://inkcanvasforclass.github.io", + UseShellExecute = true + }); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"打开官方网站失败: {ex.Message}"); + } + } + + private void LinkGithubRepo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + Process.Start(new ProcessStartInfo + { + FileName = "https://github.com/InkCanvasForClass/community", + UseShellExecute = true + }); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"打开GitHub仓库失败: {ex.Message}"); + } + } + + private void LinkContributors_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + Process.Start(new ProcessStartInfo + { + FileName = "https://github.com/InkCanvasForClass/community#贡献者", + UseShellExecute = true + }); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"打开贡献者名单失败: {ex.Message}"); + } + } + /// /// 应用主题 ///