home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / about_cs_1________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-06-26  |  2.7 KB  |  108 lines

  1. /**
  2.  * The Help->About dialog box.
  3.  *
  4.  * @author  Jonathan Pryor
  5.  */
  6.  
  7. namespace ADepends
  8.   {
  9.   using System;
  10.   using System.Drawing;
  11.   using System.Windows.Forms;
  12.   using ADepends;
  13.  
  14.   /**
  15.    * Display an "About" dialog box.
  16.    */
  17.   internal class HelpAboutForm : Form
  18.     {
  19.     Button m_ok = new Button ();
  20.  
  21.     /**
  22.      * Layout the dialog box.
  23.      */
  24.     private HelpAboutForm ()
  25.       {
  26.       Text = Localization.ABOUT_BOX_TITLE;
  27.       FormBorderStyle = FormBorderStyle.FixedDialog;
  28.       MaximizeBox = false;
  29.       MinimizeBox = false;
  30.       ControlBox = false;
  31.       Size = new Size (350, 150);
  32.  
  33.       /*
  34.        * Label contains program information.
  35.        * It's offset from the right to make room for an image (if desired).
  36.        * It leaves enough room at the bottom to let the "OK" button exist,
  37.        * with 10 px of space between the button and the form edge.
  38.        */
  39.       Label l = new Label ();
  40.       l.Location = new Point (75, 10);
  41.       l.Height -= m_ok.Height + 10;
  42.       l.Text = Localization.ABOUT_BOX_TEXT;
  43.       l.Size = new Size (
  44.         ClientSize.Width - l.Location.X,
  45.         ClientSize.Height - l.Location.Y - m_ok.Height - 10);
  46.  
  47.       Controls.Add (l);
  48.  
  49.       /*
  50.        * The "OK" button is in the lower-right corner of the dialog,
  51.        * flush against the label.
  52.        */
  53.       m_ok.Text = "OK";
  54.       m_ok.Top = l.Bottom;
  55.       m_ok.Left = l.Right - m_ok.Width - 10;
  56.       m_ok.Click += new EventHandler (_on_ok_clicked);
  57.  
  58.       Controls.Add (m_ok);
  59.  
  60.       AcceptButton = m_ok;
  61.       CancelButton = m_ok;
  62.       StartPosition = FormStartPosition.CenterParent;
  63.       }
  64.  
  65.     /**
  66.      * Layout the dialog & set the application icon to ``icon''
  67.      */
  68.     public HelpAboutForm (Icon icon)
  69.       : this ()
  70.       {
  71.       _set_icon (icon);
  72.       }
  73.  
  74.     /** Position an application icon to the left of the "about" text. */
  75.     private void _set_icon (Icon icon)
  76.       {
  77.       // An image representing the Application.
  78.       PictureBox pb = new PictureBox ();
  79.       pb.Location = new Point (21, 15);
  80.       pb.Size = new Size (32, 32);
  81.       pb.Image = icon.ToBitmap ();
  82.       Controls.Add (pb);
  83.       }
  84.  
  85.     /** Closes the dialog box. */
  86.     private void _on_ok_clicked (Object sender, EventArgs e)
  87.       {
  88.       Close ();
  89.       }
  90.  
  91.     /** 
  92.      * For testing. 
  93.      *
  94.      * Compile with:
  95.      *
  96.      *  csc /r:System.Dll /r:System.Drawing.Dll /r:System.Windows.Forms.Dll  \
  97.      *    /r:Microsoft.Win32.Interop.Dll about.cs ..\localization.cs
  98.      */
  99.     public static void Main ()
  100.       {
  101.       HelpAboutForm haf = new HelpAboutForm ();
  102.       haf._set_icon (haf.Icon);
  103.       Application.Run (haf);
  104.       }
  105.     } /* class HelpAboutForm */
  106.   } /* namespace ADepends */
  107.  
  108.