2003-03-17 Joel Basson <jstrike@mweb.co.za>
[mono.git] / mcs / class / System.Windows.Forms / Gtk / demo.cs
1 //              
2 //                      System.Windows.Forms Demo app
3 //
4 //                      Author: 
5 //                                              Joel Basson             (jstrike@mweb.co.za)
6 //
7 //
8
9 using System;
10 using System.Drawing;\r
11 using System.Windows.Forms;\r
12 \r
13 namespace demo\r
14 {\r
15         \r
16         public class GtkForm : System.Windows.Forms.Form\r
17         {\r
18                 private Button button1 = new Button(); 
19                         private Button button2 = new Button(); 
20                         private Label label1 = new Label();\r
21                 private TextBox text1 = new TextBox(); \r
22                 private ProgressBar bar1 = new ProgressBar();
23                         private CheckBox check1 = new CheckBox();\r
24                 private RadioButton opt1 = new RadioButton();
25                         private RadioButton opt2 = new RadioButton();
26                         private GroupBox frame1 = new GroupBox();
27                         private PictureBox pbox = new PictureBox();
28                         private FileDialog fdialog = new FileDialog();
29                 
30                 private void InitializeWidgets()\r
31                 {\r
32                         button1.Location = new Point(150, 28);\r
33                 button1.Name = "button1";\r
34                         button1.Size = new Size(128, 44);\r
35                 button1.Text = "Apply";\r
36                         button1.Click += new EventHandler(this.button1_Click);    \r
37                 button1.Enabled = false;
38   
39                                 button2.Location = new Point(150, 85);\r
40                 button2.Name = "button2";\r
41                         button2.Size = new Size(128, 44);\r
42                 button2.Text = "File";\r
43                         button2.Click += new EventHandler(this.button2_Click); 
44  \r
45                 text1.Location = new Point(320,48);\r
46                 text1.Name = "textBox1";\r
47                 text1.Size = new Size(150, 22);
48                                 text1.Text = this.button1.Name;
49
50                         bar1.Location = new Point(0, 230);
51                         bar1.Size = new Size(512, 20);
52                         bar1.Text = "This is a ProgressBar";
53                                 bar1.Value = 25;
54
55                         label1.Location = new Point(330, 20);
56                         label1.Text = "This is a Label";        
57                         
58                                 check1.Location = new Point(28, 140);
59                                 check1.Size = new Size(180, 20);
60                                 check1.Text = "Stretch Image";
61                                 check1.Checked = false;
62                 
63                                 opt1.Location = new Point(280, 155);
64                                 opt1.Size = new Size(180, 20);
65                                 opt1.Text = "Option";
66
67                                 opt2.Location = new Point(280,180);
68                                 opt2.Size = new Size(180, 20);
69                                 opt2.Text = "Option2";
70
71                                 frame1.Location = new Point(260, 130);
72                                 frame1.Size = new Size (110, 85);
73                                 frame1.Text = "Frame1";
74                                 
75                                 pbox.Location = new Point (25, 28);
76                                 pbox.Size = new Size(100, 100);
77                                 //
78                                 //Add you image name and path below
79                                 pbox.File = "/home/jstrike/Shared/7804.jpg";
80 \r
81           this.Controls.AddRange(new System.Windows.Forms.Control[] { 
82                                                                         this.button1,
83                                                                         this.button2,\r
84                         this.text1, 
85                                                                         this.bar1, 
86                                                                         this.check1,
87                                                                         this.opt1,
88                                                                         this.opt2,
89                                                                         this.frame1,
90                                                                         this.pbox,
91                                                                         fdialog,
92                                                                         this.label1 });\r
93           this.Size = new Size(512, 250);\r
94                 }\r
95         \r
96         public GtkForm()\r
97         {\r
98                 InitializeWidgets();
99 \r
100         }\r
101 \r
102                 private void button1_Click(object sender, EventArgs e){ 
103                         pbox.File = fdialog.OpenFile;
104                                 if (this.check1.Checked) { 
105                                         this.pbox.Stretch = true;
106                                 }
107                                 if (!this.check1.Checked){
108                                         this.pbox.Stretch = false;
109                                 }                       \r
110                 }
111
112                 private void button2_Click(object sender, EventArgs e){                                                         \r
113                         fdialog.ShowDialog();
114                         button1.Enabled = true;
115                 }
116
117                 }
118         \r
119         public class GtkMain\r
120         {\r
121                 public static void Main()\r
122                 {\r
123                         GtkForm form1 = new GtkForm ();\r
124                         form1.Text = "System.Windows.Forms at work!";                   \r
125                         Application.Run(form1);\r
126                 }\r
127         }\r
128 }\r