コード例 #1
0
ファイル: Page1.cs プロジェクト: AIBrain/ochregui
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            // Start creating and adding the various sample controls.
            ButtonTemplate bt0 = new ButtonTemplate()
            {
                Label = "Autosize",
                UpperLeftPos = ViewRect.UpperLeft.Shift(1,3),
            };
            AddControl(new Button(bt0));

            ButtonTemplate bt1 = new ButtonTemplate()
            {
                Label = "Min. Size",
                MinimumWidth = 15
            };
            bt1.UpperLeftPos = bt0.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt1));

            ButtonTemplate bt2 = new ButtonTemplate()
            {
                Label = "No Border",
                HasFrameBorder = false,

            };
            bt2.UpperLeftPos = bt1.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt2));

            ButtonTemplate bt3 = new ButtonTemplate()
            {
                Label = "Centered",
                MinimumWidth = 15,
                LabelAlignment = HorizontalAlignment.Center
            };
            bt3.UpperLeftPos = bt2.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt3));

            ButtonTemplate bt4 = new ButtonTemplate()
            {
                Label = "Right",
                MinimumWidth = 15,
                LabelAlignment = HorizontalAlignment.Right
            };
            bt4.UpperLeftPos = bt3.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt4));

            ButtonTemplate bt5 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15,5),
                VAlignment = VerticalAlignment.Top,
                LabelAlignment = HorizontalAlignment.Left
            };
            bt5.AlignTo(LayoutDirection.East, bt0, 8);
            AddControl(new Button(bt5));

            ButtonTemplate bt6 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Center,
                LabelAlignment = HorizontalAlignment.Left
            };
            bt6.AlignTo(LayoutDirection.South, bt5, 2);
            AddControl(new Button(bt6));

            ButtonTemplate bt7 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Bottom,
                LabelAlignment = HorizontalAlignment.Left
            };
            bt7.AlignTo(LayoutDirection.South, bt6, 2);
            AddControl(new Button(bt7));

            ButtonTemplate bt8 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Top,
                LabelAlignment = HorizontalAlignment.Center,
                HasFrameBorder = false,
            };
            bt8.AlignTo(LayoutDirection.East, bt5, 2);
            AddControl(new Button(bt8));

            ButtonTemplate bt9 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Center,
                LabelAlignment = HorizontalAlignment.Center,
                HasFrameBorder = false,
            };
            bt9.AlignTo(LayoutDirection.South, bt8, 2);
            AddControl(new Button(bt9));

            ButtonTemplate bt10 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Bottom,
                LabelAlignment = HorizontalAlignment.Center,
                HasFrameBorder = false,
            };
            bt10.AlignTo(LayoutDirection.South, bt9, 2);
            AddControl(new Button(bt10));

            ButtonTemplate bt11 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Top,
                LabelAlignment = HorizontalAlignment.Right
            };
            bt11.AlignTo(LayoutDirection.East, bt8, 2);
            AddControl(new Button(bt11));

            ButtonTemplate bt12 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Center,
                LabelAlignment = HorizontalAlignment.Right
            };
            bt12.AlignTo(LayoutDirection.South, bt11, 2);
            AddControl(new Button(bt12));

            ButtonTemplate bt13 = new ButtonTemplate()
            {
                Label = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment = VerticalAlignment.Bottom,
                LabelAlignment = HorizontalAlignment.Right,
            };
            bt13.AlignTo(LayoutDirection.South, bt12, 2);
            AddControl(new Button(bt13));

            ButtonTemplate bt14 = new ButtonTemplate()
            {
                Label = "Animated",
                AutoSizeOverride = new Size(12,5),
                VAlignment = VerticalAlignment.Center,
                LabelAlignment = HorizontalAlignment.Center
            };
            bt14.AlignTo(LayoutDirection.South, bt4, 4);
            AddControl(new WaveButton(bt14));

            ButtonTemplate bt15 = new ButtonTemplate()
            {
                Label = "Normal Draw",
                LabelAlignment = HorizontalAlignment.Center
            };
            bt15.AlignTo(LayoutDirection.South, bt14, 4);
            AddControl(new OwnerButton(bt15));

            ButtonTemplate bt16 = new ButtonTemplate()
            {
                Label = "901 Animated Buttons!",
            };
            bt16.AlignTo(LayoutDirection.South, bt10, 2);
            AddControl(new Button(bt16));

            // Create the matrix of animated buttons.
            // Note there is actually a large amount of overhead here - this is
            // NOT the efficient way to do this.  However, this is meant to
            // "stress test" the library, so this is how we are doing it.
            for (int y = 30; y < 47; y++)
            {
                for (int x = 20; x < 73; x++)
                {
                    ButtonTemplate bt17 = new ButtonTemplate()
                    {
                        Label = " ",
                        AutoSizeOverride = new Size(1, 1),
                        HasFrameBorder = false,
                        UpperLeftPos = new Point(x, y)
                    };

                    AddControl(new SparkleButton(bt17));
                }
            }

            PageInfo.AddText("Here is a sample selection of buttons, in various styles." +
                "\n\nTry clicking on the Animated and Owner Draw buttons to see custom behavior." +
                "\n\nNote that the 901 animated button matrix is a stress test - each button is being " +
                "created individually, each with its own scheduler, message hooks, and memory console. This is an " +
                "enormous amount of overhead, and here we can see how much it slows down the framework by "+
                "comparing the text output of this TextBox to the other pages.");

            PageInfo.AddText("\n\nHere are a couple of general things to note about the demo project:");
            PageInfo.AddText("\n* Each page is a seperate Window with its own controls" +
                "\n* The popup tooltips are intelligently constrained to the window"+
                "\n* This text is being drawn by a TextBox control from extended library",
                PageInfo.Pigments[PigmentType.Window].ReplaceForeground(new Color(0x885599))
                );
        }
コード例 #2
0
ファイル: Sample2.cs プロジェクト: vanattab/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);
        }
コード例 #3
0
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            // Start creating and adding the various sample controls.
            ButtonTemplate bt0 = new ButtonTemplate()
            {
                Label        = "Autosize",
                UpperLeftPos = ViewRect.UpperLeft.Shift(1, 3),
            };

            AddControl(new Button(bt0));

            ButtonTemplate bt1 = new ButtonTemplate()
            {
                Label        = "Min. Size",
                MinimumWidth = 15
            };

            bt1.UpperLeftPos = bt0.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt1));

            ButtonTemplate bt2 = new ButtonTemplate()
            {
                Label          = "No Border",
                HasFrameBorder = false,
            };

            bt2.UpperLeftPos = bt1.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt2));

            ButtonTemplate bt3 = new ButtonTemplate()
            {
                Label          = "Centered",
                MinimumWidth   = 15,
                LabelAlignment = HorizontalAlignment.Center
            };

            bt3.UpperLeftPos = bt2.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt3));

            ButtonTemplate bt4 = new ButtonTemplate()
            {
                Label          = "Right",
                MinimumWidth   = 15,
                LabelAlignment = HorizontalAlignment.Right
            };

            bt4.UpperLeftPos = bt3.CalculateRect().LowerLeft.Shift(0, 2);
            AddControl(new Button(bt4));

            ButtonTemplate bt5 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Top,
                LabelAlignment   = HorizontalAlignment.Left
            };

            bt5.AlignTo(LayoutDirection.East, bt0, 8);
            AddControl(new Button(bt5));

            ButtonTemplate bt6 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Center,
                LabelAlignment   = HorizontalAlignment.Left
            };

            bt6.AlignTo(LayoutDirection.South, bt5, 2);
            AddControl(new Button(bt6));

            ButtonTemplate bt7 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Bottom,
                LabelAlignment   = HorizontalAlignment.Left
            };

            bt7.AlignTo(LayoutDirection.South, bt6, 2);
            AddControl(new Button(bt7));

            ButtonTemplate bt8 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Top,
                LabelAlignment   = HorizontalAlignment.Center,
                HasFrameBorder   = false,
            };

            bt8.AlignTo(LayoutDirection.East, bt5, 2);
            AddControl(new Button(bt8));

            ButtonTemplate bt9 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Center,
                LabelAlignment   = HorizontalAlignment.Center,
                HasFrameBorder   = false,
            };

            bt9.AlignTo(LayoutDirection.South, bt8, 2);
            AddControl(new Button(bt9));

            ButtonTemplate bt10 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Bottom,
                LabelAlignment   = HorizontalAlignment.Center,
                HasFrameBorder   = false,
            };

            bt10.AlignTo(LayoutDirection.South, bt9, 2);
            AddControl(new Button(bt10));

            ButtonTemplate bt11 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Top,
                LabelAlignment   = HorizontalAlignment.Right
            };

            bt11.AlignTo(LayoutDirection.East, bt8, 2);
            AddControl(new Button(bt11));

            ButtonTemplate bt12 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Center,
                LabelAlignment   = HorizontalAlignment.Right
            };

            bt12.AlignTo(LayoutDirection.South, bt11, 2);
            AddControl(new Button(bt12));

            ButtonTemplate bt13 = new ButtonTemplate()
            {
                Label            = "Sized",
                AutoSizeOverride = new Size(15, 5),
                VAlignment       = VerticalAlignment.Bottom,
                LabelAlignment   = HorizontalAlignment.Right,
            };

            bt13.AlignTo(LayoutDirection.South, bt12, 2);
            AddControl(new Button(bt13));

            ButtonTemplate bt14 = new ButtonTemplate()
            {
                Label            = "Animated",
                AutoSizeOverride = new Size(12, 5),
                VAlignment       = VerticalAlignment.Center,
                LabelAlignment   = HorizontalAlignment.Center
            };

            bt14.AlignTo(LayoutDirection.South, bt4, 4);
            AddControl(new WaveButton(bt14));

            ButtonTemplate bt15 = new ButtonTemplate()
            {
                Label          = "Normal Draw",
                LabelAlignment = HorizontalAlignment.Center
            };

            bt15.AlignTo(LayoutDirection.South, bt14, 4);
            AddControl(new OwnerButton(bt15));

            ButtonTemplate bt16 = new ButtonTemplate()
            {
                Label = "901 Animated Buttons!",
            };

            bt16.AlignTo(LayoutDirection.South, bt10, 2);
            AddControl(new Button(bt16));

            // Create the matrix of animated buttons.
            // Note there is actually a large amount of overhead here - this is
            // NOT the efficient way to do this.  However, this is meant to
            // "stress test" the library, so this is how we are doing it.
            for (int y = 30; y < 47; y++)
            {
                for (int x = 20; x < 73; x++)
                {
                    ButtonTemplate bt17 = new ButtonTemplate()
                    {
                        Label            = " ",
                        AutoSizeOverride = new Size(1, 1),
                        HasFrameBorder   = false,
                        UpperLeftPos     = new Point(x, y)
                    };

                    AddControl(new SparkleButton(bt17));
                }
            }

            PageInfo.AddText("Here is a sample selection of buttons, in various styles." +
                             "\n\nTry clicking on the Animated and Owner Draw buttons to see custom behavior." +
                             "\n\nNote that the 901 animated button matrix is a stress test - each button is being " +
                             "created individually, each with its own scheduler, message hooks, and memory console. This is an " +
                             "enormous amount of overhead, and here we can see how much it slows down the framework by " +
                             "comparing the text output of this TextBox to the other pages.");

            PageInfo.AddText("\n\nHere are a couple of general things to note about the demo project:");
            PageInfo.AddText("\n* Each page is a seperate Window with its own controls" +
                             "\n* The popup tooltips are intelligently constrained to the window" +
                             "\n* This text is being drawn by a TextBox control from extended library",
                             PageInfo.Pigments[PigmentType.Window].ReplaceForeground(new Color(0x885599))
                             );
        }
コード例 #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);
        }