예제 #1
0
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            // Create and add interior panel that will "hold" all of the example controls
            Size panelSize = new Size(this.Size.Width-2,this.Size.Height-24);

            PanelTemplate panelTemplate = new PanelTemplate()
            {
                HasFrame = true,
                UpperLeftPos = this.LocalRect.UpperLeft.Shift(1,3),
                Size = panelSize
            };
            //panelTemplate.SetLowerRight(this.ScreenRect.LowerRight.Shift(-1, -17));
            AddControl(new Panel(panelTemplate));

            ViewRect = Rect.Inflate(panelTemplate.CalculateRect(),-1,-1);

            // Create the page info TextBox control.  Each page will have one.
            Rect textBoxRect = new Rect(panelTemplate.CalculateRect().LowerLeft.Shift(0, 1),
                this.LocalRect.LowerRight.Shift(-1, -1));

            TextBoxTemplate tbt = new TextBoxTemplate()
            {
                Size = textBoxRect.Size,
                UpperLeftPos = textBoxRect.UpperLeft,
                TextSpeed = 5,
                Pigments = new PigmentAlternatives()
                {
                    {PigmentType.Window,new Pigment(0xaaaaaa,0x111511)}
                }
            };

            PageInfo = new TextBox(tbt);
            AddControl(PageInfo);

            // Create the next, previous and quit buttons.  Each page will have these
            // buttons
            ButtonTemplate nextButtonTemplate = new ButtonTemplate()
            {
                Label = "Next->",
                Tooltip = "Click to go to the next page",
                HilightWhenMouseOver = true,
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 12
            };
            nextButtonTemplate.SetUpperRight(Application.ScreenRect.UpperRight);

            ButtonTemplate previousButtonTemplate = new ButtonTemplate()
            {
                Label = "<-Previous",
                Tooltip = "Click to go to the previous page",
                HilightWhenMouseOver = true,
                UpperLeftPos = new Point(0, 0),
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 12
            };

            ButtonTemplate quitButtonTemplate = new ButtonTemplate()
            {
                Label = "QUIT",
                Tooltip = "Quit the demo",
                HilightWhenMouseOver = true,
                LabelAlignment = HorizontalAlignment.Center,
                MinimumWidth = 38
            };
            quitButtonTemplate.SetTopCenter(Application.ScreenRect.TopCenter);

            Button quitButton = new Button(quitButtonTemplate);
            nextButton = new Button(nextButtonTemplate);
            prevButton = new Button(previousButtonTemplate);

            AddControls(nextButton, prevButton, quitButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);
            prevButton.ButtonPushed += new EventHandler(prevButton_ButtonClicked);
            nextButton.ButtonPushed += new EventHandler(nextButton_ButtonClicked);

            prevButton.IsActive = hasPrev;
            nextButton.IsActive = hasNext;
        }
예제 #2
0
        /// Here we create all of the Gui elements and add them to this window.
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            /// Set the label strings for each of the directional buttons
            string upLabel    = ((char)libtcod.TCODSpecialCharacter.ArrowNorth).ToString();
            string downLabel  = ((char)libtcod.TCODSpecialCharacter.ArrowSouth).ToString();
            string rightLabel = ((char)libtcod.TCODSpecialCharacter.ArrowEast).ToString();
            string leftLabel  = ((char)libtcod.TCODSpecialCharacter.ArrowWest).ToString();



            /// We are going to create a series of 4 buttons, each representing a direction.
            /// To do this, I'll illustrate some of the helper methods for positioning controls.
            ///
            /// First we position the upButton normally...
            ButtonTemplate upButtonTemplate = new ButtonTemplate()
            {
                Label        = upLabel,
                UpperLeftPos = new Point(3, 0)
            };



            /// Now the RIGHT direction button, which I want to sit just off the lower right side
            /// of the previously defined UP button.  Notice the string of methods used to set this
            /// UpperLeftPos.  We can break it down as follows:
            ///     1.  upButtonInfo.CalculateRect() returns the Rect structure representing the previously
            ///         defined UP button
            ///     2.  Rect.LowerRight gives us the Point structure of the lower right corner of that rect
            ///     3.  Shift(int dx, int dy) shifts that point 1 space to the right and 1 space down.
            /// Basically this is a shorthand way (especially in todays world of
            /// intellisense IDE's) of specifying a position relative to another button.  In the next example,
            /// we will see a different (and more intuitive) way of doing this sort of relative layout.

            ButtonTemplate rightButtonTemplate = new ButtonTemplate()
            {
                Label        = rightLabel,
                UpperLeftPos = upButtonTemplate.CalculateRect().LowerRight.Shift(1, 1)
            };



            /// For the DOWN button we will need to do something a little different.  I want to set the upper right
            /// corner of the DOWN button off the lower left corner of the RIGHT button.  However, ButtonInfo
            /// does not expose a property to set the upper right position (since this would allow the user
            /// to specify two different positions in the same constructor).  But there is still a way to do this:
            /// just create the ButtonInfo normally, leaving out the position...
            ButtonTemplate downButtonTemplate = new ButtonTemplate()
            {
                Label = downLabel,
            };

            /// Then we use the SetUpperRight method to set the position, like so:

            downButtonTemplate.SetUpperRight(rightButtonTemplate.CalculateRect().LowerLeft.Shift(-1, 1));



            /// Finally, our LEFT button's upper right corner is just off the lower left corner
            /// of the UP button:

            ButtonTemplate leftButtonTemplate = new ButtonTemplate()
            {
                Label = leftLabel
            };

            leftButtonTemplate.SetUpperRight(upButtonTemplate.CalculateRect().LowerLeft.Shift(-1, 1));



            /// We just need to make sure we actually create the buttons, like so:

            Button upButton    = new Button(upButtonTemplate);
            Button rightButton = new Button(rightButtonTemplate);
            Button downButton  = new Button(downButtonTemplate);
            Button leftButton  = new Button(leftButtonTemplate);



            /// Our quit button, this time we will give it the upper left position explicitly.  Also, since
            /// we don't need to keep the ButtonTemplate around, we do the creation in one step.
            Button quitButton = new Button(new ButtonTemplate()
            {
                Label        = "QUIT",
                UpperLeftPos = new Point(74, 0)
            });



            /// This time we use AddControls to add multiple controls to the window.  The controls are added
            /// in order, from lowest to highest.
            AddControls(quitButton, upButton, downButton, leftButton, rightButton);

            /// Hook into each of the required button event handlers.
            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClickedEventHandler);

            upButton.ButtonPushed    += new EventHandler(upButton_ButtonClicked);
            downButton.ButtonPushed  += new EventHandler(downButton_ButtonClicked);
            rightButton.ButtonPushed += new EventHandler(rightButton_ButtonClicked);
            leftButton.ButtonPushed  += new EventHandler(leftButton_ButtonClicked);
        }
예제 #3
0
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            // Create and add interior panel that will "hold" all of the example controls
            Size panelSize = new Size(this.Size.Width - 2, this.Size.Height - 24);

            PanelTemplate panelTemplate = new PanelTemplate()
            {
                HasFrame     = true,
                UpperLeftPos = this.LocalRect.UpperLeft.Shift(1, 3),
                Size         = panelSize
            };

            //panelTemplate.SetLowerRight(this.ScreenRect.LowerRight.Shift(-1, -17));
            AddControl(new Panel(panelTemplate));

            ViewRect = Rect.Inflate(panelTemplate.CalculateRect(), -1, -1);


            // Create the page info TextBox control.  Each page will have one.
            Rect textBoxRect = new Rect(panelTemplate.CalculateRect().LowerLeft.Shift(0, 1),
                                        this.LocalRect.LowerRight.Shift(-1, -1));

            TextBoxTemplate tbt = new TextBoxTemplate()
            {
                Size         = textBoxRect.Size,
                UpperLeftPos = textBoxRect.UpperLeft,
                TextSpeed    = 5,
                Pigments     = new PigmentAlternatives()
                {
                    { PigmentType.Window, new Pigment(0xaaaaaa, 0x111511) }
                }
            };

            PageInfo = new TextBox(tbt);
            AddControl(PageInfo);

            // Create the next, previous and quit buttons.  Each page will have these
            // buttons
            ButtonTemplate nextButtonTemplate = new ButtonTemplate()
            {
                Label   = "Next->",
                Tooltip = "Click to go to the next page",
                HilightWhenMouseOver = true,
                LabelAlignment       = HorizontalAlignment.Center,
                MinimumWidth         = 12
            };

            nextButtonTemplate.SetUpperRight(Application.ScreenRect.UpperRight);

            ButtonTemplate previousButtonTemplate = new ButtonTemplate()
            {
                Label   = "<-Previous",
                Tooltip = "Click to go to the previous page",
                HilightWhenMouseOver = true,
                UpperLeftPos         = new Point(0, 0),
                LabelAlignment       = HorizontalAlignment.Center,
                MinimumWidth         = 12
            };


            ButtonTemplate quitButtonTemplate = new ButtonTemplate()
            {
                Label   = "QUIT",
                Tooltip = "Quit the demo",
                HilightWhenMouseOver = true,
                LabelAlignment       = HorizontalAlignment.Center,
                MinimumWidth         = 38
            };

            quitButtonTemplate.SetTopCenter(Application.ScreenRect.TopCenter);

            Button quitButton = new Button(quitButtonTemplate);

            nextButton = new Button(nextButtonTemplate);
            prevButton = new Button(previousButtonTemplate);

            AddControls(nextButton, prevButton, quitButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);
            prevButton.ButtonPushed += new EventHandler(prevButton_ButtonClicked);
            nextButton.ButtonPushed += new EventHandler(nextButton_ButtonClicked);

            prevButton.IsActive = hasPrev;
            nextButton.IsActive = hasNext;
        }
예제 #4
0
파일: Sample2.cs 프로젝트: AIBrain/ochregui
        /// Here we create all of the Gui elements and add them to this window.
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            /// Set the label strings for each of the directional buttons
            string upLabel = ((char)libtcod.TCODSpecialCharacter.ArrowNorth).ToString();
            string downLabel = ((char)libtcod.TCODSpecialCharacter.ArrowSouth).ToString();
            string rightLabel = ((char)libtcod.TCODSpecialCharacter.ArrowEast).ToString();
            string leftLabel = ((char)libtcod.TCODSpecialCharacter.ArrowWest).ToString();

            /// We are going to create a series of 4 buttons, each representing a direction.
            /// To do this, I'll illustrate some of the helper methods for positioning controls.
            ///
            /// First we position the upButton normally...
            ButtonTemplate upButtonTemplate = new ButtonTemplate()
            {
                Label = upLabel,
                UpperLeftPos = new Point(3, 0)
            };

            /// Now the RIGHT direction button, which I want to sit just off the lower right side
            /// of the previously defined UP button.  Notice the string of methods used to set this
            /// UpperLeftPos.  We can break it down as follows:
            ///     1.  upButtonInfo.CalculateRect() returns the Rect structure representing the previously
            ///         defined UP button
            ///     2.  Rect.LowerRight gives us the Point structure of the lower right corner of that rect
            ///     3.  Shift(int dx, int dy) shifts that point 1 space to the right and 1 space down.
            /// Basically this is a shorthand way (especially in todays world of
            /// intellisense IDE's) of specifying a position relative to another button.  In the next example,
            /// we will see a different (and more intuitive) way of doing this sort of relative layout.

            ButtonTemplate rightButtonTemplate = new ButtonTemplate()
            {
                Label = rightLabel,
                UpperLeftPos = upButtonTemplate.CalculateRect().LowerRight.Shift(1,1)
            };

            /// For the DOWN button we will need to do something a little different.  I want to set the upper right
            /// corner of the DOWN button off the lower left corner of the RIGHT button.  However, ButtonInfo
            /// does not expose a property to set the upper right position (since this would allow the user
            /// to specify two different positions in the same constructor).  But there is still a way to do this:
            /// just create the ButtonInfo normally, leaving out the position...
            ButtonTemplate downButtonTemplate = new ButtonTemplate()
            {
                Label = downLabel,
            };

            /// Then we use the SetUpperRight method to set the position, like so:

            downButtonTemplate.SetUpperRight(rightButtonTemplate.CalculateRect().LowerLeft.Shift(-1, 1));

            /// Finally, our LEFT button's upper right corner is just off the lower left corner
            /// of the UP button:

            ButtonTemplate leftButtonTemplate = new ButtonTemplate()
            {
                Label = leftLabel
            };
            leftButtonTemplate.SetUpperRight(upButtonTemplate.CalculateRect().LowerLeft.Shift(-1, 1));

            /// We just need to make sure we actually create the buttons, like so:

            Button upButton = new Button(upButtonTemplate);
            Button rightButton = new Button(rightButtonTemplate);
            Button downButton = new Button(downButtonTemplate);
            Button leftButton = new Button(leftButtonTemplate);

            /// Our quit button, this time we will give it the upper left position explicitly.  Also, since
            /// we don't need to keep the ButtonTemplate around, we do the creation in one step.
            Button quitButton = new Button(new ButtonTemplate()
            {
                Label = "QUIT",
                UpperLeftPos = new Point(74, 0)
            });

            /// This time we use AddControls to add multiple controls to the window.  The controls are added
            /// in order, from lowest to highest.
            AddControls(quitButton, upButton, downButton, leftButton, rightButton);

            /// Hook into each of the required button event handlers.
            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClickedEventHandler);

            upButton.ButtonPushed += new EventHandler(upButton_ButtonClicked);
            downButton.ButtonPushed += new EventHandler(downButton_ButtonClicked);
            rightButton.ButtonPushed += new EventHandler(rightButton_ButtonClicked);
            leftButton.ButtonPushed += new EventHandler(leftButton_ButtonClicked);
        }