Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions GkmStatus/AboutForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 11 additions & 112 deletions GkmStatus/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,121 +22,17 @@ public AboutForm(Color backColor, Color foreColor, Font mainFont, float scale)
_scale = scale;
_titleFont = new Font(mainFont.FontFamily, 14f, FontStyle.Bold, GraphicsUnit.Point);

InitializeComponent();
}

private void InitializeComponent()
{
this.Text = I18n.T("About_Title");
this.AutoScaleMode = AutoScaleMode.None;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
this.StartPosition = FormStartPosition.CenterParent;
this.BackColor = _backColor;
this.ForeColor = _foreColor;
this.ClientSize = new Size(S(320), S(280));

// Icon
var iconBox = new PictureBox
{
Size = new Size(S(64), S(64)),
Location = new Point((this.ClientSize.Width - S(64)) / 2, S(25)),
SizeMode = PictureBoxSizeMode.Zoom
};
try
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
using Stream? stream = assembly.GetManifestResourceStream("GkmStatus.Resources.app_icon_2048px.png");
if (stream != null)
{
iconBox.Image = Image.FromStream(stream);
}
using Stream? icoStream = assembly.GetManifestResourceStream("GkmStatus.Resources.app.ico");
if (icoStream != null) this.Icon = new Icon(icoStream);
}
catch { }
this.Controls.Add(iconBox);

// App Name
var lblName = new Label
{
Text = I18n.T("App_Name"),
Font = _titleFont,
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, S(95)),
Size = new Size(this.ClientSize.Width, S(30))
};
this.Controls.Add(lblName);

// Version
var lblVersion = new Label
{
Text = "v" + Application.ProductVersion,
Font = _mainFont,
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, S(125)),
Size = new Size(this.ClientSize.Width, S(20)),
ForeColor = _foreColor.GetBrightness() > 0.5f ? Color.FromArgb(100, 100, 100) : Color.FromArgb(180, 180, 180)
};
this.Controls.Add(lblVersion);

// Author
var lblAuthor = new Label
{
Text = I18n.T("About_Author"),
Font = _mainFont,
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, S(150)),
Size = new Size(this.ClientSize.Width, S(20))
};
this.Controls.Add(lblAuthor);

// Font Attribution
var lblFont = new Label
{
Text = I18n.T("About_FontAttribution"),
Font = new Font(_mainFont.FontFamily, 8f, GraphicsUnit.Point),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, S(172)),
Size = new Size(this.ClientSize.Width, S(15)),
ForeColor = _foreColor.GetBrightness() > 0.5f ? Color.FromArgb(120, 120, 120) : Color.FromArgb(150, 150, 150)
};
this.Controls.Add(lblFont);
//SetupInitializeComponent();

var lnkLicense = new LinkLabel
{
Text = I18n.T("About_FontLicense"),
Font = new Font(_mainFont.FontFamily, 8f, GraphicsUnit.Point),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, S(187)),
Size = new Size(this.ClientSize.Width, S(15)),
LinkColor = COLOR_PRIMARY_DEFAULT,
ActiveLinkColor = Color.White,
VisitedLinkColor = COLOR_PRIMARY_DEFAULT
};
lnkLicense.LinkClicked += (s, e) => ShowLicense();
this.Controls.Add(lnkLicense);

// OK Button
var btnOk = new Button
{
Text = "OK",
Size = new Size(S(90), S(35)),
Location = new Point((this.ClientSize.Width - S(90)) / 2, S(225)),
FlatStyle = FlatStyle.Flat,
Font = _mainFont,
Cursor = Cursors.Hand
};
btnOk.FlatAppearance.BorderColor = _foreColor.GetBrightness() > 0.5f ? Color.Gray : Color.FromArgb(100, 100, 100);
btnOk.Click += (s, e) => this.Close();
this.Controls.Add(btnOk);
SuspendLayout();
InitializeComponent();
ApplyComponent();
ResumeLayout();
}

private static readonly Color COLOR_PRIMARY_DEFAULT = ColorTranslator.FromHtml("#7e87f4");

private void ShowLicense()
private void ShowLicense(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
Expand Down Expand Up @@ -186,8 +82,6 @@ protected override void OnLoad(EventArgs e)
SetTitleBarDarkMode(_backColor.GetBrightness() < 0.5f);
}

private int S(int val) => (int)Math.Round(val * _scale);

[System.Runtime.InteropServices.LibraryImport("dwmapi.dll")]
private static partial int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);

Expand All @@ -201,5 +95,10 @@ private void SetTitleBarDarkMode(bool dark)
}
catch { }
}

private void Close(object sender, EventArgs e)
{
this.Close();
}
}
}
Loading
Loading