dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/samples FormsHello.cs,1.2,1.3


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/samples FormsHello.cs,1.2,1.3
Date: Wed, 11 Jun 2003 22:55:51 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/samples
In directory subversions:/tmp/cvs-serv19710/samples

Modified Files:
        FormsHello.cs 
Log Message:


Implement the "ButtonBase" and "Button" classes, to provide simple
control functionality.


Index: FormsHello.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/samples/FormsHello.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** FormsHello.cs       11 Jun 2003 10:37:28 -0000      1.2
--- FormsHello.cs       12 Jun 2003 02:55:49 -0000      1.3
***************
*** 26,36 ****
  public class FormsHello : Form
  {
        
        private FormsHello()
        {
                SetStyle(ControlStyles.ResizeRedraw, true);
        }
  
!       private static void HandlePaint(Object sender, PaintEventArgs e)
        {
                Graphics graphics = e.Graphics;
--- 26,50 ----
  public class FormsHello : Form
  {
+       private Button button;
+       private int msgNum;
        
        private FormsHello()
        {
+               // Force the entire form to repaint when it is resized.
                SetStyle(ControlStyles.ResizeRedraw, true);
+ 
+               // Create a button control on the form.
+               button = new Button();
+               button.Text = "Click Me!";
+               button.Location = new Point(30, 130);
+               Controls.Add(button);
+               button.Show();
+ 
+               // Hook up interesting events.
+               Paint += new PaintEventHandler(HandlePaint);
+               button.Click += new EventHandler(HandleClick);
        }
  
!       private void HandlePaint(Object sender, PaintEventArgs e)
        {
                Graphics graphics = e.Graphics;
***************
*** 61,71 ****
        }
  
        public static void Main(String[] args)
        {
!               Form form = new FormsHello();
                form.Width = 400;
                form.Height = 250;
                form.Text = "Forms Hello";
-               form.Paint += new PaintEventHandler(HandlePaint);
                Application.Run(form);
        }
--- 75,97 ----
        }
  
+       private static readonly String[] Messages = {
+               "I've been clicked!",
+               "Oww! That hurts!",
+               "Stop it!",
+               "Thank you sir! May I have another?"
+       };
+ 
+       private void HandleClick(Object sender, EventArgs e)
+       {
+               Console.WriteLine(Messages[msgNum]);
+               msgNum = (msgNum + 1) % Messages.Length;
+       }
+ 
        public static void Main(String[] args)
        {
!               FormsHello form = new FormsHello();
                form.Width = 400;
                form.Height = 250;
                form.Text = "Forms Hello";
                Application.Run(form);
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]