-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FrmAboutBox.cs
192 lines (170 loc) · 7.09 KB
/
FrmAboutBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using GeoTagNinja.Helpers;
namespace GeoTagNinja;
internal partial class FrmAboutBox : Form
{
/// <summary>
/// Initializes a new instance of the <see cref="FrmAboutBox" /> class.
/// This constructor sets up the initial state of the AboutBox form.
/// It initializes the components, sets up the theme color based on the user's settings,
/// and populates the form with assembly information and relevant links.
/// </summary>
public FrmAboutBox()
{
InitializeComponent();
rtb_AboutBox.Text = string.Empty;
rtb_AboutBox.LinkClicked += rtb_AboutBox_LinkClicked;
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.UserSettingUseDarkMode
? ThemeColour.Dark
: ThemeColour.Light, parentControl: this);
HelperNonStatic helperNonstatic = new();
HelperControlAndMessageBoxHandling.ReturnControlText(cItem: this, senderForm: this);
// via https://stackoverflow.com/a/1601079/3968494
Version version = Assembly.GetEntryAssembly()
.GetName()
.Version;
DateTime buildDateTime = new DateTime(year: 2000, month: 1, day: 1).Add(value: new TimeSpan(
ticks: TimeSpan.TicksPerDay * version.Build + // days since 1 January 2000
TimeSpan.TicksPerSecond * 2 *
version.Revision)); // seconds since midnight, (multiply by 2 to get original)
Text = AssemblyTitle;
tbx_Description.Text = AssemblyDescription;
List<(string text, string link)> aboutBoxEntries =
[
(text: AssemblyTitle, link: null),
(text: $"Version/Build: {Assembly.GetExecutingAssembly()
.GetName()
.Version.Build.ToString(provider: CultureInfo.InvariantCulture)} [{buildDateTime:yyyyMMdd:HHmm}]",
link: null),
(text: $"Rights: {AssemblyCopyright}", link: null),
(text: $"Written by: {AssemblyCompany}", link: null),
(text: "Paypal: ", link: "https://paypal.me/NemethV"),
(text: "GitHub: ", link: "https://github.com/nemethviktor/GeoTagNinja"),
(text: $"ExifTool Ver: {HelperVariables.CurrentExifToolVersionLocal}", link: null)
];
foreach ((string text, string link) in aboutBoxEntries)
{
AppendText(box: rtb_AboutBox, text: text, link: link);
}
}
public sealed override string Text
{
get => base.Text;
set => base.Text = value;
}
private static void AppendText(RichTextBox box,
string text,
string link = null)
{
box.AppendText(text: $"{text} {link}{Environment.NewLine}");
}
private void btn_Generic_OK_Click(object sender,
EventArgs e)
{
Hide();
}
private void rtb_AboutBox_LinkClicked(object sender,
LinkClickedEventArgs e)
{
Process.Start(fileName: e.LinkText);
}
#region Assembly Attribute Accessors
/// <summary>
/// Gets the title of the assembly currently executing.
/// The title is retrieved from the AssemblyTitleAttribute of the assembly.
/// If the AssemblyTitleAttribute is not found or the title is empty,
/// it returns the file name of the assembly without the extension.
/// </summary>
private static string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly()
.GetCustomAttributes(attributeType: typeof(AssemblyTitleAttribute),
inherit: false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return Path.GetFileNameWithoutExtension(path: Assembly.GetExecutingAssembly()
.CodeBase);
}
}
/// <summary>
/// Gets the assembly description of the executing assembly.
/// </summary>
/// <remarks>
/// The assembly description is retrieved from the AssemblyDescriptionAttribute of the executing assembly.
/// If the AssemblyDescriptionAttribute is not found, an empty string is returned.
/// </remarks>
private static string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly()
.GetCustomAttributes(attributeType: typeof(AssemblyDescriptionAttribute),
inherit: false);
return attributes.Length == 0 ? "" : ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
/// <summary>
/// Gets the product name of the assembly.
/// </summary>
/// <returns>
/// The product name of the assembly if the AssemblyProductAttribute is found; otherwise, an empty string.
/// </returns>
private string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly()
.GetCustomAttributes(attributeType: typeof(AssemblyProductAttribute),
inherit: false);
return attributes.Length == 0 ? "" : ((AssemblyProductAttribute)attributes[0]).Product;
}
}
/// <summary>
/// Gets the copyright information from the assembly.
/// </summary>
/// <returns>
/// The copyright information if it exists; otherwise, an empty string.
/// </returns>
private static string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly()
.GetCustomAttributes(attributeType: typeof(AssemblyCopyrightAttribute),
inherit: false);
return attributes.Length == 0 ? "" : ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
/// <summary>
/// Gets the company information from the assembly.
/// </summary>
/// <returns>
/// The company information as a string. If no company information is found in the assembly, an empty string is
/// returned.
/// </returns>
private static string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly()
.GetCustomAttributes(attributeType: typeof(AssemblyCompanyAttribute),
inherit: false);
return attributes.Length == 0 ? "" : ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion
}