(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Windows.Forms / Gtk / Samples / Demo2.cs
blob6bf76a2c3bdefbfadc1b73b558d125f6f0b331ba
1 //
2 // System.Windows.Forms Demo2 app
3 //
4 //Authors:
5 // Joel Basson (jstrike@mweb.co.za)
6 // Philip Van Hoof (me@freax.org)
7 //
9 using System;
10 using System.Drawing;
11 using System.Windows.Forms;
13 namespace demo2
16 public class GtkForm : System.Windows.Forms.Form
18 private Button button1 = new Button();
19 private Button button2 = new Button();
20 private ColorDialog color1 = new ColorDialog();
21 private ComboBox combo1 = new ComboBox();
22 private MainMenu mainMenu1 = new MainMenu();
23 private MenuItem menuItem1 = new MenuItem();
24 private MenuItem menuItem2 = new MenuItem();
25 private MenuItem menuItem3 = new MenuItem();
26 private MenuItem menuItem4 = new MenuItem();
27 private MenuItem menuItem5 = new MenuItem();
29 private ListBox lb = new ListBox();
31 private StatusBar statusBar1 = new StatusBar();
32 private StatusBar statusBar2 = new StatusBar();
33 private StatusBar statusBar3 = new StatusBar();
35 private void InitializeWidgets()
37 button1.Location = new Point(100, 28);
38 button1.Name = "button1";
39 button1.Size = new Size(128, 44);
40 button1.Text = "Color";
41 button1.Click += new EventHandler(this.button1_Click);
43 this.statusBar1.Location = new System.Drawing.Point(0, 251);
44 this.statusBar1.Name = "statusBar1";
45 this.statusBar1.Size = new System.Drawing.Size(292, 22);
46 this.statusBar1.TabIndex = 0;
47 this.statusBar1.Text = "statusBar1";
49 this.statusBar2.Location = new System.Drawing.Point(0, 240);
50 this.statusBar2.Name = "statusBar2";
51 this.statusBar2.Size = new System.Drawing.Size(292, 22);
52 this.statusBar2.TabIndex = 0;
53 this.statusBar2.Text = "statusBar2";
55 this.statusBar3.Location = new System.Drawing.Point(0, 251);
56 this.statusBar3.Name = "statusBar3";
57 this.statusBar3.Size = new System.Drawing.Size(292, 22);
58 this.statusBar3.TabIndex = 0;
59 this.statusBar3.Text = "statusBar3";
61 button1.Location = new Point(100, 28);
62 button1.Name = "button1";
63 button1.Size = new Size(128, 44);
64 button1.Text = "Color";
65 button1.Click += new EventHandler(this.button1_Click);
67 button1.Enabled = true;
69 button2.Location = new Point(100, 80);
70 button2.Name = "button2";
71 button2.Size = new Size(128, 44);
72 button2.Text = "Add to ComboBox";
73 button2.Click += new EventHandler(this.button2_Click);
75 button2.Enabled = true;
77 this.lb.Location = new System.Drawing.Point(280, 28);
78 this.lb.Size = new System.Drawing.Size(200, 200);
80 menuItem1.Text = "File";
81 menuItem2.Text = "Exit";
82 menuItem2.Click += new EventHandler(this.menuItem2_Click);
83 menuItem3.Text = "Edit";
84 menuItem4.Text = "&Stop";
85 menuItem4.Click += new EventHandler(this.menuItem4_Click);
86 menuItem4.Shortcut = Shortcut.CtrlS;
87 menuItem5.Text = "S&tart";
88 menuItem5.Checked = true;
89 menuItem1.MenuItems.Add(menuItem2);
90 menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {menuItem4,
91 menuItem5});
92 mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {menuItem1,
93 menuItem3});
95 combo1.Location = new Point(100, 150);
96 this.combo1.Items.AddRange(new object[] {"Item 1",
97 "Item 2",
98 "Item 3",
99 "Item 4",
100 "Item 5"});
102 this.Controls.AddRange(new System.Windows.Forms.Control[] {
103 this.button1,
104 this.button2,
105 //this.color1,
106 this.lb,
107 this.combo1,
108 this.statusBar1,
109 this.statusBar2});
112 this.Size = new Size(512, 250);
113 this.Menu = mainMenu1;
114 // Freaky stuff
115 //this.button1.Controls.Add (this.statusBar3);
118 public GtkForm()
120 InitializeWidgets();
123 private void button1_Click(object sender, EventArgs e){
124 color1.ShowDialog();
127 private void button2_Click(object sender, EventArgs e){
128 combo1.BeginUpdate();
130 for (int i = 1; i < 5; i++) {
131 combo1.Items.Add("Joel");
132 lb.Items.Add("MyItems");
134 combo1.EndUpdate();
137 private void menuItem2_Click (object sender, EventArgs e){
138 MessageBox.Show("You clicked Exit");
141 private void menuItem4_Click(object sender, EventArgs e){
142 MessageBox.Show("You clicked Stop");
147 public class GtkMain
149 [STAThread]
150 public static void Main()
152 GtkForm form1 = new GtkForm ();
153 form1.Text = "System.Windows.Forms at work!";
154 Application.Run(form1);