Esempio n. 1
0
 /// <summary>
 /// Called when a parent controls is resized.
 /// </summary>
 /// <param name="sender">Resized control.</param>
 protected virtual void OnParentResized(UIComponent sender)
 {
 }
Esempio n. 2
0
        /// <summary>
        /// Asks children for their mouse status, and invokes MouseOut event
        /// for this control if necessary.
        /// </summary>
        /// <param name="args">Mouse event arguments.</param>
        /// <returns>Control asking for MouseOver event, otherwise null.</returns>
        internal UIComponent CheckMouseStatus(MouseEventArgs args)
        {
            UIComponent result = null;

            // Check if control can receive MouseOver and MouseOut events
            if (!this.isAnimating)
            {
                // Check if MouseOut event should be invoked
                bool mouseOver = CheckCoordinates(args.Position.X, args.Position.Y);
                if (this.isMouseOver)
                {
                    if (!mouseOver)
                    {
                        this.isMouseOver = false;
                        MouseOut.Invoke(args);
                    }
                }

                if (mouseOver)
                {
                    float zTemp = 0.0f;

                    // Ask each child to check it's mouse status
                    foreach (UIComponent control in this.controls)
                    {
                        // Keep track of highest z-order
                        if (control.ZOrder >= zTemp)
                        {
                            UIComponent child = control.CheckMouseStatus(args);

                            if (child != null)
                            {
                                // MouseOut last result
                                if (result != null && result.IsMouseOver)
                                {
                                    result.InvokeMouseOut(args);
                                }

                                // Set result and update highest z-order
                                result = child;
                                zTemp  = control.ZOrder;
                            }
                        }
                    }

                    // If no child requires the event, see if this control can
                    // take it.
                    if (result == null && this.canHaveFocus)
                    {
                        result = this;
                    }
                }
                else
                {
                    // Ensure each control can receive MouseOut event
                    foreach (UIComponent control in this.controls)
                    {
                        control.CheckMouseStatus(args);
                    }
                }
            }

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Called when a parent control is moved. Invokes Move event.
 /// </summary>
 /// <param name="sender">Moved control.</param>
 protected virtual void OnParentMoved(UIComponent sender)
 {
     Move.Invoke(this);
 }
Esempio n. 4
0
 /// <summary>
 /// Simply refreshes, override to handle event.
 /// </summary>
 /// <param name="args">Resized control.</param>
 protected virtual void OnResize(UIComponent sender)
 {
     Refresh();
 }
Esempio n. 5
0
 /// <summary>
 /// Overridden to prevent any control except RadioButton from being
 /// added.
 /// </summary>
 /// <param name="control">Control to add.</param>
 public override void Add(UIComponent control)
 {
     Debug.Assert(false);
 }
Esempio n. 6
0
 /// <summary>
 /// When the parent control is resized, fill the entire width.
 /// </summary>
 /// <param name="sender">Resized control.</param>
 protected override void OnParentResized(UIComponent sender)
 {
     base.OnParentResized(sender);
     Width = sender.Width;
 }
Esempio n. 7
0
 /// <summary>
 /// Refresh menu items positions when any of them change size.
 /// </summary>
 /// <param name="sender">Resized control.</param>
 protected void OnMenuItemResize(UIComponent sender)
 {
     RefreshMenuItems();
 }