2 // System.Windows.Forms Demo app
5 // Joel Basson (jstrike@mweb.co.za)
6 // Philip Van Hoof (me@freax.org)
12 using System
.Windows
.Forms
;
17 public class GtkForm
: System
.Windows
.Forms
.Form
19 private Button copybutton
= new Button();
20 private Button pastebutton
= new Button();
21 private Button cutbutton
= new Button();
22 private Button button1
= new Button();
23 private Button button2
= new Button();
24 private Label label1
= new Label();
25 private TextBox text1
= new TextBox();
26 private ProgressBar bar1
= new ProgressBar();
27 private CheckBox check1
= new CheckBox();
28 private RadioButton opt1
= new RadioButton();
29 private RadioButton opt2
= new RadioButton();
30 private RadioButton opt3
= new RadioButton();
31 private GroupBox frame1
= new GroupBox();
32 private PictureBox pbox
= new PictureBox();
33 private FileDialog fdialog
= new OpenFileDialog();
34 private VScrollBar vScrollBar1
= new VScrollBar();
35 private HScrollBar hScrollBar1
= new HScrollBar();
37 private void InitializeWidgets()
39 this.vScrollBar1
.Location
= new Point(10, 10);
40 this.vScrollBar1
.Maximum
= 200;
41 this.vScrollBar1
.Name
= "vScrollBar1";
42 this.vScrollBar1
.Size
= new Size(24, 200);
43 this.vScrollBar1
.TabIndex
= 0;
44 this.vScrollBar1
.ValueChanged
+= new EventHandler(this.vScrollBar1_ValueChanged
);
46 this.vScrollBar1
.BackColor
= Color
.Brown
;
47 // this.BackColor = Color.Yellow;
49 this.hScrollBar1
.Location
= new System
.Drawing
.Point(50, 60);
50 this.hScrollBar1
.Maximum
= 200;
51 this.hScrollBar1
.Minimum
= 10;
52 this.hScrollBar1
.Name
= "hScrollBar1";
53 this.hScrollBar1
.Size
= new System
.Drawing
.Size(360, 24);
54 this.hScrollBar1
.ValueChanged
+= new EventHandler(this.hScrollBar1_ValueChanged
);
56 this.button1
.Location
= new Point(150, 28);
57 this.button1
.Name
= "button1";
58 this.button1
.Size
= new Size(128, 44);
59 this.button1
.Text
= "Apply";
60 this.button1
.Click
+= new EventHandler(this.button1_Click
);
61 this.button1
.Enabled
= false;
64 this.button2
.Location
= new Point(150, 85);
65 this.button2
.Name
= "button2";
66 this.button2
.Size
= new Size(128, 44);
67 this.button2
.Text
= "File";
68 this.button2
.Click
+= new EventHandler(this.button2_Click
);
69 this.button2
.ForeColor
= Color
.Brown
;
71 this.copybutton
.Click
+= new EventHandler(this.copybutton_Click
);
72 this.pastebutton
.Click
+= new EventHandler(this.pastebutton_Click
);
73 this.cutbutton
.Click
+= new EventHandler(this.cutbutton_Click
);
75 this.copybutton
.Location
= new Point(320, 80);
76 this.pastebutton
.Location
= new Point(320, 100);
77 this.cutbutton
.Location
= new Point(320, 120);
79 this.copybutton
.Size
= new Size(150, 20);
80 this.pastebutton
.Size
= new Size(150, 20);
81 this.cutbutton
.Size
= new Size(150, 20);
83 this.copybutton
.Text
="Copy";
84 this.pastebutton
.Text
="Paste";
85 this.cutbutton
.Text
="Cut";
87 this.text1
.Location
= new Point(320,48);
88 this.text1
.Name
= "textBox1";
89 this.text1
.Size
= new Size(150, 22);
90 this.text1
.Text
= this.button1
.Name
;
92 this.bar1
.Location
= new Point(0, 230);
93 this.bar1
.Size
= new Size(512, 20);
94 this.bar1
.Text
= "This is a ProgressBar";
97 this.bar1
.ForeColor
= Color
.Blue
;
98 this.bar1
.BackColor
= Color
.Lime
;
100 this.label1
.Location
= new Point(330, 20);
101 this.label1
.Text
= "This is a Label";
103 this.check1
.Location
= new Point(150, 160);
104 this.check1
.Size
= new Size(180, 20);
105 this.check1
.Text
= "arbitrary CheckBox";
106 this.check1
.Checked
= false;
108 this.opt1
.Location
= new Point(20, 160);
109 this.opt1
.Size
= new Size(100, 20);
110 this.opt1
.Text
= "CenterImage";
112 this.opt2
.Location
= new Point(20,180);
113 this.opt2
.Size
= new Size(100, 20);
114 this.opt2
.Text
= "StretchImage";
116 this.opt3
.Location
= new Point(20,200);
117 this.opt3
.Size
= new Size(100, 20);
118 this.opt3
.Text
= "Normal";
120 this.frame1
.Location
= new Point(15, 140);
121 this.frame1
.Size
= new Size (110, 85);
122 this.frame1
.Text
= "Properties";
124 this.pbox
.Location
= new Point (25, 28);
125 this.pbox
.Size
= new Size(100, 100);
128 // Add you image name and path below
129 //pbox.File = "/home/alberto/img.png";
132 this.Controls
.AddRange(new System
.Windows
.Forms
.Control
[] {
151 this.Size
= new Size(512, 250);
159 private void set_Text1_to_scrollbarvalues() {
160 this.text1
.Text
= String
.Format ("{0}, {1}", this.vScrollBar1
.Value
, this.hScrollBar1
.Value
);
161 this.bar1
.Value
= this.hScrollBar1
.Value
;
164 private void vScrollBar1_ValueChanged (object sender
, EventArgs e
) {
165 this.set_Text1_to_scrollbarvalues ();
168 private void hScrollBar1_ValueChanged (object sender
, EventArgs e
) {
169 this.set_Text1_to_scrollbarvalues ();
173 private void copybutton_Click(object sender
, EventArgs e
){
174 //text1.Select (1, 4);
178 private void pastebutton_Click(object sender
, EventArgs e
){
183 private void cutbutton_Click(object sender
, EventArgs e
){
187 private void button1_Click(object sender
, EventArgs e
){
189 //pbox.File = fdialog.OpenFile;
190 pbox
.File
= fdialog
.FileName
;
191 if (this.opt2
.Checked
) {
192 this.pbox
.SizeMode
= PictureBoxSizeMode
.StretchImage
;
194 if (this.opt1
.Checked
){
195 this.pbox
.SizeMode
= PictureBoxSizeMode
.CenterImage
;
197 if (this.opt3
.Checked
){
198 this.pbox
.SizeMode
= PictureBoxSizeMode
.Normal
;
202 private void button2_Click(object sender
, EventArgs e
){
203 fdialog
.ShowDialog();
204 button1
.Enabled
= true;
212 public static void Main()
214 GtkForm form1
= new GtkForm ();
215 form1
.Text
= "System.Windows.Forms at work!";
216 Application
.Run(form1
);