Example #1
0
        public Menu(Base parent)
            : base(parent)
        {
            /* Context Menu Strip */
            {
                Control.Label lblClickMe = new Control.Label(this);
                lblClickMe.Text = "Right Click Me";
                lblClickMe.SetPosition(10, 30);
                lblClickMe.RightClicked += delegate(Control.Base sender, ClickedEventArgs args)
                {
                    Control.Menu menu = new Control.Menu(this);
                    Point Local = this.CanvasPosToLocal(new Point(args.X, args.Y));
                    menu.SetPosition(Local.X, Local.Y);
                    menu.AddItem("Test");
                    menu.AddItem("Clickable").Clicked +=
                        delegate(Control.Base sender2, ClickedEventArgs args2)
                        {
                            UnitPrint("Clickable item was clicked");
                        };
                    menu.Show();
                };
            }

            /* Menu Strip */
            {
                Control.MenuStrip menu = new Control.MenuStrip(this);

                /* File */
                {
                    Control.MenuItem root = menu.AddItem("File");
                    root.Menu.AddItem("Load", "test16.png", "Ctrl+L").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction(MenuItemSelect);
                }

                /* Russian */
                {
                    Control.MenuItem pRoot = menu.AddItem("\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E");
                    pRoot.Menu.AddItem("\u5355\u5143\u6D4B\u8BD5").SetAction(MenuItemSelect);
                    pRoot.Menu.AddItem("\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", "test16.png")
                        .SetAction(MenuItemSelect);
                }

                /* Embdedded Menu Items */
                {
                    Control.MenuItem pRoot = menu.AddItem("Submenu");

                    Control.MenuItem pCheckable = pRoot.Menu.AddItem("Checkable");
                    pCheckable.IsCheckable = true;
                    pCheckable.IsCheckable = true;

                    {
                        Control.MenuItem pRootB = pRoot.Menu.AddItem("Two");
                        pRootB.Menu.AddItem("Two.One");
                        pRootB.Menu.AddItem("Two.Two");
                        pRootB.Menu.AddItem("Two.Three");
                        pRootB.Menu.AddItem("Two.Four");
                        pRootB.Menu.AddItem("Two.Five");
                        pRootB.Menu.AddItem("Two.Six");
                        pRootB.Menu.AddItem("Two.Seven");
                        pRootB.Menu.AddItem("Two.Eight");
                        pRootB.Menu.AddItem("Two.Nine", "test16.png");
                    }

                    pRoot.Menu.AddItem("Three");
                    pRoot.Menu.AddItem("Four");
                    pRoot.Menu.AddItem("Five");

                    {
                        Control.MenuItem pRootB = pRoot.Menu.AddItem("Six");
                        pRootB.Menu.AddItem("Six.One");
                        pRootB.Menu.AddItem("Six.Two");
                        pRootB.Menu.AddItem("Six.Three");
                        pRootB.Menu.AddItem("Six.Four");
                        pRootB.Menu.AddItem("Six.Five", "test16.png");

                        {
                            Control.MenuItem pRootC = pRootB.Menu.AddItem("Six.Six");
                            pRootC.Menu.AddItem("Sheep");
                            pRootC.Menu.AddItem("Goose");
                            {
                                Control.MenuItem pRootD = pRootC.Menu.AddItem("Camel");
                                pRootD.Menu.AddItem("Eyes");
                                pRootD.Menu.AddItem("Nose");
                                {
                                    Control.MenuItem pRootE = pRootD.Menu.AddItem("Hair");
                                    pRootE.Menu.AddItem("Blonde");
                                    pRootE.Menu.AddItem("Black");
                                    {
                                        Control.MenuItem pRootF = pRootE.Menu.AddItem("Red");
                                        pRootF.Menu.AddItem("Light");
                                        pRootF.Menu.AddItem("Medium");
                                        pRootF.Menu.AddItem("Dark");
                                    }
                                    pRootE.Menu.AddItem("Brown");
                                }
                                pRootD.Menu.AddItem("Ears");
                            }
                            pRootC.Menu.AddItem("Duck");
                        }

                        pRootB.Menu.AddItem("Six.Seven");
                        pRootB.Menu.AddItem("Six.Eight");
                        pRootB.Menu.AddItem("Six.Nine");
                    }

                    pRoot.Menu.AddItem("Seven");
                }
            }
        }
Example #2
0
        public Label(Base parent) : base(parent)
        {
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Standard label (not autosized)";
				label.AutoSizeToContents = false;
                label.SetBounds(10, 10, 100, 10);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173";
                label.SetPosition(10, 30);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054";
                label.SetPosition(10, 50);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C";
                label.SetPosition(10, 70);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964";
                label.SetPosition(10, 90);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A";
                label.SetPosition(10, 110);
            }
            {
                Control.Label label = new Control.Label(this);
                label.MouseInputEnabled = true; // needed for tooltip
                label.Text = "Wow, Coloured Text (and tooltip)";
                label.TextColor = Color.Blue;
                label.SetToolTipText("I'm a tooltip");
                font3 = new Font(Skin.Renderer, "Motorwerk", 20);
                ((Control.Label) label.ToolTip).Font = font3;
                label.SetPosition(10, 130);
            }
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Coloured Text With Alpha";
                label.TextColor = Color.FromArgb(100, 0, 0, 255);
                label.SetPosition(10, 150);
            }
            {
                // Note that when using a custom font, this font object has to stick around
                // for the lifetime of the label. Rethink, or is that ideal?
                font1 = new Font(Skin.Renderer);
                font1.FaceName = "Comic Sans MS";
                font1.Size = 25;

                Control.Label label = new Control.Label(this);
                label.Text = "Custom Font (Comic Sans 25)";
                label.SetPosition(10, 170);
                label.Font = font1;
            }
            {
                font2 = new Font(Skin.Renderer, "French Script MT", 35);

                Control.Label label = new Control.Label(this);
                label.Font = font2;
                label.SetPosition(10, 210);
                label.Text = "Custom Font (French Script MT 35)";
            }

            // alignment test
            {
                Control.Label txt = new Control.Label(this);
                txt.SetPosition(10, 280);
                txt.Text = "Alignment test";

                Control.Label outer = new Control.Label(this);
                outer.SetBounds(10, 300, 190, 190);
                
                Control.Label l11 = new Control.Label(outer);
                l11.SetBounds(10, 10, 50, 50);
                l11.Text = "TL";
                l11.Alignment = Pos.Top | Pos.Left;

                Control.Label l12 = new Control.Label(outer);
                l12.SetBounds(70, 10, 50, 50);
                l12.Text = "T";
                l12.Alignment = Pos.Top|Pos.CenterH;

                Control.Label l13 = new Control.Label(outer);
                l13.SetBounds(130, 10, 50, 50);
                l13.Text = "TR";
                l13.Alignment = Pos.Top | Pos.Right;

                Control.Label l21 = new Control.Label(outer);
                l21.SetBounds(10, 70, 50, 50);
                l21.Text = "L";
                l21.Alignment = Pos.Left|Pos.CenterV;

                Control.Label l22 = new Control.Label(outer);
                l22.SetBounds(70, 70, 50, 50);
                l22.Text = "C";
                l22.Alignment = Pos.CenterH|Pos.CenterV;

                Control.Label l23 = new Control.Label(outer);
                l23.SetBounds(130, 70, 50, 50);
                l23.Text = "R";
                l23.Alignment = Pos.Right|Pos.CenterV;

                Control.Label l31 = new Control.Label(outer);
                l31.SetBounds(10, 130, 50, 50);
                l31.Text = "BL";
                l31.Alignment = Pos.Bottom | Pos.Left;

                Control.Label l32 = new Control.Label(outer);
                l32.SetBounds(70, 130, 50, 50);
                l32.Text = "B";
                l32.Alignment = Pos.Bottom | Pos.CenterH;

                Control.Label l33 = new Control.Label(outer);
                l33.SetBounds(130, 130, 50, 50);
                l33.Text = "BR";
                l33.Alignment = Pos.Bottom | Pos.Right;

                outer.DrawDebugOutlines = true;
            }
        }
Example #3
0
        public Label(Base parent) : base(parent)
        {
            {
                Control.Label label = new Control.Label(this);
                label.Text = "Standard label (not autosized)";
                label.SetBounds(10, 10, 100, 10);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173";
                label.SetPosition(10, 30);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054";
                label.SetPosition(10, 50);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C";
                label.SetPosition(10, 70);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964";
                label.SetPosition(10, 90);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A";
                label.SetPosition(10, 110);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.MouseInputEnabled  = true; // needed for tooltip
                label.Text      = "Wow, Coloured Text (and tooltip)";
                label.TextColor = Color.Blue;
                label.SetToolTipText("I'm a tooltip");
                font3 = new Font(Skin.Renderer, "Motorwerk", 20);
                ((Control.Label)label.ToolTip).Font = font3;
                label.SetPosition(10, 130);
            }
            {
                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text      = "Coloured Text With Alpha";
                label.TextColor = Color.FromArgb(100, 0, 0, 255);
                label.SetPosition(10, 150);
            }
            {
                // Note that when using a custom font, this font object has to stick around
                // for the lifetime of the label. Rethink, or is that ideal?
                font1          = new Font(Skin.Renderer);
                font1.FaceName = "Comic Sans MS";
                font1.Size     = 25;

                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Text = "Custom Font (Comic Sans 25)";
                label.SetPosition(10, 170);
                label.Font = font1;
            }
            {
                font2 = new Font(Skin.Renderer, "French Script MT", 35);

                Control.Label label = new Control.Label(this);
                label.AutoSizeToContents = true;
                label.Font = font2;
                label.SetPosition(10, 210);
                label.Text = "Custom Font (French Script MT 35)";
            }

            // alignment test
            {
                Control.Label txt = new Control.Label(this);
                txt.SetPosition(10, 280);
                txt.Text = "Alignment test";
                txt.AutoSizeToContents = true;

                Control.Label outer = new Control.Label(this);
                outer.SetBounds(10, 300, 190, 190);

                Control.Label l11 = new Control.Label(outer);
                l11.SetBounds(10, 10, 50, 50);
                l11.Text      = "TL";
                l11.Alignment = Pos.Top | Pos.Left;

                Control.Label l12 = new Control.Label(outer);
                l12.SetBounds(70, 10, 50, 50);
                l12.Text      = "T";
                l12.Alignment = Pos.Top | Pos.CenterH;

                Control.Label l13 = new Control.Label(outer);
                l13.SetBounds(130, 10, 50, 50);
                l13.Text      = "TR";
                l13.Alignment = Pos.Top | Pos.Right;

                Control.Label l21 = new Control.Label(outer);
                l21.SetBounds(10, 70, 50, 50);
                l21.Text      = "L";
                l21.Alignment = Pos.Left | Pos.CenterV;

                Control.Label l22 = new Control.Label(outer);
                l22.SetBounds(70, 70, 50, 50);
                l22.Text      = "C";
                l22.Alignment = Pos.CenterH | Pos.CenterV;

                Control.Label l23 = new Control.Label(outer);
                l23.SetBounds(130, 70, 50, 50);
                l23.Text      = "R";
                l23.Alignment = Pos.Right | Pos.CenterV;

                Control.Label l31 = new Control.Label(outer);
                l31.SetBounds(10, 130, 50, 50);
                l31.Text      = "BL";
                l31.Alignment = Pos.Bottom | Pos.Left;

                Control.Label l32 = new Control.Label(outer);
                l32.SetBounds(70, 130, 50, 50);
                l32.Text      = "B";
                l32.Alignment = Pos.Bottom | Pos.CenterH;

                Control.Label l33 = new Control.Label(outer);
                l33.SetBounds(130, 130, 50, 50);
                l33.Text      = "BR";
                l33.Alignment = Pos.Bottom | Pos.Right;

                outer.DrawDebugOutlines = true;
            }
        }
Example #4
0
        public Menu(ControlBase parent) : base(parent)
        {
            /* Context Menu Strip */
            {
                Control.Label lblClickMe = new Control.Label(this);
                lblClickMe.Text = "Right Click Me";
                lblClickMe.SetPosition(10, 30);
                lblClickMe.RightClicked += delegate(Control.ControlBase sender, ClickedEventArgs args) {
                    Control.Menu menu  = new Control.Menu(this);
                    Point        Local = this.CanvasPosToLocal(new Point(args.X, args.Y));
                    menu.SetPosition(Local.X, Local.Y);
                    menu.AddItem("Test");
                    menu.AddItem("Clickable").Clicked += delegate(Control.ControlBase sender2, ClickedEventArgs args2) {
                        UnitPrint("Clickable item was clicked");
                    };
                    menu.Show();
                };
            }

            /* Menu Strip */
            {
                Control.MenuStrip menu = new Control.MenuStrip(this);

                /* File */
                {
                    Control.MenuItem root = menu.AddItem("File");
                    root.Menu.AddItem("Load", "test16.png", "Ctrl+L").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Save", String.Empty, "Ctrl+S").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Save As..", String.Empty, "Ctrl+A").SetAction(MenuItemSelect);
                    root.Menu.AddItem("Quit", String.Empty, "Ctrl+Q").SetAction(MenuItemSelect);
                }

                /* Russian */
                {
                    Control.MenuItem pRoot = menu.AddItem("\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E");
                    pRoot.Menu.AddItem("\u5355\u5143\u6D4B\u8BD5").SetAction(MenuItemSelect);
                    pRoot.Menu.AddItem("\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", "test16.png").SetAction(MenuItemSelect);
                }

                /* Embdedded Menu Items */
                {
                    Control.MenuItem pRoot = menu.AddItem("Submenu");

                    Control.MenuItem pCheckable = pRoot.Menu.AddItem("Checkable");
                    pCheckable.IsCheckable = true;
                    pCheckable.IsCheckable = true;

                    {
                        Control.MenuItem pRootB = pRoot.Menu.AddItem("Two");
                        pRootB.Menu.AddItem("Two.One");
                        pRootB.Menu.AddItem("Two.Two");
                        pRootB.Menu.AddItem("Two.Three");
                        pRootB.Menu.AddItem("Two.Four");
                        pRootB.Menu.AddItem("Two.Five");
                        pRootB.Menu.AddItem("Two.Six");
                        pRootB.Menu.AddItem("Two.Seven");
                        pRootB.Menu.AddItem("Two.Eight");
                        pRootB.Menu.AddItem("Two.Nine", "test16.png");
                    }

                    pRoot.Menu.AddItem("Three");
                    pRoot.Menu.AddItem("Four");
                    pRoot.Menu.AddItem("Five");

                    {
                        Control.MenuItem pRootB = pRoot.Menu.AddItem("Six");
                        pRootB.Menu.AddItem("Six.One");
                        pRootB.Menu.AddItem("Six.Two");
                        pRootB.Menu.AddItem("Six.Three");
                        pRootB.Menu.AddItem("Six.Four");
                        pRootB.Menu.AddItem("Six.Five", "test16.png");

                        {
                            Control.MenuItem pRootC = pRootB.Menu.AddItem("Six.Six");
                            pRootC.Menu.AddItem("Sheep");
                            pRootC.Menu.AddItem("Goose");
                            {
                                Control.MenuItem pRootD = pRootC.Menu.AddItem("Camel");
                                pRootD.Menu.AddItem("Eyes");
                                pRootD.Menu.AddItem("Nose");
                                {
                                    Control.MenuItem pRootE = pRootD.Menu.AddItem("Hair");
                                    pRootE.Menu.AddItem("Blonde");
                                    pRootE.Menu.AddItem("Black");
                                    {
                                        Control.MenuItem pRootF = pRootE.Menu.AddItem("Red");
                                        pRootF.Menu.AddItem("Light");
                                        pRootF.Menu.AddItem("Medium");
                                        pRootF.Menu.AddItem("Dark");
                                    }
                                    pRootE.Menu.AddItem("Brown");
                                }
                                pRootD.Menu.AddItem("Ears");
                            }
                            pRootC.Menu.AddItem("Duck");
                        }

                        pRootB.Menu.AddItem("Six.Seven");
                        pRootB.Menu.AddItem("Six.Eight");
                        pRootB.Menu.AddItem("Six.Nine");
                    }

                    pRoot.Menu.AddItem("Seven");
                }
            }
        }
Example #5
0
        public ListBox(ControlBase parent)
            : base(parent)
        {
            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetPosition(10, 10);

                ctrl.AddRow("First");
                ctrl.AddRow("Blue");
                ctrl.AddRow("Yellow");
                ctrl.AddRow("Orange");
                ctrl.AddRow("Brown");
                ctrl.AddRow("Black");
                ctrl.AddRow("Green");
                ctrl.AddRow("Dog");
                ctrl.AddRow("Cat Blue");
                ctrl.AddRow("Shoes");
                ctrl.AddRow("Shirts");
                ctrl.AddRow("Chair");
                ctrl.AddRow("I'm autosized");
                ctrl.AddRow("Last");

                ctrl.AllowMultiSelect = true;
                ctrl.SelectRowsByRegex("Bl.e|Dog");

                ctrl.RowSelected   += RowSelected;
                ctrl.RowUnselected += RowUnSelected;

                ctrl.SizeToContents();
            }

            {
                Table ctrl = new Table(this);
                ctrl.SetPosition(120, 10);

                ctrl.AddRow("First");
                ctrl.AddRow("Blue");
                ctrl.AddRow("Yellow");
                ctrl.AddRow("Orange");
                ctrl.AddRow("Brown");
                ctrl.AddRow("Black");
                ctrl.AddRow("Green");
                ctrl.AddRow("Dog");
                ctrl.AddRow("Cat Blue");
                ctrl.AddRow("Shoes");
                ctrl.AddRow("Shirts");
                ctrl.AddRow("Chair");
                ctrl.AddRow("I'm autosized");
                ctrl.AddRow("Last");

                ctrl.SizeToContents(0);
            }

            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetBounds(220, 10, 200, 200);
                ctrl.ColumnCount = 3;
                //ctrl.AllowMultiSelect = true;
                ctrl.RowSelected   += RowSelected;
                ctrl.RowUnselected += RowUnSelected;

                {
                    TableRow row = ctrl.AddRow("Baked Beans");
                    row.SetCellText(1, "Heinz");
                    row.SetCellText(2, "£3.50");
                }

                {
                    TableRow row = ctrl.AddRow("Bananas");
                    row.SetCellText(1, "Trees");
                    row.SetCellText(2, "£1.27");
                }

                {
                    TableRow row = ctrl.AddRow("Chicken");
                    row.SetCellText(1, "\u5355\u5143\u6D4B\u8BD5");
                    row.SetCellText(2, "£8.95");
                }
            }

            {
                // fixed-size table
                Control.Layout.Table table = new Table(this);
                table.SetColumnCount(3);
                table.SetBounds(450, 10, 320, 100);
                table.SetColumnWidth(0, 100);
                table.SetColumnWidth(1, 100);
                table.SetColumnWidth(2, 100);
                var row1 = table.AddRow();
                row1.SetCellText(0, "Row 1");
                row1.SetCellText(1, "R1 cell 1");
                row1.SetCellText(2, "Row 1 cell 2");

                table.AddRow().Text = "Row 2, slightly bigger";
                table[1].SetCellText(1, "Center cell");

                table.AddRow().Text = "Row 3, medium";
                table[2].SetCellText(2, "Last cell");
            }

            {
                //Control.Label outer = new Control.Label(this);
                //outer.SetBounds(340, 140, 300, 200);

                // autosized table
                Control.Layout.Table table = new Table(this);
                table.SetColumnCount(3);
                table.SetPosition(450, 150);

                var row1 = table.AddRow();
                row1.SetCellText(0, "Row 1");
                row1.SetCellText(1, "R1 cell 1");
                row1.SetCellText(2, "Row 1 cell 2");

                table.AddRow().Text = "Row 2, slightly bigger";
                table[1].SetCellText(1, "Center cell");

                table.AddRow().Text = "Row 3, medium";
                table[2].SetCellText(2, "Last cell");

                table.SizeToContents(0);
            }

            /* Selecting Rows in Code */
            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetPosition(10, 320);

                ListBoxRow Row = ctrl.AddRow("Row");
                ctrl.AddRow("Text");
                ctrl.AddRow("InternalName", "Name");
                ctrl.AddRow("UserData", "Internal", 12);

                ctrl.SizeToContents();

                Control.CheckBox Multiline = new Control.CheckBox(this);
                Multiline.SetPosition(10, 405);
                Multiline.CheckChanged += delegate(ControlBase sender, EventArgs args)
                {
                    ctrl.AllowMultiSelect = Multiline.IsChecked;
                };

                Control.Label lblml = new Control.Label(this);
                lblml.Text = "Enable MultiSelect";
                lblml.SetPosition(30, 405);


                //Select by Menu Item
                {
                    Control.Button TriangleButton = new Control.Button(this);
                    TriangleButton.SetPosition(100, 320);
                    TriangleButton.Text     = "Row";
                    TriangleButton.Width    = 100;
                    TriangleButton.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectedRow = Row;
                    };
                }

                //Select by Text
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 340);
                    TestBtn.Text     = "Text";
                    TestBtn.Width    = 100;
                    TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectByText("Text");
                    };
                }

                //Select by Name
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 360);
                    TestBtn.Text     = "Name";
                    TestBtn.Width    = 100;
                    TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectByName("Name");
                    };
                }

                //Select by UserData
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 380);
                    TestBtn.Text     = "UserData";
                    TestBtn.Width    = 100;
                    TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectByUserData(12);
                    };
                }
            }
        }
Example #6
0
        public ListBox(Base parent)
            : base(parent)
        {
            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetPosition(10, 10);

                ctrl.AddRow("First");
                ctrl.AddRow("Blue");
                ctrl.AddRow("Yellow");
                ctrl.AddRow("Orange");
                ctrl.AddRow("Brown");
                ctrl.AddRow("Black");
                ctrl.AddRow("Green");
                ctrl.AddRow("Dog");
                ctrl.AddRow("Cat Blue");
                ctrl.AddRow("Shoes");
                ctrl.AddRow("Shirts");
                ctrl.AddRow("Chair");
                ctrl.AddRow("I'm autosized");
                ctrl.AddRow("Last");

                ctrl.AllowMultiSelect = true;
                ctrl.SelectRowsByRegex("Bl.e|Dog");

                ctrl.RowSelected += RowSelected;
                ctrl.RowUnselected += RowUnSelected;

                ctrl.SizeToContents();
            }

            {
                Table ctrl = new Table(this);
                ctrl.SetPosition(120, 10);

                ctrl.AddRow("First");
                ctrl.AddRow("Blue");
                ctrl.AddRow("Yellow");
                ctrl.AddRow("Orange");
                ctrl.AddRow("Brown");
                ctrl.AddRow("Black");
                ctrl.AddRow("Green");
                ctrl.AddRow("Dog");
                ctrl.AddRow("Cat Blue");
                ctrl.AddRow("Shoes");
                ctrl.AddRow("Shirts");
                ctrl.AddRow("Chair");
                ctrl.AddRow("I'm autosized");
                ctrl.AddRow("Last");

                ctrl.SizeToContents(0);
            }

            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetBounds(220, 10, 200, 200);
                ctrl.ColumnCount = 3;
                //ctrl.AllowMultiSelect = true;
                ctrl.RowSelected += RowSelected;
                ctrl.RowUnselected += RowUnSelected;

                {
                    TableRow row = ctrl.AddRow("Baked Beans");
                    row.SetCellText(1, "Heinz");
                    row.SetCellText(2, "£3.50");
                }

                {
                    TableRow row = ctrl.AddRow("Bananas");
                    row.SetCellText(1, "Trees");
                    row.SetCellText(2, "£1.27");
                }

                {
                    TableRow row = ctrl.AddRow("Chicken");
                    row.SetCellText(1, "\u5355\u5143\u6D4B\u8BD5");
                    row.SetCellText(2, "£8.95");
                }
            }

            {
                // fixed-size table
                Control.Layout.Table table = new Table(this);
                table.SetColumnCount(3);
                table.SetBounds(450, 10, 320, 100);
                table.SetColumnWidth(0, 100);
                table.SetColumnWidth(1, 100);
                table.SetColumnWidth(2, 100);
                var row1 = table.AddRow();
                row1.SetCellText(0, "Row 1");
                row1.SetCellText(1, "R1 cell 1");
                row1.SetCellText(2, "Row 1 cell 2");

                table.AddRow().Text = "Row 2, slightly bigger";
                table[1].SetCellText(1, "Center cell");

                table.AddRow().Text = "Row 3, medium";
                table[2].SetCellText(2, "Last cell");
            }

            {
                //Control.Label outer = new Control.Label(this);
                //outer.SetBounds(340, 140, 300, 200);

                // autosized table
                Control.Layout.Table table = new Table(this);
                table.SetColumnCount(3);
                table.SetPosition(450, 150);

                var row1 = table.AddRow();
                row1.SetCellText(0, "Row 1");
                row1.SetCellText(1, "R1 cell 1");
                row1.SetCellText(2, "Row 1 cell 2");

                table.AddRow().Text = "Row 2, slightly bigger";
                table[1].SetCellText(1, "Center cell");

                table.AddRow().Text = "Row 3, medium";
                table[2].SetCellText(2, "Last cell");

                table.SizeToContents(0);
            }

            /* Selecting Rows in Code */
            {
                Control.ListBox ctrl = new Control.ListBox(this);
                ctrl.SetPosition(10, 320);

                ListBoxRow Row = ctrl.AddRow("Row");
                ctrl.AddRow("Text");
                ctrl.AddRow("InternalName", "Name");
                ctrl.AddRow("UserData", "Internal", 12);

                ctrl.SizeToContents();

                Control.CheckBox Multiline = new Control.CheckBox(this);
                Multiline.SetPosition(10, 405);
                Multiline.CheckChanged +=
                    delegate(Base sender, EventArgs args) { ctrl.AllowMultiSelect = Multiline.IsChecked; };

                Control.Label lblml = new Control.Label(this);
                lblml.Text = "Enable MultiSelect";
                lblml.SetPosition(30, 405);

                //Select by Menu Item
                {
                    Control.Button TriangleButton = new Control.Button(this);
                    TriangleButton.SetPosition(100, 320);
                    TriangleButton.Text = "Row";
                    TriangleButton.Width = 100;
                    TriangleButton.Clicked += delegate(Base sender, ClickedEventArgs args) { ctrl.SelectedRow = Row; };
                }

                //Select by Text
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 340);
                    TestBtn.Text = "Text";
                    TestBtn.Width = 100;
                    TestBtn.Clicked += delegate(Base sender, ClickedEventArgs args) { ctrl.SelectByText("Text"); };
                }

                //Select by Name
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 360);
                    TestBtn.Text = "Name";
                    TestBtn.Width = 100;
                    TestBtn.Clicked += delegate(Base sender, ClickedEventArgs args) { ctrl.SelectByName("Name"); };
                }

                //Select by UserData
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(100, 380);
                    TestBtn.Text = "UserData";
                    TestBtn.Width = 100;
                    TestBtn.Clicked += delegate(Base sender, ClickedEventArgs args) { ctrl.SelectByUserData(12); };
                }
            }
        }