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

  1. /**
  2.  * Display a dialog box that allows the user to specify the paths
  3.  * that are used when loading up new Assemblies.
  4.  *
  5.  * @author  Jonathan Pryor
  6.  */
  7.  
  8. namespace ADepends
  9.   {
  10.   using System;
  11.   using System.Collections;
  12.   using System.Drawing;
  13.   using System.Diagnostics;
  14.   using System.Windows.Forms;
  15.  
  16.   /**
  17.    * Display a dialog box that allows the user to type in the
  18.    * name of a manifest to load.
  19.    */
  20.   internal class AssemblyPathsDialog : ResizeableForm
  21.     {
  22.     private Button m_ok = new Button ();
  23.     private Button m_cancel = new Button ();
  24.  
  25.     private TextBox m_app_base = new TextBox ();
  26.     private TextBox m_rel_search = new TextBox ();
  27.  
  28.     private const int div = 10;
  29.  
  30.     private void _add_control (
  31.       Control c, 
  32.       Control above, 
  33.       int dabove, 
  34.       int width)
  35.       {
  36.       c.Top = above.Bottom + dabove;
  37.       c.Left = div;
  38.       c.Width = width;
  39.       c.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
  40.  
  41.       Controls.Add (c);
  42.       }
  43.  
  44.     /**
  45.      * Layout the dialog box.
  46.      */
  47.     public AssemblyPathsDialog (string abp, string rsp)
  48.       : base (Localization.ASSEMBLY_PATHS_WINDOW_TITLE)
  49.       {
  50.       // default string values...
  51.       m_app_base.Text = abp;
  52.       m_rel_search.Text = rsp;
  53.  
  54.       int width = ClientSize.Width - 2*div;
  55.  
  56.       Label l = new Label ();
  57.       l.Text = Localization.APP_BASE_PATH_DESC;
  58.       l.Location = new Point (div, div);
  59.       l.Width = width;
  60.       l.AutoSize = true;
  61.       Controls.Add (l);
  62.       _add_control (m_app_base, l, div/2, width);
  63.  
  64.       l = new Label ();
  65.       l.Text = Localization.RELATIVE_SEARCH_PATH_DESC;
  66.       l.AutoSize = true;
  67.       _add_control (l, m_app_base, div, width);
  68.       _add_control (m_rel_search, l, div/2, width);
  69.  
  70.       m_cancel.Text = Localization.BUTTON_CANCEL;
  71.       m_cancel.Top = ClientSize.Height - m_cancel.Height - div;
  72.       m_cancel.Left = ClientSize.Width - m_cancel.Width - div;
  73.       m_cancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
  74.       m_cancel.Click += new EventHandler (_on_cancel_clicked);
  75.  
  76.       Controls.Add (m_cancel);
  77.  
  78.       m_ok.Text = Localization.BUTTON_OK;
  79.       m_ok.Top = m_cancel.Top;
  80.       m_ok.Left = m_cancel.Left - m_ok.Width - div;
  81.       m_ok.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
  82.       m_ok.Click += new EventHandler (_on_ok_clicked);
  83.  
  84.       Controls.Add (m_ok);
  85.  
  86.       MinimumSize = new Size (
  87.         ((m_cancel.Right + div) - (m_ok.Left - div)) + div,
  88.         ((m_cancel.Bottom + div) - (Controls[0].Top - div)) + 2*div);
  89.  
  90.       AcceptButton = m_ok;
  91.       CancelButton = m_cancel;
  92.       StartPosition = FormStartPosition.CenterParent;
  93.       }
  94.  
  95.     /** 
  96.      * Closes the dialog box, specifying that the dialog completed
  97.      * succesfully.
  98.      */
  99.     private void _on_ok_clicked (Object sender, EventArgs e)
  100.       {
  101.       Close ();
  102.       DialogResult = DialogResult.OK;
  103.       }
  104.  
  105.     /** 
  106.      * Closes the dialog box, specifying that the dialog was cancelled.
  107.      */
  108.     private void _on_cancel_clicked (Object sender, EventArgs e)
  109.       {
  110.       Close ();
  111.       DialogResult = DialogResult.Cancel;
  112.       }
  113.  
  114.     /**
  115.      * If "OK" was pressed, the AppBase Path to use when loading Assemblies.
  116.      */
  117.     public String AppBasePath
  118.       {
  119.       get 
  120.         {return m_app_base.Text;}
  121.       }
  122.  
  123.     /**
  124.      * If "OK" was pressed, the Relative Search Path to use when loading 
  125.      * Assemblies.
  126.      */
  127.     public String RelativeSearchPath
  128.       {
  129.       get 
  130.         {return m_rel_search.Text;}
  131.       }
  132.     } /* class AssemblyPathsDialog */
  133.   } /* namespace ADepends */
  134.  
  135.