Пример #1
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        public new void Update()
        {
            if (!DesignMode)
            {
                ProcessDragDrop();

                if (Gui.GetButton(0) == ButtonState.Up)
                {
                    EndDragDrop();
                }
            }

            int pressed = -1;
            int down    = -1;

            for (int i = 0; i < Gui.Buttons.Length; i++)
            {
                if (Gui.GetButton(i) == ButtonState.Press)
                {
                    pressed = i;
                }

                if (Gui.GetButton(i) == ButtonState.Down)
                {
                    down = i;
                }
            }

            if (pressed == -1)
            {
                if (TooltipControl != null)
                {
                    TooltipControl.Visible = false;
                }
                hot = GetControlAt(Gui.MousePosition.x, Gui.MousePosition.y);
                if (TooltipControl != null)
                {
                    TooltipControl.Visible = true;
                }

                if (!DesignMode && hot != null && ModalQueue.Count > 0)
                {
                    Control check = ModalQueue[ModalQueue.Count - 1];
                    bool    found = check == hot || hot.IsChildOf(check);

                    if (!found && Dropdowns.Count > 0)
                    {
                        for (int i = Dropdowns.Count - 1; i >= 0; i--)
                        {
                            if (Dropdowns[i].Contains(hot))
                            {
                                found = true;
                                break;
                            }
                        }
                    }

                    if (!found && hot.Owner != null)
                    {
                        found = hot.Owner.IsChildOf(check);
                    }

                    if (!found)
                    {
                        hot = this;
                    }
                }

                if (hot != HotControl)
                {
                    if (HotControl != null)
                    {
                        HotControl.OnMouseLeave();
                    }

                    if (hot != null)
                    {
                        CurrentCursor = hot.Cursor;
                        hot.OnMouseEnter();
                    }

                    HotControl = hot;
                }
            }
            else if (pressed > 1)
            {
                hot = null;
            }

            for (int i = 0; i < Gui.Buttons.Length; i++)
            {
                if (Gui.GetButton(i) == ButtonState.Up)
                {
                    if (MouseDownControl != null)
                    {
                        MouseDownControl.OnMouseUp(i);
                        break;
                    }
                }
            }

            if (!DesignMode && down > -1)
            {
                if (ModalQueue.Count == 0)
                {
                    Window w = GetWindowAt(Gui.MousePosition.x, Gui.MousePosition.y);
                    if (w != null && w != window && w.Dock == DockStyle.None)
                    {
                        w.BringToFront();
                        w.Focus();
                        window = w;
                    }
                }

                if (hot != null)
                {
                    if (hot.AllowFocus)
                    {
                        FocusedControl = hot;
                    }
                    else if (!hot.PreventFocusChange)
                    {
                        FocusedControl = null;
                    }
                }
                else
                {
                    FocusedControl = null;
                }

                //if(OnClick != null)
                //    OnClick(hot);

                if (Dropdowns.Count > 0)
                {
                    if (hot == null)
                    {
                        CloseDropdowns();
                    }
                    else
                    {
                        for (int i = Dropdowns.Count - 1; i >= 0; i--)
                        {
                            if (hot != Dropdowns[i])
                            {
                                if (!Dropdowns[i].Contains(hot))
                                {
                                    Dropdowns[i].Parent = null;
                                    Dropdowns.RemoveAt(i);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            if (!DesignMode)
            {
                if (hot != null)
                {
                    hot.DoEvents();
                }

                DoKeyEvents();

                if (FocusedControl != null)
                {
                    FocusedControl.DoKeyEvents();
                }

                if (IsDragging)
                {
                    SetTooltip(dropTarget);
                }
                else
                {
                    SetTooltip((down > -1 || pressed > -1) ? null : hot);
                }
            }

            PerformUpdate();
            PerformLayout();
            PerformLateUpdate();

            foreach (KeyData data in Gui.KeyBuffer)
            {
                if (data.Pressed && data.Key == Keys.TAB)
                {
                    if (Gui.ShiftPressed)
                    {
                        TabPrevious();
                    }
                    else
                    {
                        TabNext();
                    }
                }
            }
        }