예제 #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>
        /// <param name="message">Message to display.</param>
        /// <param name="title">Window title.</param>
        /// <param name="buttons">Tyoe of buttons to display.</param>
        /// <param name="type">Type of icon to use.</param>
        public MessageBox(
            Game game,
            GUIManager guiManager,
            string message,
            string title,
            MessageBoxButtons buttons,
            MessageBoxType type
            )
            : base(game, guiManager)
        {
            this.buttonList = new List<TextButton>();

            #region Create Child Controls
            this.icon = new Icon(game, guiManager);
            this.message = new Label(game, guiManager);
            #endregion

            this.buttons = buttons;

            if (this.buttons == MessageBoxButtons.OK || this.buttons == MessageBoxButtons.Yes_No)
                HasCloseButton = false;

            this.infoSkin = defaultInfoSkin;
            this.errorSkin = defaultErrorSkin;
            this.warningSkin = defaultWarningSkin;
            this.questionSkin = defaultQuestionSkin;

            this.type = type;

            Add(this.message);
            this.TitleText = title;
            this.message.Text = message;

            int numButtons = 0;

            if (this.buttons == MessageBoxButtons.OK)
                numButtons = 1;
            else if (this.buttons == MessageBoxButtons.OK_Cancel || this.buttons == MessageBoxButtons.Yes_No)
                numButtons = 2;
            else if (this.buttons == MessageBoxButtons.Yes_No_Cancel)
                numButtons = 3;

            for (int i = 0; i < numButtons; i++)
            {
                TextButton newButton = new TextButton(game, guiManager);
                this.buttonList.Add(newButton);
                Add(newButton);

                if (i == 0)
                {
                    if (this.buttons == MessageBoxButtons.OK || this.buttons == MessageBoxButtons.OK_Cancel)
                        newButton.Text = "OK";
                    else
                        newButton.Text = "Yes";
                }
                else if (i == 1)
                {
                    if (this.buttons == MessageBoxButtons.OK_Cancel)
                        newButton.Text = "Cancel";
                    else
                        newButton.Text = "No";
                }
                else
                    newButton.Text = "Cancel";

                newButton.Click += new ClickHandler(OnClick);
            }

            ArrangeWindow(type);
        }
예제 #2
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
        }
예제 #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 ComboBox(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            this.isListBoxOpen = false;

            #region Create Child Controls
            this.textBox = new TextBox(game, guiManager);
            this.button = new Icon(game, guiManager);
            this.listBox = new ListBox(game, guiManager);
            #endregion

            #region Add Child Controls
            Add(this.textBox);
            Add(this.button);
            #endregion

            #region Set Properties
            this.listBox.ResizeToFit = true;
            #endregion

            #region Set Default Properties
            this.Width = defaultWidth;
            this.Height = defaultHeight;
            this.Font = defaultFont;
            ButtonSkin = defaultButtonSkin;
            ButtonHoverSkin = defaultButtonHoverSkin;
            ButtonPressedSkin = defaultButtonPressedSkin;
            #endregion

            #region Event Handlers
            this.button.MouseOver += new MouseOverHandler(OnButtonMouseOver);
            this.button.MouseOut += new MouseOutHandler(OnButtonMouseOut);
            this.button.MouseDown += new MouseDownHandler(OnButtonMouseDown);
            this.button.LoseFocus += new LoseFocusHandler(OnButtonLoseFocus);
            this.listBox.SelectedChanged += new SelectionChangedHandler(OnSelectionChanged);
            this.listBox.LoseFocus += new LoseFocusHandler(OnListBoxLoseFocus);
            #endregion
        }