GUI/SensorGadget.cs
changeset 289 d4798e7f4388
parent 263 575f8d4c378d
child 300 ee03b05bce9f
     1.1 --- a/GUI/SensorGadget.cs	Sun May 15 21:43:40 2011 +0000
     1.2 +++ b/GUI/SensorGadget.cs	Mon May 16 22:04:04 2011 +0000
     1.3 @@ -201,6 +201,20 @@
     1.4          Redraw();
     1.5        };
     1.6  
     1.7 +      VisibleChanged += delegate(object sender, EventArgs e) {
     1.8 +        Rectangle bounds = new Rectangle(Location, Size);
     1.9 +        Screen screen = Screen.FromRectangle(bounds);
    1.10 +        Rectangle intersection = 
    1.11 +          Rectangle.Intersect(screen.WorkingArea, bounds);
    1.12 +        if (intersection.Width < Math.Min(16, bounds.Width) || 
    1.13 +            intersection.Height < Math.Min(16, bounds.Height)) 
    1.14 +        {
    1.15 +          Location = new Point(
    1.16 +            screen.WorkingArea.Width / 2 - bounds.Width / 2, 
    1.17 +            screen.WorkingArea.Height / 2 - bounds.Height / 2);
    1.18 +        }
    1.19 +      };
    1.20 +
    1.21        MouseDoubleClick += delegate(object obj, MouseEventArgs args) {
    1.22          SendHideShowCommand();
    1.23        };