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 TextButton(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            #region Create Child Controls
            this.buttonBar = new Bar(game, guiManager);
            this.label = new Label(game, guiManager);
            #endregion

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

            #region Set Properties
            this.buttonBar.IsVertical = false;
            MinWidth = defaultHeight;
            MinHeight = defaultHeight;
            #endregion

            #region Set Default Properties
            Width = defaultWidth;
            Height = defaultHeight;
            EdgeSize = defaultEdgeSize;
            Skin = defaultSkin;
            HoverSkin = defaultHoverSkin;
            PressedSkin = defaultPressedSkin;
            #endregion
        }
Beispiel #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 Window(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            this.isResizable = true;
            this.transparency = -1;

            #region Create Child Controls
            this.box = new Box(game, guiManager);
            this.viewPort = new UIComponent(game, guiManager);
            this.titleBar = new Bar(game, guiManager);
            this.movableArea = new MovableArea(game, guiManager);
            this.backgroundMovableArea = new MovableArea(game, guiManager);
            this.label = new Label(game, guiManager);
            this.closeButton = new ImageButton(game, guiManager);
            #endregion

            #region Add Child Controls
            base.Add(this.box);
            base.Add(this.viewPort);
            base.Add(this.titleBar);
            base.Add(this.label);
            base.Add(this.movableArea);
            #endregion

            #region Add Resizable Areas
            this.resizableAreas = new ResizableArea[8];

            for (int i = 0; i < 8; i++)
            {
                this.resizableAreas[i] = new ResizableArea(game, guiManager);
                this.resizableAreas[i].ZOrder = 0.3f;
                this.resizableAreas[i].StartResizing += new StartResizingHandler(OnStartAnimating);
                this.resizableAreas[i].EndResizing += new EndResizingHandler(OnEndAnimating);
                base.Add(this.resizableAreas[i]);
            }

            this.resizableAreas[0].ResizeArea = ResizeAreas.TopLeft;
            this.resizableAreas[1].ResizeArea = ResizeAreas.Top;
            this.resizableAreas[2].ResizeArea = ResizeAreas.TopRight;
            this.resizableAreas[3].ResizeArea = ResizeAreas.Left;
            this.resizableAreas[4].ResizeArea = ResizeAreas.Right;
            this.resizableAreas[5].ResizeArea = ResizeAreas.BottomLeft;
            this.resizableAreas[6].ResizeArea = ResizeAreas.Bottom;
            this.resizableAreas[7].ResizeArea = ResizeAreas.BottomRight;
            #endregion

            #region Set Non-Default Properties
            this.movableArea.ZOrder = 0.1f;
            this.closeButton.ZOrder = 0.4f;
            this.viewPort.ZOrder = 0.2f;
            this.viewPort.CanHaveFocus = true;
            MinWidth = 150;
            #endregion

            #region Set Default Properties
            Margin = defaultMargin;
            HasCloseButton = defaultHasCloseButton;
            HasFullWindowMovableArea = defaultFullWindowMovableArea;
            TitleBarHeight = defaultTitleBarHeight;
            Width = MinWidth;
            Height = MinHeight;
            ButtonSize = defaultButtonSize;
            Skin = defaultSkin;
            TitleBarSkin = defaultTitleBarSkin;
            CloseButtonSkin = defaultCloseButtonSkin;
            CloseButtonHoverSkin = defaultCloseButtonHoverSkin;
            CloseButtonPressedSkin = defaultCloseButtonPressedSkin;
            #endregion

            #region Event Handlers
            this.closeButton.Click += new ClickHandler(OnClose);
            this.movableArea.StartMoving += new StartMovingHandler(OnStartAnimating);
            this.movableArea.EndMoving += new EndMovingHandler(OnEndAnimating);
            this.backgroundMovableArea.StartMoving += new StartMovingHandler(OnStartAnimating);
            this.backgroundMovableArea.EndMoving += new EndMovingHandler(OnEndAnimating);
            #endregion

            Refresh();
        }
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 ScrollBar(Game game, GUIManager guiManager)
            : base(game, guiManager)
        {
            this.value = 0;
            this.viewable = 1;
            this.maximumValue = 1;
            this.scrollStep = 1;
            this.countdown = 0;
            this.firstRepeat = true;
            this.isTopPressed = false;
            this.isBottomPressed = false;
            this.isTopOver = false;
            this.isBottomOver = false;
            this.draggingThumb = false;
            this.lastLocation = Point.Zero;

            #region Create Child Controls
            this.topButton = new ImageButton(game, guiManager);
            this.bottomButton = new ImageButton(game, guiManager);
            this.thumb = new Bar(game, guiManager);
            #endregion

            #region Add Child Controls
            // Thumb added first so buttons drawn on top when really small
            Add(this.thumb);
            Add(this.topButton);
            Add(this.bottomButton);
            #endregion

            #region Set Properties
            MinWidth = defaultButtonSize;
            MinHeight = 2 * defaultButtonSize;
            Scale = true;
            this.thumb.CanHaveFocus = true;
            this.thumb.IsVertical = true;
            this.thumb.Y = defaultButtonSize;
            #endregion

            #region Set Default Properties
            Width = defaultButtonSize;
            BackgroundSkin = defaultBackgroundSkin;
            TopButtonSkin = defaultTopButtonSkin;
            TopButtonHoverSkin = defaultTopButtonHoverSkin;
            TopButtonPressedSkin = defaultTopButtonPressedSkin;
            BottomButtonSkin = defaultBottomButtonSkin;
            BottomButtonHoverSkin = defaultBottomButtonHoverSkin;
            BottomButtonPressedSkin = defaultBottomButtonPressedSkin;
            ThumbSkin = defaultThumbSkin;
            ThumbHoverSkin = defaultThumbHoverSkin;
            ThumbPressedSkin = defaultThumbPressedSkin;
            #endregion

            #region Event Handlers
            this.topButton.MouseDown += new MouseDownHandler(OnTopButtonDown);
            this.topButton.MouseUp += new MouseUpHandler(OnButtonUp);
            this.topButton.MouseOut += new MouseOutHandler(OnTopButtonOut);
            this.topButton.MouseOver += new MouseOverHandler(OnTopButtonOver);
            this.bottomButton.MouseDown += new MouseDownHandler(OnBottomButtonDown);
            this.bottomButton.MouseUp += new MouseUpHandler(OnButtonUp);
            this.bottomButton.MouseOver += new MouseOverHandler(OnBottomButtonOver);
            this.bottomButton.MouseOut += new MouseOutHandler(OnBottomButtonOut);
            this.thumb.MouseOver += new MouseOverHandler(OnThumbMouseOver);
            this.thumb.MouseOut += new MouseOutHandler(OnThumbMouseOut);
            this.thumb.MouseDown += new MouseDownHandler(OnThumbDown);
            this.thumb.MouseUp += new MouseUpHandler(OnThumbUp);
            this.thumb.MouseMove += new MouseMoveHandler(OnThumbMove);
            #endregion
        }