using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D; // gradient
using System.Reflection; // to get attributes from AssemblyInfo
namespace Standard
{
public partial class AboutForm : System.Windows.Forms.Form
{
public AboutForm()
{
InitializeComponent();
}
private void AboutForm_Load(object sender, System.EventArgs e)
{
string stringMe = "AboutForm_Load: ";
try
{
this.Icon = new Icon(this.GetType(), "application.ico");
this.BackColor = Model.BackgroundColor;
if (Model.Background == Model.BgType.Image)
fixImage();
else
this.Invalidate();
this.CenterToParent();
this.Text = "About " + Application.ProductName +
" " + Model.VersionShort;
this.pictureBox1.Image = Owner.Icon.ToBitmap();
string tmpstr = Description() +
"\n\r\n\r" + "Version " + Application.ProductVersion +
"\n\r\n\r" + Company() +
"\n\r\n\r" + Copyright();
this.label1.Text = tmpstr;
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
} // end AboutForm_Load
private void fixImage()
{
this.BackgroundImage =
new Bitmap(this.GetType(), "background.jpg");
this.Invalidate();
}
///
/// uses reflection to obtain the Description attribute from AssemblyInfo
///
private string Description()
{
string stringMe = "AboutForm.Description: ";
try
{
AssemblyDescriptionAttribute myAttr =
(AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly(), typeof
(AssemblyDescriptionAttribute));
return myAttr.Description;
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
}
///
/// uses reflection to obtain the Company attribute from AssemblyInfo
///
private string Company()
{
string stringMe = "AboutForm.Company: ";
try
{
AssemblyCompanyAttribute myAttr =
(AssemblyCompanyAttribute) AssemblyCompanyAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly(), typeof
(AssemblyCompanyAttribute));
return myAttr.Company;
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
}
///
/// uses reflection to obtain the Copyright attribute from AssemblyInfo
///
private string Copyright()
{
string stringMe = "AboutForm.Copyright: ";
try
{
AssemblyCopyrightAttribute myAttr =
(AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute
(System.Reflection.Assembly.GetExecutingAssembly(), typeof
(AssemblyCopyrightAttribute));
return myAttr.Copyright;
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
}
private void buttonClose_Click(object sender, System.EventArgs e)
{
string stringMe = "AboutForm.buttonClose_Click: ";
try
{
this.Close();
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
string stringMe = "MainForm.OnPaintBackground: ";
try
{
if (Model.Background == Model.BgType.Gradient)
{
Graphics gc = pevent.Graphics;
// paint from upper-left corner (0,0) to lower-right
LinearGradientBrush linGrBrush = new LinearGradientBrush(new Point(0,0),
new Point(this.Width, this.Height),
Model.GradientColor1,Model.GradientColor2);
gc.FillRectangle(linGrBrush, pevent.ClipRectangle);
}
else
{
base.OnPaintBackground(pevent);
}
}
catch (Exception ex)
{ throw new Exception(stringMe + ex.Message); }
}
} // end class
} // end namespace