Ejemplo n.º 1
0
 /// <summary>
 /// Clears user controls handled by this manager
 /// </summary>
 public void Clear()
 {
   if (mouseover != null)
   {
     mouseover.OnMouseLeave();
     mouseover = null;
   }
   if (Focus != null)
   {
     Focus.OnFocusLost();
     Focus = null;
   }
   controls.Clear();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a user control to this manager
 /// </summary>
 /// <param id="control">New user control</param>
 public void AddControl(UserControl control)
 {
   controls.Add(control);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Handles the mouse operations
 /// </summary>
 private void HandleMouseOperations()
 {
   if (UI.Instance.LMBHold() && mouseover.Enabled)
   {
     mouseover.OnLHold();
   }
   if (UI.Instance.LMBClick())
   {
     if (Focus != mouseover)
     {
       if (Focus != null)
       {
         Focus.OnFocusLost();
       }
       mouseover.OnFocus();
       Focus = mouseover;
     }
     if (mouseover.Enabled)
     {
       mouseover.OnLClick();
     }
   }
   if (UI.Instance.RMBHold() && mouseover.Enabled)
   {
     mouseover.OnRHold();
   }
   if (UI.Instance.RMBClick())
   {
     if (mouseover.Enabled)
     {
       mouseover.OnRClick();
     }
     if (Focus != null)
     {
       Focus.OnFocusLost();
       Focus = null;
     }
   }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Handles the user control focus operations
    /// </summary>
    private void HandleFocus()
    {
      if (UI.Instance.KeysPressed && Focus.Enabled)
      {
        Focus.OnKeyPress();
      }

      if (!Focus.Focus)
      {
        Focus.OnFocusLost();
        Focus = null;
      }
      else if (mouseover == null)
      {
        if (UI.Instance.LMBClick() || UI.Instance.RMBClick())
        {
          Focus.OnFocusLost();
          Focus = null;
        }
      }

      if (Focus == null)
      {
        HandleMouseover();
      }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Handles the mouseover events
    /// </summary>
    private void HandleMouseover()
    {
      UserControl newMouseover = null;

      // Prefer focused control
      if (Focus != null)
      {
        if (UI.Instance.MouseInArea(Focus.Position, Focus.Size))
        {
          newMouseover = Focus;
        }
      }

      // Prefer already mouseovered control
      if (newMouseover == null && mouseover != null)
      {
        if (UI.Instance.MouseInArea(mouseover.Position, mouseover.Size))
        {
          newMouseover = mouseover;
        }
      }

      // If neither focused nor mouseovered controls are under mouse, check the rest
      if (newMouseover == null)
      {
        foreach (var control in controls)
        {
          if (UI.Instance.MouseInArea(control.Position, control.Size))
          {
            newMouseover = control;
            break;
          }
        }
      }

      // Handle new mouseovered control
      if (newMouseover == mouseover)
      {
        if (mouseover != null)
        {
          mouseover.OnMouseMove();
        }
      }
      else if (newMouseover == null)
      {
        // Left control
        mouseover.OnMouseLeave();
      }
      else if (mouseover == null)
      {
        // Entered control
        newMouseover.OnMouseEnter();
      }
      else
      {
        // Switched control
        mouseover.OnMouseLeave();
        newMouseover.OnMouseEnter();
      }
      mouseover = newMouseover;
    }