File: ui.cs

package info (click to toggle)
hugs98 98.200311-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,964 kB
  • ctags: 8,084
  • sloc: ansic: 67,521; haskell: 61,497; xml: 4,566; sh: 3,264; cpp: 1,936; yacc: 1,094; makefile: 915; cs: 883; sed: 10
file content (75 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// The prototypical functional GUI application, the counter.
//
// To compile: csc /t:library ui.cs
//
using System;
using System.Windows.Forms;

public class UITest : Form {
 private Button upButton;
 private Button downButton;
 private Label  countLabel;
 private int count;
 
 public UITest() {
   upButton = new Button();
   upButton.Text = "Up";
   Controls.Add(upButton);

   downButton = new Button();
   downButton.Text = "Down";
   downButton.Location = new System.Drawing.Point (0,50);
   Controls.Add(downButton);
   
   countLabel = new Label();
   countLabel.Text = count.ToString();
   countLabel.Location = new System.Drawing.Point (0,30);
   countLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
   Controls.Add(countLabel);

   Text = "WinForms example";
   Height = 100;
   Width = 100;
 }
 
 public void IncCount() {
   count++;
   countLabel.Text = count.ToString();
 }
 
 public void DecCount() {
   count--;
   countLabel.Text = count.ToString();
 }
 
 public void AddHandlerUp(System.EventHandler h) {
   upButton.Click += h;
 }
 
 public void AddHandlerDown(System.EventHandler h) {
   downButton.Click += h;
 }
 
 public void RunIt() {
   Application.Run(this);
 }
 /*
 public void KickOff(System.EventHandler h) {
   button1.Click += h;
   Application.Run(this);
 }

 private void button1_click(object sender, EventArgs e) {
   MessageBox.Show("button1 clicked");
 }
 */

}
/*
public class TestApp {
 public static void Main(string[] args) {
   Application.Run(new SampleApp());
 }
}
*/