Back to index

lightning-sunbird  0.9+nobinonly
MSDotNETCSEmbedForm.cs
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: Mozilla-sample-code 1.0
00004  *
00005  * Copyright (c) 2002 Netscape Communications Corporation and
00006  * other contributors
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a
00009  * copy of this Mozilla sample software and associated documentation files
00010  * (the "Software"), to deal in the Software without restriction, including
00011  * without limitation the rights to use, copy, modify, merge, publish,
00012  * distribute, sublicense, and/or sell copies of the Software, and to permit
00013  * persons to whom the Software is furnished to do so, subject to the
00014  * following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included
00017  * in all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  *
00027  * Contributor(s):
00028  *   Roy Yokoyama <yokoyama@netscape.com> (original author)
00029  *
00030  * ***** END LICENSE BLOCK ***** */
00031 
00032 using System;
00033 using System.Drawing;
00034 using System.Collections;
00035 using System.ComponentModel;
00036 using System.Windows.Forms;
00037 using System.Data;
00038 
00039 // Gecko namespace
00040 using Mozilla.Embedding;
00041 
00042 namespace MSDotNETCSEmbed
00043 {
00047        public class MSDotNETCSEmbedForm : System.Windows.Forms.Form
00048        {
00052               private System.ComponentModel.Container components = null;
00053               private Mozilla.Embedding.Gecko gecko1;
00054               private System.Windows.Forms.Button goButton;
00055               private System.Windows.Forms.TextBox urlBar;
00056 
00057               public MSDotNETCSEmbedForm()
00058               {
00059                      //
00060                      // Required for Windows Form Designer support
00061                      //
00062                      InitializeComponent();
00063 
00064                      //
00065                      // TODO: Add any constructor code after InitializeComponent call
00066                      //
00067               }
00068 
00072               protected override void Dispose( bool disposing )
00073               {
00074                      if( disposing )
00075                      {
00076                             if (components != null) 
00077                             {
00078                                    components.Dispose();
00079                             }
00080                      }
00081                      base.Dispose( disposing );
00082               }
00083 
00084               #region Windows Form Designer generated code
00085 
00086 
00087 
00088 
00089               private void InitializeComponent()
00090               {
00091                      this.gecko1 = new Mozilla.Embedding.Gecko();
00092                      this.goButton = new System.Windows.Forms.Button();
00093                      this.urlBar = new System.Windows.Forms.TextBox();
00094                      this.SuspendLayout();
00095                      // 
00096                      // gecko1
00097                      // 
00098                      this.gecko1.Location = new System.Drawing.Point(0, 40);
00099                      this.gecko1.Name = "gecko1";
00100                      this.gecko1.Size = new System.Drawing.Size(664, 392);
00101                      this.gecko1.TabIndex = 0;
00102                      // 
00103                      // goButton
00104                      // 
00105                      this.goButton.Location = new System.Drawing.Point(600, 8);
00106                      this.goButton.Name = "goButton";
00107                      this.goButton.Size = new System.Drawing.Size(56, 24);
00108                      this.goButton.TabIndex = 1;
00109                      this.goButton.Text = "Go";
00110                      this.goButton.Click += new System.EventHandler(this.goButton_Click);
00111                      // 
00112                      // urlBar
00113                      // 
00114                      this.urlBar.Location = new System.Drawing.Point(8, 10);
00115                      this.urlBar.Name = "urlBar";
00116                      this.urlBar.Size = new System.Drawing.Size(576, 20);
00117                      this.urlBar.TabIndex = 2;
00118                      this.urlBar.Text = "";
00119                      this.urlBar.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.urlBar_KeyPress);
00120                      // 
00121                      // MSDotNETCSEmbedForm
00122                      // 
00123                      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00124                      this.ClientSize = new System.Drawing.Size(664, 429);
00125                      this.Controls.AddRange(new System.Windows.Forms.Control[] {
00126                                                                                                                                 this.urlBar,
00127                                                                                                                                 this.goButton,
00128                                                                                                                                 this.gecko1});
00129                      this.Name = "MSDotNETCSEmbedForm";
00130                      this.Text = "MSDotNETCSEmbed [UNSUPPORTED]";
00131                      this.Resize += new System.EventHandler(this.MSDotNETCSEmbedForm_Resize);
00132                      this.Load += new System.EventHandler(this.MSDotNETCSEmbedForm_Load);
00133                      this.ResumeLayout(false);
00134 
00135               }
00136               #endregion
00137 
00141               [STAThread]
00142               static void Main() 
00143               {
00144                      Application.Run(new MSDotNETCSEmbedForm());
00145 
00146                      // terminate gecko
00147                      Gecko.TermEmbedding();
00148               }
00149 
00150               private void MSDotNETCSEmbedForm_Load(object sender, System.EventArgs e)
00151               {
00152                      urlBar.Text = "http://www.mozilla.org";
00153                      gecko1.OpenURL(urlBar.Text);
00154                      this.Text = "MSDotNETCSEmbed [UNSUPPORTED] - " + urlBar.Text;
00155               }
00156 
00157               private void MSDotNETCSEmbedForm_Resize(object sender, System.EventArgs e)
00158               {
00159                      gecko1.Size =
00160                             new Size(ClientSize.Width,
00161                                            ClientSize.Height - gecko1.Location.Y);
00162               }
00163 
00164               private void urlBar_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
00165               {
00166                      switch (e.KeyChar)
00167                      {
00168                             case '\r':
00169                                    gecko1.OpenURL(urlBar.Text);
00170                                    e.Handled = true;
00171                                    break;
00172                      }
00173               }
00174 
00175               private void goButton_Click(object sender, System.EventArgs e)
00176               {
00177                      gecko1.OpenURL(urlBar.Text);
00178               }
00179        }
00180 }