Fixed Issue 215.
authormoel.mich
Mon, 16 May 2011 22:04:04 +0000
changeset 289d4798e7f4388
parent 288 a35a89a35532
child 290 22214a7e85a9
Fixed Issue 215.
GUI/Gadget.cs
GUI/SensorGadget.cs
     1.1 --- a/GUI/Gadget.cs	Sun May 15 21:43:40 2011 +0000
     1.2 +++ b/GUI/Gadget.cs	Mon May 16 22:04:04 2011 +0000
     1.3 @@ -176,12 +176,16 @@
     1.4        set {
     1.5          if (value != window.Visible) {
     1.6            window.Visible = value;
     1.7 +          if (VisibleChanged != null)
     1.8 +            VisibleChanged(this, EventArgs.Empty);
     1.9            if (value)
    1.10              Redraw();          
    1.11          }
    1.12        }
    1.13      }
    1.14  
    1.15 +    public event EventHandler VisibleChanged;
    1.16 +
    1.17      public void Redraw() {
    1.18        if (!window.Visible)
    1.19          return;
     2.1 --- a/GUI/SensorGadget.cs	Sun May 15 21:43:40 2011 +0000
     2.2 +++ b/GUI/SensorGadget.cs	Mon May 16 22:04:04 2011 +0000
     2.3 @@ -201,6 +201,20 @@
     2.4          Redraw();
     2.5        };
     2.6  
     2.7 +      VisibleChanged += delegate(object sender, EventArgs e) {
     2.8 +        Rectangle bounds = new Rectangle(Location, Size);
     2.9 +        Screen screen = Screen.FromRectangle(bounds);
    2.10 +        Rectangle intersection = 
    2.11 +          Rectangle.Intersect(screen.WorkingArea, bounds);
    2.12 +        if (intersection.Width < Math.Min(16, bounds.Width) || 
    2.13 +            intersection.Height < Math.Min(16, bounds.Height)) 
    2.14 +        {
    2.15 +          Location = new Point(
    2.16 +            screen.WorkingArea.Width / 2 - bounds.Width / 2, 
    2.17 +            screen.WorkingArea.Height / 2 - bounds.Height / 2);
    2.18 +        }
    2.19 +      };
    2.20 +
    2.21        MouseDoubleClick += delegate(object obj, MouseEventArgs args) {
    2.22          SendHideShowCommand();
    2.23        };