예제 #1
0
        /// <summary>
        /// As mentioned, MyManager is responsible for initializing all of the buttons and
        /// user interface logic, which we do in the OnSettingUp method.
        /// </summary>
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            /// First define the teleport button template.  Here we are going to use the MinimumWidth
            /// properties for all of these buttons so that they are all the same size, and thus
            /// line up nicely.
            ButtonTemplate telButtonTemplate = new ButtonTemplate()
            {
                Label        = "Teleport",
                UpperLeftPos = new Point(3, 1),
                MinimumWidth = 12
            };

            /// Here we see a more intuitive way of positioning a control (or, more technically,
            /// a control template) relative to another one.  In this case, we are going to
            /// place our redButtonTemplate directly underneath the telButtonTemplate, with 1
            /// extra space in between.

            ButtonTemplate redButtonTemplate = new ButtonTemplate()
            {
                Label        = "Turn Red",
                MinimumWidth = 12
            };

            redButtonTemplate.AlignTo(LayoutDirection.South, telButtonTemplate, 1);

            /// This one will go directly to the right of the red button template.

            ButtonTemplate blueButtonTemplate = new ButtonTemplate()
            {
                Label        = "Turn Blue",
                MinimumWidth = 12
            };

            blueButtonTemplate.AlignTo(LayoutDirection.East, redButtonTemplate, 2);



            /// Create the buttons, add them to the window, and hook into their events.

            Button teleportButton = new Button(telButtonTemplate);
            Button turnRedButton  = new Button(redButtonTemplate);
            Button turnBlueButton = new Button(blueButtonTemplate);

            Button quitButton = new Button(new ButtonTemplate()
            {
                Label        = "QUIT",
                UpperLeftPos = new Point(74, 0)
            });

            ParentWindow.AddControls(quitButton, turnBlueButton, turnRedButton, teleportButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);

            teleportButton.ButtonPushed += new EventHandler(teleportButton_ButtonClicked);

            turnBlueButton.ButtonPushed += new EventHandler(turnBlueButton_ButtonClicked);

            turnRedButton.ButtonPushed += new EventHandler(turnRedButton_ButtonClicked);



            /// Here we hilight the scheduling feature of the framework.  All descendents of Component, which
            /// includes our MyManager class, have access to the AddSchedule method.  This method takes as
            /// a parameter a Schedule instance, which in turn is constructed with 2 arguments:
            /// 1.  A delegate indiciating which method to call at the appropriate time
            /// 2.  A delay value in milliseconds.
            ///
            /// Here, we are telling the scheduler to call our Flicker method every 100 milliseconds.
            AddSchedule(new Schedule(Flicker, 100));
        }
예제 #2
0
파일: Page2.cs 프로젝트: AIBrain/ochregui
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            CheckBoxTemplate cb1 = new CheckBoxTemplate()
            {
                Label = " A Checkbox",
                UpperLeftPos = ViewRect.UpperLeft.Shift(1, 3),
            };
            AddControl(new CheckBox(cb1));

            CheckBoxTemplate cb2 = new CheckBoxTemplate()
            {
                Label = " Checkbox",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = true
            };
            cb2.AlignTo(LayoutDirection.South, cb1, 1);
            AddControl(new CheckBox(cb2));

            CheckBoxTemplate cb3 = new CheckBoxTemplate()
            {
                Label = "Checkbox",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = true,
                LabelAlignment = HorizontalAlignment.Right
            };
            cb3.AlignTo(LayoutDirection.South, cb2, 1);
            AddControl(new CheckBox(cb3));

            CheckBoxTemplate cb4 = new CheckBoxTemplate()
            {
                Label = "Checkbox",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = true,
                LabelAlignment = HorizontalAlignment.Center,
            };
            cb4.AlignTo(LayoutDirection.South, cb3, 1);
            AddControl(new CheckBox(cb4));

            CheckBoxTemplate cb5 = new CheckBoxTemplate()
            {
                Label = "Checkbox",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = false,
                LabelAlignment = HorizontalAlignment.Left,
                VerticalAlign = VerticalAlignment.Center,
                AutoSizeOverride = new Size(14,3),
                HasFrameBorder = false,
            };
            cb5.AlignTo(LayoutDirection.East, cb2, 1);
            AddControl(new CheckBox(cb5));

            CheckBoxTemplate cb6 = new CheckBoxTemplate()
            {
                Label = "Checkbox ",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = false,
                LabelAlignment = HorizontalAlignment.Right,
                VerticalAlign = VerticalAlignment.Center,
                AutoSizeOverride = new Size(14, 3),
                HasFrameBorder = false,
            };
            cb6.AlignTo(LayoutDirection.South, cb5, 1);
            AddControl(new CheckBox(cb6));

            CheckBoxTemplate cb7 = new CheckBoxTemplate()
            {
                Label = Color.CYAN.DoForegroundCode() + "C" +
                    Color.RED.DoForegroundCode() + "o"+
                    Color.BLUE.DoForegroundCode() + "l"+
                    Color.BRASS.DoForegroundCode() + "o"+
                    Color.DARK_LIME.DoForegroundCode() + "r"+
                    Color.LIGHT_MAGENTA.DoForegroundCode() + "s" +
                    Color.StopColorCode + "!! ",
                CheckOnLeft = false,
                LabelAlignment = HorizontalAlignment.Center,
                HasFrameBorder = false,
            };
            cb7.AlignTo(LayoutDirection.South, cb6, 1);
            AddControl(new CheckBox(cb7));

            CheckBoxTemplate cb8 = new CheckBoxTemplate()
            {
                Label = "Custom",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft = false,
                LabelAlignment = HorizontalAlignment.Center,
            };
            cb8.AlignTo(LayoutDirection.North, cb5, 1);
            AddControl(new FancyCheck(cb8));

            ListBoxTemplate lb1 = new ListBoxTemplate()
            {
                Title = "A List Box",
                Items = new System.Collections.Generic.List<ListItemData>()
                {
                    new ListItemData("Item 1","Item 1 Tooltip"),
                    new ListItemData("Item 2","Item 2 Tooltip"),
                    new ListItemData("Item 3","Item 3 Tooltip"),
                    new ListItemData("Item 4","Item 4 Tooltip")
                },
            };
            lb1.AlignTo(LayoutDirection.South, cb4, 2);
            AddControl(new ListBox(lb1));

            ListBoxTemplate lb2 = new ListBoxTemplate()
            {
                Title = "A List Box",
                TitleAlignment = HorizontalAlignment.Right,
                LabelAlignment = HorizontalAlignment.Center,
                MinimumListBoxWidth = 20,
                Items = new System.Collections.Generic.List<ListItemData>()
                {
                    new ListItemData("Item 1","Item 1 Tooltip"),
                    new ListItemData("Item 2","Item 2 Tooltip"),
                    new ListItemData("Item 3","Item 3 Tooltip"),
                    new ListItemData("Item 4","Item 4 Tooltip")
                }
            };
            lb2.AlignTo(LayoutDirection.East, lb1, 2);
            AddControl(new ListBox(lb2));

            TextEntryTemplate t1 = new TextEntryTemplate()
            {
                Label = "Text Entry (Hit Enter to keep): ",
                MaximumCharacters = 6
            };
            t1.AlignTo(LayoutDirection.East, cb8, 2);
            AddControl(new TextEntry(t1));

            TextEntryTemplate t2 = new TextEntryTemplate()
            {
                Label = "Symbols Only: ",
                Validation = TextEntryValidations.Symbols,
                MaximumCharacters = 25
            };
            t2.AlignTo(LayoutDirection.South, t1, 2);
            AddControl(new TextEntry(t2));

            TextEntryTemplate t3 = new TextEntryTemplate()
            {
                Label = "Numbers & Symbols: ",
                Validation = TextEntryValidations.Numbers | TextEntryValidations.Symbols,
                MaximumCharacters = 20
            };
            t3.AlignTo(LayoutDirection.South, t2, 2);
            AddControl(new TextEntry(t3));

            TextEntryTemplate t4 = new TextEntryTemplate()
            {
                Label = "Don't need to hit Enter: ",
                MaximumCharacters = 4,
                CommitOnLostFocus = true,
            };
            t4.AlignTo(LayoutDirection.South, t3, 2);
            t4.UpperLeftPos = t4.UpperLeftPos.Shift(4, 0);
            AddControl(new TextEntry(t4));

            TextEntryTemplate t5 = new TextEntryTemplate()
            {
                Label = "Replace Text: ",
                MaximumCharacters = 11,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                StartingField = "Replace me",
                HasFrameBorder = false
            };
            t5.AlignTo(LayoutDirection.South, t4, 2);
            AddControl(new TextEntry(t5));

            ButtonTemplate mb1 = new ButtonTemplate()
            {
                Label = "Right Click for Menu"
            };
            mb1.AlignTo(LayoutDirection.South, lb2,3);
            AddControl(new MenuButton(mb1));

            RadioGroupTemplate rg1 = new RadioGroupTemplate()
            {
                Items = new System.Collections.Generic.List<RadioItemData>()
                {
                    new RadioItemData("Radio One","Tooltip for radio 1"),
                    new RadioItemData("Radio Two","Tooltip for radio 2"),
                    new RadioItemData("Radio Three","Tooltip for radio 3")
                },
            };
            rg1.AlignTo(LayoutDirection.South, t5, 2);
            AddControl(new RadioGroup(rg1));

            RadioGroupTemplate rg2 = new RadioGroupTemplate()
            {
                Items = new System.Collections.Generic.List<RadioItemData>()
                {
                    new RadioItemData("Radio One","Tooltip for radio 1"),
                    new RadioItemData("Radio Two","Tooltip for radio 2"),
                    new RadioItemData("Radio Three","Tooltip for radio 3")
                },
                HasFrameBorder = false,
                RadioOnLeft = false
            };
            rg2.AlignTo(LayoutDirection.South, rg1, 1);
            AddControl(new RadioGroup(rg2));

            PageInfo.AddText("This page shows a selection of Checkbox, TextEntry, ListBox, and RadioGroup controls." +
                "\n\nCheckbox controls are similar to buttons, except that there state (IsChecked) is persistant, and" +
                " this state is, by default, shown by a check box graphic." +
                "\n\nTextEntry controls allow user input.  Various behaviors of validation and committing the input are available." +
                "\n\nListBox controls are basically a list of clickable buttons with persistant state - one item is always the currently selected." +
                "\n\nMenu controls are similar to ListBox, except they automatically close if an item is selected or the mouse pointer leaves the area." +
                "\n\nRadioGroups are the same as ListBoxes, except the currently selected item is displayed differently.");
        }
예제 #3
0
파일: Page2.cs 프로젝트: vanattab/ochregui
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            CheckBoxTemplate cb1 = new CheckBoxTemplate()
            {
                Label        = " A Checkbox",
                UpperLeftPos = ViewRect.UpperLeft.Shift(1, 3),
            };

            AddControl(new CheckBox(cb1));

            CheckBoxTemplate cb2 = new CheckBoxTemplate()
            {
                Label        = " Checkbox",
                MinimumWidth = cb1.CalculateSize().Width,
                CheckOnLeft  = true
            };

            cb2.AlignTo(LayoutDirection.South, cb1, 1);
            AddControl(new CheckBox(cb2));

            CheckBoxTemplate cb3 = new CheckBoxTemplate()
            {
                Label          = "Checkbox",
                MinimumWidth   = cb1.CalculateSize().Width,
                CheckOnLeft    = true,
                LabelAlignment = HorizontalAlignment.Right
            };

            cb3.AlignTo(LayoutDirection.South, cb2, 1);
            AddControl(new CheckBox(cb3));

            CheckBoxTemplate cb4 = new CheckBoxTemplate()
            {
                Label          = "Checkbox",
                MinimumWidth   = cb1.CalculateSize().Width,
                CheckOnLeft    = true,
                LabelAlignment = HorizontalAlignment.Center,
            };

            cb4.AlignTo(LayoutDirection.South, cb3, 1);
            AddControl(new CheckBox(cb4));

            CheckBoxTemplate cb5 = new CheckBoxTemplate()
            {
                Label            = "Checkbox",
                MinimumWidth     = cb1.CalculateSize().Width,
                CheckOnLeft      = false,
                LabelAlignment   = HorizontalAlignment.Left,
                VerticalAlign    = VerticalAlignment.Center,
                AutoSizeOverride = new Size(14, 3),
                HasFrameBorder   = false,
            };

            cb5.AlignTo(LayoutDirection.East, cb2, 1);
            AddControl(new CheckBox(cb5));

            CheckBoxTemplate cb6 = new CheckBoxTemplate()
            {
                Label            = "Checkbox ",
                MinimumWidth     = cb1.CalculateSize().Width,
                CheckOnLeft      = false,
                LabelAlignment   = HorizontalAlignment.Right,
                VerticalAlign    = VerticalAlignment.Center,
                AutoSizeOverride = new Size(14, 3),
                HasFrameBorder   = false,
            };

            cb6.AlignTo(LayoutDirection.South, cb5, 1);
            AddControl(new CheckBox(cb6));

            CheckBoxTemplate cb7 = new CheckBoxTemplate()
            {
                Label = Color.CYAN.DoForegroundCode() + "C" +
                        Color.RED.DoForegroundCode() + "o" +
                        Color.BLUE.DoForegroundCode() + "l" +
                        Color.BRASS.DoForegroundCode() + "o" +
                        Color.DARK_LIME.DoForegroundCode() + "r" +
                        Color.LIGHT_MAGENTA.DoForegroundCode() + "s" +
                        Color.StopColorCode + "!! ",
                CheckOnLeft    = false,
                LabelAlignment = HorizontalAlignment.Center,
                HasFrameBorder = false,
            };

            cb7.AlignTo(LayoutDirection.South, cb6, 1);
            AddControl(new CheckBox(cb7));

            CheckBoxTemplate cb8 = new CheckBoxTemplate()
            {
                Label          = "Custom",
                MinimumWidth   = cb1.CalculateSize().Width,
                CheckOnLeft    = false,
                LabelAlignment = HorizontalAlignment.Center,
            };

            cb8.AlignTo(LayoutDirection.North, cb5, 1);
            AddControl(new FancyCheck(cb8));


            ListBoxTemplate lb1 = new ListBoxTemplate()
            {
                Title = "A List Box",
                Items = new System.Collections.Generic.List <ListItemData>()
                {
                    new ListItemData("Item 1", "Item 1 Tooltip"),
                    new ListItemData("Item 2", "Item 2 Tooltip"),
                    new ListItemData("Item 3", "Item 3 Tooltip"),
                    new ListItemData("Item 4", "Item 4 Tooltip")
                },
            };

            lb1.AlignTo(LayoutDirection.South, cb4, 2);
            AddControl(new ListBox(lb1));

            ListBoxTemplate lb2 = new ListBoxTemplate()
            {
                Title               = "A List Box",
                TitleAlignment      = HorizontalAlignment.Right,
                LabelAlignment      = HorizontalAlignment.Center,
                MinimumListBoxWidth = 20,
                Items               = new System.Collections.Generic.List <ListItemData>()
                {
                    new ListItemData("Item 1", "Item 1 Tooltip"),
                    new ListItemData("Item 2", "Item 2 Tooltip"),
                    new ListItemData("Item 3", "Item 3 Tooltip"),
                    new ListItemData("Item 4", "Item 4 Tooltip")
                }
            };

            lb2.AlignTo(LayoutDirection.East, lb1, 2);
            AddControl(new ListBox(lb2));


            TextEntryTemplate t1 = new TextEntryTemplate()
            {
                Label             = "Text Entry (Hit Enter to keep): ",
                MaximumCharacters = 6
            };

            t1.AlignTo(LayoutDirection.East, cb8, 2);
            AddControl(new TextEntry(t1));

            TextEntryTemplate t2 = new TextEntryTemplate()
            {
                Label             = "Symbols Only: ",
                Validation        = TextEntryValidations.Symbols,
                MaximumCharacters = 25
            };

            t2.AlignTo(LayoutDirection.South, t1, 2);
            AddControl(new TextEntry(t2));

            TextEntryTemplate t3 = new TextEntryTemplate()
            {
                Label             = "Numbers & Symbols: ",
                Validation        = TextEntryValidations.Numbers | TextEntryValidations.Symbols,
                MaximumCharacters = 20
            };

            t3.AlignTo(LayoutDirection.South, t2, 2);
            AddControl(new TextEntry(t3));

            TextEntryTemplate t4 = new TextEntryTemplate()
            {
                Label             = "Don't need to hit Enter: ",
                MaximumCharacters = 4,
                CommitOnLostFocus = true,
            };

            t4.AlignTo(LayoutDirection.South, t3, 2);
            t4.UpperLeftPos = t4.UpperLeftPos.Shift(4, 0);
            AddControl(new TextEntry(t4));

            TextEntryTemplate t5 = new TextEntryTemplate()
            {
                Label             = "Replace Text: ",
                MaximumCharacters = 11,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                StartingField     = "Replace me",
                HasFrameBorder    = false
            };

            t5.AlignTo(LayoutDirection.South, t4, 2);
            AddControl(new TextEntry(t5));


            ButtonTemplate mb1 = new ButtonTemplate()
            {
                Label = "Right Click for Menu"
            };

            mb1.AlignTo(LayoutDirection.South, lb2, 3);
            AddControl(new MenuButton(mb1));


            RadioGroupTemplate rg1 = new RadioGroupTemplate()
            {
                Items = new System.Collections.Generic.List <RadioItemData>()
                {
                    new RadioItemData("Radio One", "Tooltip for radio 1"),
                    new RadioItemData("Radio Two", "Tooltip for radio 2"),
                    new RadioItemData("Radio Three", "Tooltip for radio 3")
                },
            };

            rg1.AlignTo(LayoutDirection.South, t5, 2);
            AddControl(new RadioGroup(rg1));

            RadioGroupTemplate rg2 = new RadioGroupTemplate()
            {
                Items = new System.Collections.Generic.List <RadioItemData>()
                {
                    new RadioItemData("Radio One", "Tooltip for radio 1"),
                    new RadioItemData("Radio Two", "Tooltip for radio 2"),
                    new RadioItemData("Radio Three", "Tooltip for radio 3")
                },
                HasFrameBorder = false,
                RadioOnLeft    = false
            };

            rg2.AlignTo(LayoutDirection.South, rg1, 1);
            AddControl(new RadioGroup(rg2));


            PageInfo.AddText("This page shows a selection of Checkbox, TextEntry, ListBox, and RadioGroup controls." +
                             "\n\nCheckbox controls are similar to buttons, except that there state (IsChecked) is persistant, and" +
                             " this state is, by default, shown by a check box graphic." +
                             "\n\nTextEntry controls allow user input.  Various behaviors of validation and committing the input are available." +
                             "\n\nListBox controls are basically a list of clickable buttons with persistant state - one item is always the currently selected." +
                             "\n\nMenu controls are similar to ListBox, except they automatically close if an item is selected or the mouse pointer leaves the area." +
                             "\n\nRadioGroups are the same as ListBoxes, except the currently selected item is displayed differently.");
        }
예제 #4
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))
                );
        }
예제 #5
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))
                             );
        }
예제 #6
0
        /// <summary>
        /// As mentioned, MyManager is responsible for initializing all of the buttons and 
        /// user interface logic, which we do in the OnSettingUp method.
        /// </summary>
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            /// First define the teleport button template.  Here we are going to use the MinimumWidth
            /// properties for all of these buttons so that they are all the same size, and thus
            /// line up nicely.
            ButtonTemplate telButtonTemplate = new ButtonTemplate()
            {
                Label = "Teleport",
                UpperLeftPos = new Point(3, 1),
                MinimumWidth = 12
            };

            /// Here we see a more intuitive way of positioning a control (or, more technically,
            /// a control template) relative to another one.  In this case, we are going to
            /// place our redButtonTemplate directly underneath the telButtonTemplate, with 1
            /// extra space in between.

            ButtonTemplate redButtonTemplate = new ButtonTemplate()
            {
                Label = "Turn Red",
                MinimumWidth = 12
            };
            redButtonTemplate.AlignTo(LayoutDirection.South, telButtonTemplate, 1);

            /// This one will go directly to the right of the red button template.

            ButtonTemplate blueButtonTemplate = new ButtonTemplate()
            {
                Label = "Turn Blue",
                MinimumWidth = 12
            };
            blueButtonTemplate.AlignTo(LayoutDirection.East, redButtonTemplate, 2);

            /// Create the buttons, add them to the window, and hook into their events.

            Button teleportButton = new Button(telButtonTemplate);
            Button turnRedButton = new Button(redButtonTemplate);
            Button turnBlueButton = new Button(blueButtonTemplate);

            Button quitButton = new Button(new ButtonTemplate()
            {
                Label = "QUIT",
                UpperLeftPos = new Point(74,0)
            });

            ParentWindow.AddControls(quitButton, turnBlueButton, turnRedButton, teleportButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);

            teleportButton.ButtonPushed += new EventHandler(teleportButton_ButtonClicked);

            turnBlueButton.ButtonPushed += new EventHandler(turnBlueButton_ButtonClicked);

            turnRedButton.ButtonPushed += new EventHandler(turnRedButton_ButtonClicked);

            /// Here we hilight the scheduling feature of the framework.  All descendents of Component, which
            /// includes our MyManager class, have access to the AddSchedule method.  This method takes as
            /// a parameter a Schedule instance, which in turn is constructed with 2 arguments:
            /// 1.  A delegate indiciating which method to call at the appropriate time
            /// 2.  A delay value in milliseconds.
            ///
            /// Here, we are telling the scheduler to call our Flicker method every 100 milliseconds.
            AddSchedule(new Schedule(Flicker, 100));
        }