Beispiel #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="game">The currently running Game object.</param>
        /// <param name="guiManager">GUIManager that this control is part of.</param>
        public MenuItem(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            this.numMenuItems     = 0;
            this.numClicks        = 0;
            this.isPopUpShown     = false;
            this.isHighlightShown = false;
            this.isEnabled        = true;
            this.canClose         = true;

            #region Create Child Controls
            this.label        = new Label(game, guiManager);
            this.highlightBox = new Box(game, guiManager);
            this.popUpMenu    = new PopUpMenu(game, guiManager);
            this.arrow        = new Icon(game, guiManager);
            #endregion

            #region Add Child Controls
            base.Add(this.label);
            #endregion

            #region Set Default Properties
            HMargin       = defaultHMargin;
            VMargin       = defaultVMargin;
            HighlightSkin = defaultHighlightSkin;
            ArrowSkin     = defaultArrowSkin;
            #endregion

            #region Event Handlers
            this.popUpMenu.Close += new CloseHandler(OnPopUpClosed);
            #endregion
        }
Beispiel #2
0
        /// <summary>
        /// Refreshes child control positions and sizes.
        /// </summary>
        private void RefreshMargins()
        {
            int       imageMarginWidth   = 0;
            PopUpMenu parentPopUpMenu    = this.Parent as PopUpMenu;
            bool      imageMarginVisible = parentPopUpMenu != null && parentPopUpMenu.ShowMarginImage;

            if (imageMarginVisible) // Image margin displayed
            {
                imageMarginWidth = parentPopUpMenu.MarginWidth;
            }

            if (!this.canClose && this.numMenuItems > 0) // Arrow displayed
            {
                base.Add(this.arrow);
                Width = imageMarginWidth + this.label.TextWidth + (this.hMargin * 3) + this.arrow.Width;
            }
            else
            {
                base.Remove(this.arrow);
                Width = imageMarginWidth + this.label.TextWidth + (this.hMargin * 2);
            }

            Height = this.label.TextHeight + (this.vMargin * 2);

            this.label.X     = imageMarginWidth + this.hMargin;
            this.label.Width = Width - this.label.X - this.hMargin;

            this.label.Y      = this.vMargin;
            this.label.Height = Height - this.label.Y - this.vMargin;

            if (imageMarginVisible)
            {
                this.icon.Visible = true;
                this.icon.X       = (imageMarginWidth - this.icon.Width) / 2;
                this.icon.Y       = (this.Height - this.icon.Height) / 2;
            }
            else
            {
                this.icon.Visible = false;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="game">The currently running Game object.</param>
        /// <param name="guiManager">GUIManager that this control is part of.</param>
        public MenuItem(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            this.numMenuItems = 0;
            this.numClicks = 0;
            this.isPopUpShown = false;
            this.isHighlightShown = false;
            this.isEnabled = true;
            this.canClose = true;

            #region Create Child Controls
            this.label = new Label(game, guiManager);
            this.highlightBox = new Box(game, guiManager);
            this.popUpMenu = new PopUpMenu(game, guiManager);
            this.arrow = new Icon(game, guiManager);
            #endregion

            #region Add Child Controls
            base.Add(this.label);
            #endregion

            #region Set Default Properties
            HMargin = defaultHMargin;
            VMargin = defaultVMargin;
            HighlightSkin = defaultHighlightSkin;
            ArrowSkin = defaultArrowSkin;
            #endregion

            #region Event Handlers
            this.popUpMenu.Close += new CloseHandler(OnPopUpClosed);
            #endregion
        }