增加关于对话框

This commit is contained in:
ww-rm
2025-03-03 23:14:46 +08:00
parent 99b645cfcd
commit cb710f9b9c
3 changed files with 395 additions and 0 deletions

View File

@@ -0,0 +1,151 @@
namespace SpineViewer.Dialogs
{
partial class AboutDialog
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
tableLayoutPanel_About = new TableLayoutPanel();
label3 = new Label();
label1 = new Label();
label_Version = new Label();
linkLabel_RepoUrl = new LinkLabel();
panel1 = new Panel();
tableLayoutPanel_About.SuspendLayout();
panel1.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel_About
//
tableLayoutPanel_About.BackColor = Color.Transparent;
tableLayoutPanel_About.ColumnCount = 2;
tableLayoutPanel_About.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 28.5714283F));
tableLayoutPanel_About.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 71.42857F));
tableLayoutPanel_About.Controls.Add(label3, 0, 1);
tableLayoutPanel_About.Controls.Add(label1, 0, 0);
tableLayoutPanel_About.Controls.Add(label_Version, 1, 0);
tableLayoutPanel_About.Controls.Add(linkLabel_RepoUrl, 1, 1);
tableLayoutPanel_About.Dock = DockStyle.Fill;
tableLayoutPanel_About.Location = new Point(50, 15);
tableLayoutPanel_About.Margin = new Padding(0);
tableLayoutPanel_About.Name = "tableLayoutPanel_About";
tableLayoutPanel_About.RowCount = 3;
tableLayoutPanel_About.RowStyles.Add(new RowStyle());
tableLayoutPanel_About.RowStyles.Add(new RowStyle());
tableLayoutPanel_About.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel_About.Size = new Size(604, 254);
tableLayoutPanel_About.TabIndex = 1;
//
// label3
//
label3.AutoSize = true;
label3.Dock = DockStyle.Fill;
label3.Location = new Point(3, 54);
label3.Margin = new Padding(3, 10, 3, 10);
label3.Name = "label3";
label3.Size = new Size(166, 24);
label3.TabIndex = 2;
label3.Text = "项目地址:";
label3.TextAlign = ContentAlignment.MiddleRight;
//
// label1
//
label1.AutoSize = true;
label1.Dock = DockStyle.Fill;
label1.Location = new Point(3, 10);
label1.Margin = new Padding(3, 10, 3, 10);
label1.Name = "label1";
label1.Size = new Size(166, 24);
label1.TabIndex = 0;
label1.Text = "程序版本:";
label1.TextAlign = ContentAlignment.MiddleRight;
//
// label_Version
//
label_Version.Anchor = AnchorStyles.Left;
label_Version.AutoSize = true;
label_Version.Location = new Point(175, 10);
label_Version.Name = "label_Version";
label_Version.Size = new Size(61, 24);
label_Version.TabIndex = 1;
label_Version.Text = "vX.Y.Z";
label_Version.TextAlign = ContentAlignment.MiddleLeft;
//
// linkLabel_RepoUrl
//
linkLabel_RepoUrl.Anchor = AnchorStyles.Left;
linkLabel_RepoUrl.AutoSize = true;
linkLabel_RepoUrl.Location = new Point(175, 54);
linkLabel_RepoUrl.Name = "linkLabel_RepoUrl";
linkLabel_RepoUrl.Size = new Size(356, 24);
linkLabel_RepoUrl.TabIndex = 3;
linkLabel_RepoUrl.TabStop = true;
linkLabel_RepoUrl.Text = "https://github.com/ww-rm/SpineViewer";
linkLabel_RepoUrl.LinkClicked += linkLabel_RepoUrl_LinkClicked;
//
// panel1
//
panel1.BackgroundImageLayout = ImageLayout.Center;
panel1.Controls.Add(tableLayoutPanel_About);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(16, 17);
panel1.Name = "panel1";
panel1.Padding = new Padding(50, 15, 50, 10);
panel1.Size = new Size(704, 279);
panel1.TabIndex = 2;
//
// AboutDialog
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(736, 313);
Controls.Add(panel1);
FormBorderStyle = FormBorderStyle.FixedDialog;
Margin = new Padding(6);
MaximizeBox = false;
MinimizeBox = false;
Name = "AboutDialog";
Padding = new Padding(16, 17, 16, 17);
ShowIcon = false;
ShowInTaskbar = false;
StartPosition = FormStartPosition.CenterParent;
Text = "关于";
tableLayoutPanel_About.ResumeLayout(false);
tableLayoutPanel_About.PerformLayout();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayoutPanel_About;
private Label label3;
private Label label1;
private Label label_Version;
private LinkLabel linkLabel_RepoUrl;
private Panel panel1;
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SpineViewer.Dialogs
{
partial class AboutDialog : Form
{
public AboutDialog()
{
InitializeComponent();
this.Text = $"关于 {AssemblyTitle}";
this.label_Version.Text = $"v{InformationalVersion}";
}
#region 访
public string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if(attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if(titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
}
}
public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public string InformationalVersion
{
get
{
return Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
}
}
public string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}
public string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
private void linkLabel_RepoUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string url = linkLabel_RepoUrl.Text;
if (Control.ModifierKeys == Keys.Control)
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
}
else
{
Clipboard.SetText(url);
MessageBox.Show(this, "链接已复制到剪贴板,请前往浏览器进行访问", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>