From d0ded5cd9bf5070a120bad58b5be21fe2ac6a4ff Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期六, 20 十二月 2025 16:41:09 +0800
Subject: [PATCH] test
---
IDViewer_2D/VersionHelper.cs | 95 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/IDViewer_2D/VersionHelper.cs b/IDViewer_2D/VersionHelper.cs
new file mode 100644
index 0000000..0fc27d0
--- /dev/null
+++ b/IDViewer_2D/VersionHelper.cs
@@ -0,0 +1,95 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Windows;
+
+namespace IDViewer_2D
+{
+ public static class VersionHelper
+ {
+ public static void ShowVersionInfo()
+ {
+ try
+ {
+ string versionFile = "鐗堟湰璇存槑.txt";
+ if (!File.Exists(versionFile))
+ {
+ MessageBox.Show("鐗堟湰璇存槑鏂囦欢涓嶅瓨鍦�", "閿欒", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ string[] lines = File.ReadAllLines(versionFile, Encoding.UTF8);
+ string latestVersion = "";
+ string latestDate = "";
+ StringBuilder changes = new StringBuilder();
+
+ // 浠庡悗鍚戝墠鏌ユ壘鏈�鏂扮増鏈�
+ for (int i = lines.Length - 1; i >= 0; i--)
+ {
+ string line = lines[i].Trim();
+
+ // 鏌ユ壘鐗堟湰琛� (鍖呭惈鏃ユ湡鍜寁鐗堟湰鍙�)
+ if (IsVersionLine(line))
+ {
+ ParseVersionLine(line, ref latestVersion, ref latestDate);
+
+ // 鏀堕泦鏇存柊鍐呭
+ for (int j = i + 1; j < lines.Length; j++)
+ {
+ string contentLine = lines[j].Trim();
+ if (string.IsNullOrEmpty(contentLine) || IsVersionLine(contentLine))
+ break;
+
+ changes.AppendLine(contentLine);
+ if (j - i > 8) break; // 鏈�澶�8琛�
+ }
+ break;
+ }
+ }
+
+ if (string.IsNullOrEmpty(latestVersion))
+ {
+ MessageBox.Show("鏈壘鍒扮増鏈俊鎭�", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ string message = $"褰撳墠杞欢鐗堟湰: {latestVersion}\n" +
+ $"鍙戝竷鏃ユ湡: {latestDate}\n\n" +
+ $"鏈�鏂版洿鏂板唴瀹�:\n{changes}\n" +
+ $"瀹屾暣鐗堟湰鍘嗗彶璁板綍璇锋煡鐪嬬増鏈鏄�.txt鏂囦欢";
+
+ MessageBox.Show(message, "杞欢鐗堟湰璇存槑", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"璇诲彇鐗堟湰淇℃伅鍑洪敊: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private static bool IsVersionLine(string line)
+ {
+ return !string.IsNullOrEmpty(line) &&
+ line.Contains("v") &&
+ line.Contains(".") &&
+ line.Length > 8 &&
+ char.IsDigit(line[0]);
+ }
+
+ private static void ParseVersionLine(string line, ref string version, ref string date)
+ {
+ string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string part in parts)
+ {
+ if (part.Contains("v") && part.Contains("."))
+ {
+ version = part;
+ }
+ else if (part.Contains(".") && part.Length >= 8 && char.IsDigit(part[0]))
+ {
+ date = part;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3