Add About dialog

This commit is contained in:
MBucari 2023-04-02 11:29:28 -06:00
parent 4a65d6bbd3
commit 8d73f5cc7e
14 changed files with 466 additions and 16 deletions

View file

@ -0,0 +1,161 @@
namespace LibationWinForms.Dialogs
{
partial class AboutDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
pictureBox1 = new System.Windows.Forms.PictureBox();
versionLbl = new System.Windows.Forms.Label();
releaseNotesLbl = new System.Windows.Forms.LinkLabel();
checkForUpgradeBtn = new System.Windows.Forms.Button();
listView1 = new System.Windows.Forms.ListView();
columnHeader1 = new System.Windows.Forms.ColumnHeader();
columnHeader2 = new System.Windows.Forms.ColumnHeader();
copyBtn = new System.Windows.Forms.Button();
label2 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// pictureBox1
//
pictureBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
pictureBox1.Image = Properties.Resources.cheers;
pictureBox1.Location = new System.Drawing.Point(12, 105);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new System.Drawing.Size(410, 283);
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
// versionLbl
//
versionLbl.AutoSize = true;
versionLbl.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
versionLbl.Location = new System.Drawing.Point(12, 9);
versionLbl.Name = "versionLbl";
versionLbl.Size = new System.Drawing.Size(198, 21);
versionLbl.TabIndex = 1;
versionLbl.Text = "Libation Classic v11.0.0.0";
//
// releaseNotesLbl
//
releaseNotesLbl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
releaseNotesLbl.AutoSize = true;
releaseNotesLbl.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
releaseNotesLbl.Location = new System.Drawing.Point(319, 10);
releaseNotesLbl.Name = "releaseNotesLbl";
releaseNotesLbl.Size = new System.Drawing.Size(103, 20);
releaseNotesLbl.TabIndex = 2;
releaseNotesLbl.TabStop = true;
releaseNotesLbl.Text = "Release Notes";
releaseNotesLbl.LinkClicked += releaseNotesLbl_LinkClicked;
//
// checkForUpgradeBtn
//
checkForUpgradeBtn.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
checkForUpgradeBtn.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
checkForUpgradeBtn.Location = new System.Drawing.Point(12, 54);
checkForUpgradeBtn.Name = "checkForUpgradeBtn";
checkForUpgradeBtn.Size = new System.Drawing.Size(410, 31);
checkForUpgradeBtn.TabIndex = 3;
checkForUpgradeBtn.Text = "Check for Upgrade";
checkForUpgradeBtn.UseVisualStyleBackColor = true;
checkForUpgradeBtn.Click += checkForUpgradeBtn_Click;
//
// listView1
//
listView1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { columnHeader1, columnHeader2 });
listView1.Location = new System.Drawing.Point(12, 444);
listView1.Name = "listView1";
listView1.Size = new System.Drawing.Size(410, 105);
listView1.TabIndex = 4;
listView1.UseCompatibleStateImageBehavior = false;
listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
columnHeader1.Text = "Assembly";
//
// columnHeader2
//
columnHeader2.Text = "Version";
//
// copyBtn
//
copyBtn.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
copyBtn.Location = new System.Drawing.Point(304, 415);
copyBtn.Name = "copyBtn";
copyBtn.Size = new System.Drawing.Size(118, 23);
copyBtn.TabIndex = 5;
copyBtn.Text = "Copy to Clipboard";
copyBtn.UseVisualStyleBackColor = true;
copyBtn.Click += copyBtn_Click;
//
// label2
//
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(12, 419);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(108, 15);
label2.TabIndex = 6;
label2.Text = "Loaded Assemblies";
//
// AboutDialog
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(434, 561);
Controls.Add(label2);
Controls.Add(copyBtn);
Controls.Add(listView1);
Controls.Add(checkForUpgradeBtn);
Controls.Add(releaseNotesLbl);
Controls.Add(versionLbl);
Controls.Add(pictureBox1);
MinimumSize = new System.Drawing.Size(450, 600);
Name = "AboutDialog";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "About Libation";
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label versionLbl;
private System.Windows.Forms.LinkLabel releaseNotesLbl;
private System.Windows.Forms.Button checkForUpgradeBtn;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Button copyBtn;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
}
}

View file

@ -0,0 +1,66 @@
using LibationUiBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LibationWinForms.Dialogs
{
public partial class AboutDialog : Form
{
public AboutDialog()
{
InitializeComponent();
this.SetLibationIcon();
versionLbl.Text = $"Libation {AppScaffolding.LibationScaffolding.Variety} v{AppScaffolding.LibationScaffolding.BuildVersion}";
var asmNames = AppDomain.CurrentDomain.GetAssemblies().Select(a => new AssemblyName(a.FullName)).Where(a => a.Version.Major + a.Version.Minor + a.Version.Build + a.Version.Revision > 0).OrderBy(a => a.Name).ToList();
listView1.Items.AddRange(asmNames.Select(a => new ListViewItem(new string[] { a.Name, a.Version.ToString() })).ToArray());
listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
Resize += (_, _) => listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
}
private void releaseNotesLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToString(3)}");
private async void checkForUpgradeBtn_Click(object sender, EventArgs e)
{
var form1 = Owner as Form1;
var upgrader = new Upgrader();
upgrader.DownloadBegin += (_, _) => form1.Invoke(() => form1.upgradeLbl.Visible = form1.upgradePb.Visible = true);
upgrader.DownloadProgress += (_, e) => form1.Invoke(() => form1.upgradePb.Value = int.Max(0, int.Min(100, (int)(e.ProgressPercentage ?? 0))));
upgrader.DownloadCompleted += (_, _) => form1.Invoke(() => form1.upgradeLbl.Visible = form1.upgradePb.Visible = false);
checkForUpgradeBtn.Enabled = false;
Version latestVersion = null;
await upgrader.CheckForUpgradeAsync(OnUpgradeAvailable);
checkForUpgradeBtn.Enabled = latestVersion is null;
checkForUpgradeBtn.Text = latestVersion is null ? "Libation is up to date. Check Again." : $"Version {latestVersion:3} is available";
Task OnUpgradeAvailable(UpgradeEventArgs e)
{
var notificationResult = new UpgradeNotificationDialog(e.UpgradeProperties).ShowDialog(this);
e.Ignore = notificationResult == DialogResult.Ignore;
e.InstallUpgrade = notificationResult == DialogResult.Yes;
latestVersion = e.UpgradeProperties.LatestRelease;
return Task.CompletedTask;
}
}
private void copyBtn_Click(object sender, EventArgs e)
{
var text = string.Join(Environment.NewLine, listView1.Items.OfType<ListViewItem>().Select(i => $"{i.SubItems[0].Text}\t{i.SubItems[1].Text}"));
Clipboard.SetDataObject(text, false, 5, 150);
}
}
}

View file

@ -0,0 +1,60 @@
<root>
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -697,7 +697,7 @@
private System.Windows.Forms.Button removeBooksBtn;
private System.Windows.Forms.Button doneRemovingBtn;
private System.Windows.Forms.ToolStripMenuItem setPdfDownloadedManualToolStripMenuItem;
private System.Windows.Forms.ToolStripProgressBar upgradePb;
private System.Windows.Forms.ToolStripStatusLabel upgradeLbl;
public System.Windows.Forms.ToolStripProgressBar upgradePb;
public System.Windows.Forms.ToolStripStatusLabel upgradeLbl;
}
}

View file

@ -12,9 +12,7 @@ namespace LibationWinForms
private void basicSettingsToolStripMenuItem_Click(object sender, EventArgs e) => new SettingsDialog().ShowDialog();
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
=> MessageBox.Show($"Libation {AppScaffolding.LibationScaffolding.Variety}{Environment.NewLine}Version {AppScaffolding.LibationScaffolding.BuildVersion}", $"Libation v{AppScaffolding.LibationScaffolding.BuildVersion}");
private void aboutToolStripMenuItem_Click(object sender, EventArgs e) => new AboutDialog().ShowDialog(this);
private async void tourToolStripMenuItem_Click(object sender, EventArgs e)
=> await new Walkthrough(this).RunAsync();

View file

@ -60,6 +60,16 @@ namespace LibationWinForms.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap cheers {
get {
object obj = ResourceManager.GetObject("cheers", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cheers" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cheers.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="default_cover_300x300" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\img-coverart-prod-unavailable_300x300.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB