Пример #1
0
        public ColorPickers(Base parent)
            : base(parent)
        {
            /* RGB Picker */
            {
                ColorPicker rgbPicker = new ColorPicker(this);
                rgbPicker.SetPosition(10, 10);
                rgbPicker.ColorChanged += ColorChanged;
            }

            /* HSVColorPicker */
            {
                HSVColorPicker hsvPicker = new HSVColorPicker(this);
                hsvPicker.SetPosition(300, 10);
                hsvPicker.ColorChanged += ColorChanged;
            }

            /* HSVColorPicker in Window */
            {
                Control.WindowControl Window = new WindowControl(this);
                Window.SetSize(300, 300);
                Window.Hide();

                HSVColorPicker hsvPicker = new HSVColorPicker(Window);
                hsvPicker.SetPosition(10, 10);
                hsvPicker.ColorChanged += ColorChanged;

                Control.Button OpenWindow = new Control.Button(this);
                OpenWindow.SetPosition(10, 200);
                OpenWindow.SetSize(200, 20);
                OpenWindow.Text = "Open Window";
                OpenWindow.Clicked += delegate(Base sender, ClickedEventArgs args) { Window.Show(); };
            }
        }
Пример #2
0
        public Window(Base parent)
            : base(parent)
        {
            rand = new Random();

            Control.Button button1 = new Control.Button(this);
            button1.SetText("Open a Window");
            button1.Clicked += OpenWindow;

            Control.Button button2 = new Control.Button(this);
            button2.SetText("Open a MessageBox");
            button2.Clicked += OpenMsgbox;
            Align.PlaceRightBottom(button2, button1, 10);

            m_WindowCount = 1;
        }
Пример #3
0
        public Button(Base parent)
            : base(parent)
        {
            buttonA = new Control.Button(this);
            buttonA.Text = "Event tester";
            buttonA.SetBounds(200, 30, 300, 200);
            buttonA.Pressed += onButtonAp;
            buttonA.Clicked += onButtonAc;
            buttonA.Released += onButtonAr;

            buttonB = new Control.Button(this);
            buttonB.Text = "\u0417\u0430\u043C\u0435\u0436\u043D\u0430\u044F \u043C\u043E\u0432\u0430";
            buttonB.SetPosition(0, 20);

            buttonC = new Control.Button(this);
            buttonC.Text = "Image button";
            buttonC.SetImage("test16.png");
            Align.PlaceDownLeft(buttonC, buttonB, 10);

            buttonD = new Control.Button(this);
            buttonD.SetImage("test16.png");
            buttonD.SetSize(20, 20);
            Align.PlaceDownLeft(buttonD, buttonC, 10);

            buttonE = new Control.Button(this);
            buttonE.Text = "Toggle me";
            buttonE.IsToggle = true;
            buttonE.Toggled += onToggle;
            buttonE.ToggledOn += onToggleOn;
            buttonE.ToggledOff += onToggleOff;
            Align.PlaceDownLeft(buttonE, buttonD, 10);

            buttonF = new Control.Button(this);
            buttonF.Text = "Disabled :D";
            buttonF.IsDisabled = true;
            Align.PlaceDownLeft(buttonF, buttonE, 10);

            buttonG = new Control.Button(this);
            buttonG.Text = "With Tooltip";
            buttonG.SetToolTipText("This is tooltip");
            Align.PlaceDownLeft(buttonG, buttonF, 10);

            buttonH = new Control.Button(this);
            buttonH.Text = "I'm autosized";
            buttonH.SizeToContents();
            Align.PlaceDownLeft(buttonH, buttonG, 10);
        }
Пример #4
0
        public StatusBar(Base parent)
            : base(parent)
        {
            Control.StatusBar sb = new Control.StatusBar(this);
            Control.Label left = new Control.Label(sb);
            left.Text = "Label added to left";
            sb.AddControl(left, false);

            Control.Label right = new Control.Label(sb);
            right.Text = "Label added to right";
            sb.AddControl(right, true);

            Control.Button bl = new Control.Button(sb);
            bl.Text = "Left button";
            sb.AddControl(bl, false);

            Control.Button br = new Control.Button(sb);
            br.Text = "Right button";
            sb.AddControl(br, true);
        }
Пример #5
0
        public ComboBox(Base parent)
            : base(parent)
        {
            {
                Control.ComboBox combo = new Control.ComboBox(this);
                combo.SetPosition(50, 50);
                combo.Width = 200;

                combo.AddItem("Option One", "one");
                combo.AddItem("Number Two", "two");
                combo.AddItem("Door Three", "three");
                combo.AddItem("Four Legs", "four");
                combo.AddItem("Five Birds", "five");

                combo.ItemSelected += OnComboSelect;
            }

            {
                // Empty
                Control.ComboBox combo = new Control.ComboBox(this);
                combo.SetPosition(50, 80);
                combo.Width = 200;
            }

            {
                // Lots of things
                Control.ComboBox combo = new Control.ComboBox(this);
                combo.SetPosition(50, 110);
                combo.Width = 200;

                for (int i = 0; i < 500; i++)
                    combo.AddItem(String.Format("Option {0}", i));

                combo.ItemSelected += OnComboSelect;
            }

            {
                // In-Code Item Change
                Control.ComboBox combo = new Control.ComboBox(this);
                combo.SetPosition(50, 140);
                combo.Width = 200;

                MenuItem Triangle = combo.AddItem("Triangle");
                combo.AddItem("Red", "color");
                combo.AddItem("Apple", "fruit");
                combo.AddItem("Blue", "color");
                combo.AddItem("Green", "color", 12);
                combo.ItemSelected += OnComboSelect;

                //Select by Menu Item
                {
                    Control.Button TriangleButton = new Control.Button(this);
                    TriangleButton.SetPosition(255, 140);
                    TriangleButton.Text = "Triangle";
                    TriangleButton.Width = 100;
                    TriangleButton.Clicked +=
                        delegate(Base sender, ClickedEventArgs args) { combo.SelectedItem = Triangle; };
                }

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

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

                //Select by UserData
                {
                    Control.Button TestBtn = new Control.Button(this);
                    TestBtn.SetPosition(570, 140);
                    TestBtn.Text = "Green";
                    TestBtn.Width = 100;
                    TestBtn.Clicked += delegate(Base sender, ClickedEventArgs args) { combo.SelectByUserData(12); };
                }
            }
        }
Пример #6
0
        public ScrollControl(Base parent)
            : base(parent)
        {
            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(10, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Twice As Big");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(110, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Same Size");
                pTestButton.SetBounds(0, 0, 100, 100);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(210, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Wide");
                pTestButton.SetBounds(0, 0, 200, 50);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(310, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Tall");
                pTestButton.SetBounds(0, 0, 50, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(410, 10, 100, 100);
                ctrl.EnableScroll(false, true);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Vertical");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(510, 10, 100, 100);
                ctrl.EnableScroll(true, false);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Horizontal");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            // Bottom Row

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(10, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Twice As Big");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(110, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Same Size");
                pTestButton.SetBounds(0, 0, 100, 100);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(210, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Wide");
                pTestButton.SetBounds(0, 0, 200, 50);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(310, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Tall");
                pTestButton.SetBounds(0, 0, 50, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(410, 110, 100, 100);
                ctrl.AutoHideBars = true;
                ctrl.EnableScroll(false, true);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Vertical");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(510, 110, 100, 100);
                ctrl.AutoHideBars = true;
                ctrl.EnableScroll(true, false);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Horinzontal");
                pTestButton.SetBounds(0, 0, 200, 200);
            }
        }
Пример #7
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); };
                }
            }
        }
Пример #8
0
        public CrossSplitter(Base parent)
            : base(parent)
        {
            m_CurZoom = 0;

            m_Splitter = new Control.CrossSplitter(this);
            m_Splitter.SetPosition(0, 0);
            m_Splitter.Dock = Pos.Fill;

            {
                VerticalSplitter splitter = new VerticalSplitter(m_Splitter);
                Control.Button button1 = new Control.Button(splitter);
                button1.SetText("Vertical left");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Vertical right");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(0, splitter);
            }

            {
                HorizontalSplitter splitter = new HorizontalSplitter(m_Splitter);
                Control.Button button1 = new Control.Button(splitter);
                button1.SetText("Horizontal up");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Horizontal down");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(1, splitter);
            }

            {
                HorizontalSplitter splitter = new HorizontalSplitter(m_Splitter);
                Control.Button button1 = new Control.Button(splitter);
                button1.SetText("Horizontal up");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Horizontal down");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(2, splitter);
            }

            {
                VerticalSplitter splitter = new VerticalSplitter(m_Splitter);
                Control.Button button1 = new Control.Button(splitter);
                button1.SetText("Vertical left");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Vertical right");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(3, splitter);
            }

            //Status bar to hold unit testing buttons
            Control.StatusBar pStatus = new Control.StatusBar(this);
            pStatus.Dock = Pos.Bottom;

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("Zoom");
                pButton.Clicked += ZoomTest;
                pStatus.AddControl(pButton, false);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("UnZoom");
                pButton.Clicked += UnZoomTest;
                pStatus.AddControl(pButton, false);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("CenterPanels");
                pButton.Clicked += CenterPanels;
                pStatus.AddControl(pButton, true);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("Splitters");
                pButton.Clicked += ToggleSplitters;
                pStatus.AddControl(pButton, true);
            }
        }
Пример #9
0
 private void CreateControl(ControlBase parent, string text)
 {
     Control.Button button = new Control.Button(parent);
     button.Text = text;
 }
Пример #10
0
        public ScrollControl(Base parent)
            : base(parent)
        {
            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(10, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Twice As Big");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(110, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Same Size");
                pTestButton.SetBounds(0, 0, 100, 100);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(210, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Wide");
                pTestButton.SetBounds(0, 0, 200, 50);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(310, 10, 100, 100);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Tall");
                pTestButton.SetBounds(0, 0, 50, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(410, 10, 100, 100);
                ctrl.EnableScroll(false, true);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Vertical");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(510, 10, 100, 100);
                ctrl.EnableScroll(true, false);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Horizontal");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            // Bottom Row

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(10, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Twice As Big");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(110, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Same Size");
                pTestButton.SetBounds(0, 0, 100, 100);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(210, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Wide");
                pTestButton.SetBounds(0, 0, 200, 50);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(310, 110, 100, 100);
                ctrl.AutoHideBars = true;

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Tall");
                pTestButton.SetBounds(0, 0, 50, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(410, 110, 100, 100);
                ctrl.AutoHideBars = true;
                ctrl.EnableScroll(false, true);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Vertical");
                pTestButton.SetBounds(0, 0, 200, 200);
            }

            {
                Control.ScrollControl ctrl = new Control.ScrollControl(this);
                ctrl.SetBounds(510, 110, 100, 100);
                ctrl.AutoHideBars = true;
                ctrl.EnableScroll(true, false);

                Control.Button pTestButton = new Control.Button(ctrl);
                pTestButton.SetText("Horinzontal");
                pTestButton.SetBounds(0, 0, 200, 200);
            }
        }
Пример #11
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)
                {
                    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);
                    };
                }
            }
        }
Пример #12
0
        public CrossSplitter(Base parent)
            : base(parent)
        {
            m_CurZoom = 0;

            m_Splitter = new Control.CrossSplitter(this);
            m_Splitter.SetPosition(0, 0);
            m_Splitter.Dock = Pos.Fill;

            {
                VerticalSplitter splitter = new VerticalSplitter(m_Splitter);
                Control.Button   button1  = new Control.Button(splitter);
                button1.SetText("Vertical left");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Vertical right");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(0, splitter);
            }

            {
                HorizontalSplitter splitter = new HorizontalSplitter(m_Splitter);
                Control.Button     button1  = new Control.Button(splitter);
                button1.SetText("Horizontal up");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Horizontal down");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(1, splitter);
            }

            {
                HorizontalSplitter splitter = new HorizontalSplitter(m_Splitter);
                Control.Button     button1  = new Control.Button(splitter);
                button1.SetText("Horizontal up");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Horizontal down");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(2, splitter);
            }

            {
                VerticalSplitter splitter = new VerticalSplitter(m_Splitter);
                Control.Button   button1  = new Control.Button(splitter);
                button1.SetText("Vertical left");
                Control.Button button2 = new Control.Button(splitter);
                button2.SetText("Vertical right");
                splitter.SetPanel(0, button1);
                splitter.SetPanel(1, button2);
                m_Splitter.SetPanel(3, splitter);
            }

            //Status bar to hold unit testing buttons
            Control.StatusBar pStatus = new Control.StatusBar(this);
            pStatus.Dock = Pos.Bottom;

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("Zoom");
                pButton.Clicked += ZoomTest;
                pStatus.AddControl(pButton, false);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("UnZoom");
                pButton.Clicked += UnZoomTest;
                pStatus.AddControl(pButton, false);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("CenterPanels");
                pButton.Clicked += CenterPanels;
                pStatus.AddControl(pButton, true);
            }

            {
                Control.Button pButton = new Control.Button(pStatus);
                pButton.SetText("Splitters");
                pButton.Clicked += ToggleSplitters;
                pStatus.AddControl(pButton, true);
            }
        }
Пример #13
0
        public ListBox(ControlBase parent)
            : base(parent)
        {
            HorizontalLayout hlayout = new HorizontalLayout(this);

            hlayout.Margin = Margin.Three;
            hlayout.Dock   = Dock.Top;
            {
                Control.ListBox ctrl = new Control.ListBox(hlayout);
                ctrl.Margin           = Margin.Three;
                ctrl.AllowMultiSelect = true;

                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.SelectRowsByRegex("Bl.e|Dog");

                ctrl.RowSelected   += RowSelected;
                ctrl.RowUnselected += RowUnSelected;
            }
            {
                Table ctrl = new Table(hlayout);
                ctrl.Margin = Margin.Three;

                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.SizeColumnsToContent();
            }
            {
                Control.ListBox ctrl = new Control.ListBox(hlayout);
                ctrl.Margin         = Margin.Three;
                ctrl.ColumnCount    = 3;
                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");
                }
            }

            VerticalLayout vlayout = new VerticalLayout(hlayout);

            {
                // fixed-size list box
                Control.ListBox ctrl = new Control.ListBox(vlayout);
                ctrl.Margin = Margin.Three;
                ctrl.Height = 90;
                ctrl.AutoSizeColumnsToContent = false;
                ctrl.HorizontalAlignment      = HorizontalAlignment.Left;
                ctrl.ColumnCount = 3;

                ctrl.SetColumnWidth(0, 120);
                ctrl.SetColumnWidth(1, 150);
                ctrl.SetColumnWidth(2, 150);

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

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

                ctrl.AddRow("Row 3, medium");
                ctrl[2].SetCellText(2, "Last cell");
            }
            {
                // autosized list box
                Control.ListBox ctrl = new Control.ListBox(vlayout);
                ctrl.Margin = Margin.Three;
                ctrl.HorizontalAlignment = HorizontalAlignment.Left;
                ctrl.AutoSizeToContent   = true;
                ctrl.ColumnCount         = 3;

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

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

                ctrl.AddRow("Row 3, medium");
                ctrl[2].SetCellText(2, "Last cell");
            }
            {
                Control.ListBox ctrl = new Control.ListBox(vlayout);
                ctrl.Margin = Margin.Three;
                ctrl.HorizontalAlignment = HorizontalAlignment.Left;
                ctrl.AutoSizeToContent   = true;
                ctrl.Height = 110;

                ObservableCollection <ListBoxItem> items = new ObservableCollection <ListBoxItem>();
                items.Add(new ListBoxItem()
                {
                    Name = "Baked Beans", Type = "Heinz", Price = 3.50
                });
                items.Add(new ListBoxItem()
                {
                    Name = "Bananas", Type = "Trees", Price = 1.27
                });

                ctrl.DisplayMembers = new string[] { "Name", "Type", "Price" };
                ctrl.ItemsSource    = items;

                HorizontalLayout hlayout2 = new HorizontalLayout(vlayout);
                {
                    Control.Button add = new Control.Button(hlayout2);
                    add.Margin   = Margin.Three;
                    add.Text     = "Insert";
                    add.Clicked += (s, e) =>
                    {
                        int selectedIndex = ctrl.SelectedRowIndex;
                        if (selectedIndex != -1)
                        {
                            items.Insert(selectedIndex, new ListBoxItem()
                            {
                                Name = "Chicken", Type = "\u5355\u5143\u6D4B\u8BD5", Price = 8.95
                            });
                        }
                        else
                        {
                            items.Add(new ListBoxItem()
                            {
                                Name = "Chicken", Type = "\u5355\u5143\u6D4B\u8BD5", Price = 8.95
                            });
                        }
                    };
                }
                {
                    Control.Button remove = new Control.Button(hlayout2);
                    remove.Margin   = Margin.Three;
                    remove.Text     = "Remove";
                    remove.Clicked += (s, e) =>
                    {
                        int selectedIndex = ctrl.SelectedRowIndex;
                        if (selectedIndex != -1)
                        {
                            items.RemoveAt(selectedIndex);
                        }
                    };
                }
            }
            hlayout        = new HorizontalLayout(this);
            hlayout.Margin = Margin.Six;
            hlayout.Dock   = Dock.Top;

            /* Selecting Rows in Code */
            {
                Control.ListBox ctrl = new Control.ListBox(hlayout);
                ctrl.AutoSizeToContent = true;

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

                Control.LabeledCheckBox multiline = new Control.LabeledCheckBox(this);
                multiline.Margin        = Margin.Six;
                multiline.Dock          = Dock.Top;
                multiline.Text          = "Enable MultiSelect";
                multiline.CheckChanged += delegate(ControlBase sender, EventArgs args)
                {
                    ctrl.AllowMultiSelect = multiline.IsChecked;
                };

                vlayout = new VerticalLayout(hlayout);
                //Select by Row
                {
                    Control.Button TriangleButton = new Control.Button(vlayout);
                    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(vlayout);
                    TestBtn.Text     = "Text";
                    TestBtn.Width    = 100;
                    TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectRows("Text");
                    };
                }
                //Select by Name
                {
                    Control.Button TestBtn = new Control.Button(vlayout);
                    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(vlayout);
                    TestBtn.Text     = "UserData";
                    TestBtn.Width    = 100;
                    TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args)
                    {
                        ctrl.SelectByUserData(12);
                    };
                }
            }
        }