示例#1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // TODO: Add your update logic here
            textbox.Update(gameTime);
            button.Update(gameTime);

            if (listbox.Visible)
            {
                listbox.Update(gameTime);

                if (!listbox.area.Contains(MouseHelper.Cursor.Location) && MouseHelper.HasBeenPressed && !justOpened)
                {
                    Close();
                }

                if (MouseHelper.HasBeenReleased)
                {
                    justOpened = false;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Update every enabled control
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            area.X      = (int)Position.X;
            area.Y      = (int)Position.Y;
            area.Width  = (int)Size.X;
            area.Height = (int)Size.Y;

            UpdateState();
            UpdateTopMost();

            if (state == WindowState.Normal && !isMaximized && !isMinimized)
            {
                if (!isResizing)
                {
                    CheckDragging();
                }
                if (!isDragging && style == BorderStyle.Sizable)
                {
                    CheckResize();
                }
            }

            CheckDoubleClick(gameTime);

            if (state != WindowState.Minimized && !isMinimized)
            {
                if (Size.X < minimumSize.X)
                {
                    Width = minimumSize.X;
                }
                if (Size.Y < minimumSize.Y)
                {
                    Height = minimumSize.Y;
                }
            }

            if (FormCollection.TopMostForm == this || (isMinimized && FormCollection.ActiveForm == this))
            {
                if (menu != null && menu.Visible)
                {
                    menu.Update(gameTime);
                }

                if (btClose != null)
                {
                    btClose.Update(gameTime);
                }

                if (btMinimize != null && ((hasMinimizeButton && !isMinimized) || (hasMaximizeButton && isMaximized)))
                {
                    btMinimize.Update(gameTime);
                }

                if (btMaximize != null && ((hasMaximizeButton && !isMaximized) || (hasMinimizeButton && isMinimized)))
                {
                    btMaximize.Update(gameTime);
                }

                if (btRestore != null && ((hasMinimizeButton && isMinimized) || (hasMaximizeButton && isMaximized)))
                {
                    btRestore.Update(gameTime);
                }

                if (menu == null || !menu.Visible || menu.State == Menu.MenuState.Closed)
                {
                    if (state == WindowState.Normal || state == WindowState.Maximized)
                    {
                        //ComboBox fix (so the controls underneath the listbox don't update)
                        bool skip = false;
                        for (int i = 0; i < controls.Count; i++)
                        {
                            if (controls[i].GetType() == typeof(ComboBox) && ((ComboBox)controls[i]).Opened)
                            {
                                controls[i].Update(gameTime);
                                skip = true;
                            }
                        }


                        if (!skip)
                        {
                            for (int i = 0; i < controls.Count; i++)
                            {
                                if (!controls[i].IsDisposed && controls[i].Enabled) // && area.Contains(controls[i].area))
                                {
                                    controls[i].Update(gameTime);
                                }
                            }
                        }
                    }
                }
            }

            UpdateActive();

            if (FormCollection.ActiveForm != this)
            {
                if (isResizing)
                {
                    isResizing = false;
                }
                if (isDragging)
                {
                    isDragging = false;
                }
            }
        }