Skip to content

Commit

Permalink
Merge pull request #25 from Mijo-Software/mjohne-patch-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
mjohne authored Oct 4, 2023
2 parents 92e8f59 + 6501065 commit 7c1f054
Show file tree
Hide file tree
Showing 24 changed files with 1,735 additions and 433 deletions.
318 changes: 318 additions & 0 deletions DisksizeWatcher/AboutBoxForm.Designer.cs

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions DisksizeWatcher/AboutBoxForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace DisksizeWatcher
{
partial class AboutBoxForm : Form
{
/// <summary>
/// Set a specific text to the status bar
/// </summary>
/// <param name="text">text with some information</param>
private void SetStatusbarText(string text)
{
labelInformation.Enabled = !string.IsNullOrEmpty(value: text);
labelInformation.Text = text;
}

public AboutBoxForm()
{
InitializeComponent();
Text = $"Info about {AssemblyTitle}";
labelProductName.Text = AssemblyProduct;
labelVersion.Text = $"Version {AssemblyVersion}";
labelCopyright.Text = AssemblyCopyright;
labelCompanyName.Text = AssemblyCompany;
textBoxDescription.Text = AssemblyDescription;
}

#region Assemblyattributaccessoren

public string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != string.Empty)
{
return titleAttribute.Title;
}
}
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}

public string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}

public string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}

public string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}

public string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}

public string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return string.Empty;
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
#endregion

/// <summary>
/// Load the form
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="e"/> and <paramref name="sender"/> are not needed, but must be indicated.</remarks>
private void AboutBoxForm_Load(object sender, System.EventArgs e) => SetStatusbarText(text: string.Empty);

/// <summary>
/// Detect the accessibility description to set as information text in the status bar
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameter <paramref name="e"/> is not needed, but must be indicated.</remarks>
private void SetStatusbar_Enter(object sender, EventArgs e)
{
string text = string.Empty;
switch (sender)
{
case Control control:
text = control.AccessibleDescription;
break;
case ToolStripSplitButton toolStripSplitButton:
text = toolStripSplitButton.AccessibleDescription;
break;
case ToolStripButton toolStripButton:
text = toolStripButton.AccessibleDescription;
break;
case ToolStripLabel toolStripLabel:
text = toolStripLabel.AccessibleDescription;
break;
case ToolStripMenuItem toolStripMenuItem:
text = toolStripMenuItem.AccessibleDescription;
break;
}
SetStatusbarText(text: text);
}

/// <summary>
/// Clear the information text of the status bar
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="e"/> and <paramref name="sender"/> are not needed, but must be indicated.</remarks>
private void ClearStatusbar_Leave(object sender, EventArgs e) => SetStatusbarText(text: string.Empty);
}
}
Loading

0 comments on commit 7c1f054

Please sign in to comment.