GUI/Gadget.cs
changeset 183 3096735e99b2
parent 181 9901dbb25f18
child 202 551243a66b32
     1.1 --- a/GUI/Gadget.cs	Wed Sep 08 19:29:58 2010 +0000
     1.2 +++ b/GUI/Gadget.cs	Mon Sep 13 22:34:08 2010 +0000
     1.3 @@ -76,16 +76,21 @@
     1.4        }
     1.5      }
     1.6  
     1.7 -    protected virtual Size Size {
     1.8 +    public virtual Size Size {
     1.9        get {
    1.10          return window.Size; 
    1.11        }
    1.12 -      set {
    1.13 -        if (window.Size != value) {
    1.14 -          DisposeBuffer();
    1.15 -          this.window.Size = value;          
    1.16 -          CreateBuffer();
    1.17 -        }
    1.18 +      set {        
    1.19 +        this.window.Size = value;
    1.20 +      }
    1.21 +    }
    1.22 +
    1.23 +    public event EventHandler SizeChanged {
    1.24 +      add {
    1.25 +        window.SizeChanged += value;
    1.26 +      }
    1.27 +      remove {
    1.28 +        window.SizeChanged -= value;
    1.29        }
    1.30      }
    1.31  
    1.32 @@ -98,12 +103,12 @@
    1.33        }
    1.34      }
    1.35  
    1.36 -    public bool LockPosition {
    1.37 +    public bool LockPositionAndSize {
    1.38        get {
    1.39 -        return window.LockPosition;
    1.40 +        return window.LockPositionAndSize;
    1.41        }
    1.42        set {
    1.43 -        window.LockPosition = value;
    1.44 +        window.LockPositionAndSize = value;
    1.45        }
    1.46      }
    1.47  
    1.48 @@ -125,6 +130,15 @@
    1.49        }
    1.50      }
    1.51  
    1.52 +    public event HitTestEventHandler HitTest {
    1.53 +      add {
    1.54 +        window.HitTest += value;
    1.55 +      }
    1.56 +      remove {
    1.57 +        window.HitTest -= value;
    1.58 +      }
    1.59 +    } 
    1.60 +
    1.61      private void CreateBuffer() {
    1.62        this.buffer = new Bitmap(window.Size.Width, window.Size.Height, 
    1.63          PixelFormat.Format32bppArgb);
    1.64 @@ -160,6 +174,11 @@
    1.65      }
    1.66  
    1.67      public void Redraw() {
    1.68 +      if (window.Size != buffer.Size) {
    1.69 +        DisposeBuffer();
    1.70 +        CreateBuffer();
    1.71 +      }
    1.72 +
    1.73        OnPaint(new PaintEventArgs(graphics, 
    1.74          new Rectangle(Point.Empty, window.Size)));
    1.75        window.Update(buffer);