Download Cyotek.ArcadeExplosionMaker.zip version 1.0.0.1, last updated 05/06/2012 (123.69 KB)

Download
  • md5: bd412009442f7923a555ba5b0f508fe0
using System;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using TKageyu.Utils;

namespace Cyotek.ArcadeExplosionMaker.Client
{
  public partial class SimpleAboutDialog : Form
  {
    #region��Public�Constructors

    public SimpleAboutDialog()
    {
      Assembly assembly;
      string title;

      this.InitializeComponent();

      assembly = Assembly.GetEntryAssembly();
      title = Application.ProductName;

      this.UpdateUi(assembly.Location, title);
    }

    #endregion��Public�Constructors

    #region��Event�Handlers

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

    private void footerGroupBox_Paint(object sender, PaintEventArgs e)
    {
      e.Graphics.DrawLine(SystemPens.ControlDark, 0, 0, footerGroupBox.Width, 0);
      e.Graphics.DrawLine(SystemPens.ControlLightLight, 0, 1, footerGroupBox.Width, 1);
    }

    private void webLinkLabel_Click(object sender, EventArgs e)
    {
      try
      {
        Process.Start(((Control)sender).Text);
      }
      catch (Exception ex)
      {
        MessageBox.Show(string.Format("Unable to start the specified URI.\n\n{0}", ex.Message), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      }
    }

    #endregion��Event�Handlers

    #region��Private�Methods

    private int GetArea(Size size)
    {
      return size.Width * size.Height;
    }

    private Bitmap GetIcon(string fileName, Size size)
    {
      Icon match;

      using (IconExtractor iconExtractor = new IconExtractor(fileName))
      {
        Icon[] icons;

        icons = IconExtractor.SplitIcon(iconExtractor.GetIcon(0));
        match = icons.SingleOrDefault(i => i.Size == size);
        if (match == null)
          match = icons[0];
      }

      return new Bitmap(match.ToBitmap());
    }

    private Bitmap GetLargestIcon(string fileName)
    {
      Icon match;

      using (IconExtractor iconExtractor = new IconExtractor(fileName))
      {
        Icon[] icons;

        icons = IconExtractor.SplitIcon(iconExtractor.GetIcon(0));
        match = icons.Single(i => this.GetArea(i.Size) == icons.Max(m => this.GetArea(m.Size)));
      }

      return new Bitmap(match.ToBitmap());
    }

    private void UpdateUi(string fileName, string dialogTitle)
    {
      FileVersionInfo info;

      this.Text = string.Format("About {0}", dialogTitle);
      nameLabel.Text = dialogTitle;

      info = FileVersionInfo.GetVersionInfo(fileName);
      versionLabel.Text = string.Format("Version {0}", info.FileVersion);
      copyrightLabel.Text = info.LegalCopyright;

      iconPictureBox.Image = this.GetLargestIcon(fileName);
      nameLabel.Left = (iconPictureBox.Left * 2) + iconPictureBox.Width;
      versionLabel.Left = nameLabel.Left;
      webLinkLabel.Left = nameLabel.Left;
      copyrightLabel.Left = nameLabel.Left;
      copyrightLabel.Width = this.ClientSize.Width - (copyrightLabel.Left + iconPictureBox.Left);
    }

    #endregion��Private�Methods
  }
}

Donate

Donate