// 许可证文本查看窗:显示 licenses\ 目录下某协议的标准全文(缺失时给出官方地址提示) using System; using System.IO; using System.Windows.Forms; namespace 成套报价软件 { public partial class 许可证文本 : Form { /// 窗口标题用,如 "MIT License"。 /// licenses 目录下的文件名,如 "MIT.txt"。 public 许可证文本(string 协议名, string 文件名) { InitializeComponent(); this.BackColor = System.Drawing.Color.White; Text = "许可证全文 - " + 协议名; try { string p = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "licenses", 文件名); if (File.Exists(p)) { txt正文.Text = File.ReadAllText(p, System.Text.Encoding.UTF8); } else { txt正文.Text = "许可证文本文件缺失: licenses\\" + 文件名 + "\r\n\r\n请访问官方发布页查看完整文本:" + 官方地址(文件名); } } catch (Exception ex) { txt正文.Text = "读取许可证文本失败: " + ex.Message; } txt正文.SelectionStart = 0; txt正文.SelectionLength = 0; } private static string 官方地址(string 文件名) { switch (文件名) { case "MIT.txt": return "https://opensource.org/license/MIT"; case "Apache-2.0.txt": return "https://www.apache.org/licenses/LICENSE-2.0"; case "Apache-2.0-ZCode.txt": return "https://github.com/zai-org/ZCode/blob/main/LICENSE"; case "BSD-3-Clause.txt": return "https://opensource.org/license/BSD-3-Clause"; case "ISC.txt": return "https://opensource.org/license/ISC"; case "MS-PL.txt": return "https://opensource.org/license/MS-PL"; case "PublicDomain.txt": return "https://sqlite.org/copyright.html"; case "WebView2-terms.txt": return "https://learn.microsoft.com/microsoft-edge/webview2/"; default: return "https://opensource.org/licenses"; } } private void btn确定_Click(object sender, EventArgs e) { Close(); } } }