forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutDialog.cs
More file actions
176 lines (162 loc) · 5.98 KB
/
Copy pathAboutDialog.cs
File metadata and controls
176 lines (162 loc) · 5.98 KB
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
using System;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using PluginCore.Localization;
using FlashDevelop.Helpers;
using PluginCore;
namespace FlashDevelop.Dialogs
{
public class AboutDialog : Form
{
Label copyLabel;
LinkLabel versionLabel;
PictureBox imageBox;
public AboutDialog()
{
Owner = Globals.MainForm;
Font = PluginBase.Settings.DefaultFont;
InitializeComponent();
ApplyLocalizedTexts();
InitializeGraphics();
}
#region Windows Forms Designer Generated Code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
public void InitializeComponent()
{
imageBox = new PictureBox();
copyLabel = new Label();
versionLabel = new LinkLabel();
versionLabel.LinkColor = Color.DarkGray;
((System.ComponentModel.ISupportInitialize)(imageBox)).BeginInit();
SuspendLayout();
//
// imageBox
//
imageBox.BorderStyle = BorderStyle.None;
imageBox.SizeMode = PictureBoxSizeMode.StretchImage;
imageBox.Location = new Point(0, 0);
imageBox.Name = "imageBox";
imageBox.Size = new Size(450, 244);
imageBox.TabIndex = 0;
imageBox.TabStop = false;
imageBox.Click += DialogCloseClick;
//
// copyLabel
//
copyLabel.AutoSize = true;
copyLabel.ForeColor = Color.DarkGray;
copyLabel.BackColor = Color.FromArgb(37, 37, 37);
copyLabel.FlatStyle = FlatStyle.System;
copyLabel.Location = new Point(25, 192);
copyLabel.Name = "copyLabel";
copyLabel.Size = new Size(383, 30);
copyLabel.TabIndex = 0;
copyLabel.Text = DistroConfig.DISTRIBUTION_ABOUT;
copyLabel.Click += DialogCloseClick;
//
// versionLabel
//
versionLabel.AutoSize = true;
versionLabel.ForeColor = Color.DarkGray;
versionLabel.BackColor = Color.FromArgb(37, 37, 37);
versionLabel.FlatStyle = FlatStyle.System;
versionLabel.Location = new Point(23, 172);
versionLabel.Name = "versionLabel";
versionLabel.Size = new Size(289, 15);
versionLabel.TabIndex = 0;
versionLabel.Text = "FlashDevelop 5.0.0.99 for .NET 3.5 (master#1234567890)";
versionLabel.Click += DialogCloseClick;
versionLabel.LinkClicked += VersionLabelLinkClicked;
//
// AboutDialog
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(450, 244);
Controls.Add(copyLabel);
Controls.Add(versionLabel);
Controls.Add(imageBox);
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
Name = "AboutDialog";
ShowInTaskbar = false;
KeyDown += DialogKeyDown;
StartPosition = FormStartPosition.CenterParent;
Text = " About FlashDevelop";
((System.ComponentModel.ISupportInitialize)(imageBox)).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
#region Methods And Event Handlers
/// <summary>
/// Attaches the image to the imagebox
/// </summary>
void InitializeGraphics()
{
var stream = ResourceHelper.GetStream("AboutDialog.jpg");
imageBox.Image = Image.FromStream(stream);
}
/// <summary>
/// Applies the localized texts to the form
/// </summary>
void ApplyLocalizedTexts()
{
var name = Application.ProductName;
var bit = IntPtr.Size == 4 ? "[x86]" : "[x64]";
Text = $" {TextHelper.GetString("Title.AboutDialog")} {bit}";
versionLabel.Font = new Font(Font, FontStyle.Bold);
versionLabel.Text = name;
string sha;
var match = Regex.Match(name, "#([a-f0-9]*)");
if (match.Success && match.Captures.Count > 0) sha = match.Captures[0].ToString().Remove(0, 1);
else
{
// TODO slavara: https://github.com/fdorg/flashdevelop/issues/3215
sha = $"ProductName#{name}";
}
var link = $"www.github.com/fdorg/flashdevelop/commit/{sha}";
var lastChar = versionLabel.Text.Length;
var firstChar = versionLabel.Text.IndexOf('(');
versionLabel.Links.Add(new LinkLabel.Link(firstChar, lastChar, link));
var tooltip = new ToolTip();
tooltip.SetToolTip(versionLabel, link);
}
/// <summary>
/// When user clicks the link, open the Github commit in the browser.
/// </summary>
static void VersionLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (e.Link.LinkData is string target) Process.Start(target);
}
/// <summary>
/// Closes the about dialog
/// </summary>
void DialogKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter || e.KeyData == Keys.Escape)
{
Close();
}
}
/// <summary>
/// Closes the about dialog
/// </summary>
void DialogCloseClick(object sender, EventArgs e) => Close();
/// <summary>
/// Shows the about dialog
/// </summary>
public new static void Show()
{
using var dialog = new AboutDialog();
dialog.ShowDialog();
}
#endregion
}
}