示例#1
0
 /// <summary>
 /// Processes a MouseClick event.
 /// </summary>
 /// <param name="loc">The location of the mouse.</param>
 /// <param name="button">The buttons that are pressed.</param>
 internal void DoClick(Vec2 loc, MouseButtons button)
 {
     if (IsActiveWindow)
     {
         if (ContentBounds.IsInBounds(loc))
         {
             Vec2 RelativeLoc;
             foreach (Control c in Controls)
             {
                 RelativeLoc = new Vec2(loc.X - Location.X - WindowBorderSize, loc.Y - Location.Y - HeaderHeight);
                 if (c.Bounds.IsInBounds(RelativeLoc))
                 {
                     c.DoClick(RelativeLoc, button);
                 }
             }
         }
         else
         {
             if (HeaderBounds.IsInBounds(loc))
             {
                 if (CloseButtonBounds.IsInBounds(loc))
                 {
                     this.Close();
                 }
                 else if (MaxButtonBounds.IsInBounds(loc))
                 {
                     if (CurrentState == WindowState.Maximized)
                     {
                         Parent.RestoreWindow(this);
                     }
                     else
                     {
                         Parent.MaximizeWindow(this);
                     }
                 }
                 else if (MinButtonBounds.IsInBounds(loc))
                 {
                     Parent.MinimizeWindow(this);
                 }
             }
             else // Window border was clicked, and we don't care about it.
             {
                 //throw new Exception("Unknown part of the window clicked!");
             }
         }
     }
     else
     {
         Parent.BringWindowToFront(this);
     }
 }
示例#2
0
 /// <summary>
 /// Processes a click event.
 /// </summary>
 /// <param name="loc">The location of the mouse.</param>
 /// <param name="buttons">The buttons that are pressed.</param>
 internal void DoClick(Vec2 loc, MouseButtons buttons)
 {
     if (!Drawn)
     {
         RedrawBuffer();
     }
     if (WasOverButton)
     {
         if (WindowButtonBounds[overButtonIndx].IsInBounds(loc))
         {
             if (Windows[overButtonIndx].IsActiveWindow)
             {
                 Manager.MinimizeWindow(Windows[overButtonIndx]);
             }
             else if (Windows[overButtonIndx].CurrentState == WindowState.Minimized)
             {
                 Manager.RestoreWindow(Windows[overButtonIndx]);
             }
             else
             {
                 Manager.BringWindowToFront(Windows[overButtonIndx]);
             }
             DrawnOverButton = false;
             DoMouseMove(loc);
         }
         else
         {
             for (int i = 0; i < Windows.Length; i++)
             {
                 if (WindowButtonBounds[i].IsInBounds(loc))
                 {
                     DrawOverButton(WindowButtonBounds[i], Windows[i]);
                     overButtonIndx  = i;
                     DrawnOverButton = false;
                     if (Windows[i].IsActiveWindow)
                     {
                         Manager.MinimizeWindow(Windows[i]);
                     }
                     else if (Windows[i].CurrentState == WindowState.Minimized)
                     {
                         Manager.RestoreWindow(Windows[i]);
                     }
                     else
                     {
                         Manager.BringWindowToFront(Windows[i]);
                     }
                     DoMouseMove(loc);
                     return;
                 }
             }
         }
     }
     else
     {
         for (int i = 0; i < Windows.Length; i++)
         {
             if (WindowButtonBounds[i].IsInBounds(loc))
             {
                 DrawOverButton(WindowButtonBounds[i], Windows[i]);
                 overButtonIndx  = i;
                 DrawnOverButton = false;
                 if (Windows[i].IsActiveWindow)
                 {
                     Manager.MinimizeWindow(Windows[i]);
                 }
                 else if (Windows[i].CurrentState == WindowState.Minimized)
                 {
                     Manager.RestoreWindow(Windows[i]);
                 }
                 else
                 {
                     Manager.BringWindowToFront(Windows[i]);
                 }
                 DoMouseMove(loc);
                 return;
             }
         }
     }
 }