示例#1
0
        public CheckBox(ControlBase parent)
            : base(parent)
        {

            Control.CheckBox check = new Control.CheckBox(this);
            check.SetPosition(10, 10);
            check.Checked += OnChecked;
            check.UnChecked += OnUnchecked;
            check.CheckChanged += OnCheckChanged;

            Control.LabeledCheckBox labeled = new Control.LabeledCheckBox(this);
            labeled.Text = "Labeled CheckBox";
            labeled.Checked += OnChecked;
            labeled.UnChecked += OnUnchecked;
            labeled.CheckChanged += OnCheckChanged;
            Align.PlaceDownLeft(labeled, check, 10);

            Control.LabeledCheckBox labeled2 = new Control.LabeledCheckBox(this);
            labeled2.Text = "I'm autosized";
            labeled2.SizeToChildren();
            Align.PlaceDownLeft(labeled2, labeled, 10);

            Control.CheckBox check2 = new Control.CheckBox(this);
            check2.IsDisabled = true;
            Align.PlaceDownLeft(check2, labeled2, 20);
        }
示例#2
0
        public CheckBox(Base parent)
            : base(parent)
        {
            Control.CheckBox check = new Control.CheckBox(this);
            check.SetPosition(10, 10);
            check.Checked      += OnChecked;
            check.UnChecked    += OnUnchecked;
            check.CheckChanged += OnCheckChanged;

            Control.LabeledCheckBox labeled = new Control.LabeledCheckBox(this);
            labeled.Text          = "Labeled CheckBox";
            labeled.Checked      += OnChecked;
            labeled.UnChecked    += OnUnchecked;
            labeled.CheckChanged += OnCheckChanged;
            Align.PlaceDownLeft(labeled, check, 10);

            Control.LabeledCheckBox labeled2 = new Control.LabeledCheckBox(this);
            labeled2.Text = "I'm autosized";
            labeled2.SizeToChildren();
            Align.PlaceDownLeft(labeled2, labeled, 10);

            Control.CheckBox check2 = new Control.CheckBox(this);
            check2.IsDisabled = true;
            Align.PlaceDownLeft(check2, labeled2, 20);
        }
示例#3
0
        public CheckBox(ControlBase parent)
            : base(parent)
        {
            VerticalLayout layout = new VerticalLayout(this);

            Control.CheckBox check;

            check               = new Control.CheckBox(layout);
            check.Margin        = Margin.Three;
            check.Checked      += OnChecked;
            check.UnChecked    += OnUnchecked;
            check.CheckChanged += OnCheckChanged;

            Control.LabeledCheckBox labeled;

            labeled               = new Control.LabeledCheckBox(layout);
            labeled.Margin        = Margin.Three;
            labeled.Text          = "Labeled CheckBox";
            labeled.Checked      += OnChecked;
            labeled.UnChecked    += OnUnchecked;
            labeled.CheckChanged += OnCheckChanged;

            check            = new Control.CheckBox(layout);
            check.Margin     = Margin.Three;
            check.IsDisabled = true;
        }
示例#4
0
        private void OpenWindow(ControlBase control, EventArgs args)
        {
            Control.Window window = new Control.Window(this);
            window.Title   = String.Format("Window ({0})", ++m_WindowCount);
            window.Size    = new Size(m_Rand.Next(200, 400), m_Rand.Next(200, 400));
            window.Left    = m_Rand.Next(700);
            window.Top     = m_Rand.Next(400);
            window.Padding = new Padding(6, 3, 6, 6);

            Control.RadioButtonGroup rbg = new RadioButtonGroup(window);
            rbg.Dock = Dock.Top;
            rbg.AddOption("Resize disabled", "None").Checked += (c, a) => window.Resizing = Resizing.None;
            rbg.AddOption("Resize width", "Width").Checked   += (c, a) => window.Resizing = Resizing.Width;
            rbg.AddOption("Resize height", "Height").Checked += (c, a) => window.Resizing = Resizing.Height;
            rbg.AddOption("Resize both", "Both").Checked     += (c, a) => window.Resizing = Resizing.Both;
            rbg.SetSelectionByName("Both");

            Control.LabeledCheckBox dragging = new Control.LabeledCheckBox(window);
            dragging.Dock          = Dock.Top;
            dragging.Text          = "Dragging";
            dragging.IsChecked     = true;
            dragging.CheckChanged += (c, a) => window.IsDraggingEnabled = dragging.IsChecked;
        }
        public string Note; // additional text to display in status bar

        public UnitTest(Base parent) : base(parent)
        {
            Dock = Pos.Fill;
            SetSize(1024, 768);
            m_List = new Control.CollapsibleList(this);

            LeftDock.TabControl.AddPage("Unit tests", m_List);
            LeftDock.Width = 150;

            m_TextOutput      = new Control.ListBox(BottomDock);
            m_Button          = BottomDock.TabControl.AddPage("Output", m_TextOutput);
            BottomDock.Height = 200;

            m_DebugCheck = new Control.LabeledCheckBox(m_List)
            {
                Text = "Debug outlines"
            };
            m_DebugCheck.CheckChanged += DebugCheckChanged;

            m_StatusBar = new Control.StatusBar(this)
            {
                Dock = Pos.Bottom
            };
            m_StatusBar.AddControl(m_DebugCheck, true);

            m_Center = new Center(this)
            {
                Dock = Pos.Fill
            };
            GUnit test;

            {
                CollapsibleCategory cat = m_List.Add("Non-Interactive");
                {
                    test = new Label(m_Center);
                    RegisterUnitTest("Label", cat, test);
                    test = new RichLabel(m_Center);
                    RegisterUnitTest("RichLabel", cat, test);
                    test = new GroupBox(m_Center);
                    RegisterUnitTest("GroupBox", cat, test);
                    test = new ProgressBar(m_Center);
                    RegisterUnitTest("ProgressBar", cat, test);
                    test = new ImagePanel(m_Center);
                    RegisterUnitTest("ImagePanel", cat, test);
                    test = new StatusBar(m_Center);
                    RegisterUnitTest("StatusBar", cat, test);
                }
            }

            {
                CollapsibleCategory cat = m_List.Add("Standard");
                {
                    test = new Button(m_Center);
                    RegisterUnitTest("Button", cat, test);
                    test = new TextBox(m_Center);
                    RegisterUnitTest("TextBox", cat, test);
                    test = new CheckBox(m_Center);
                    RegisterUnitTest("CheckBox", cat, test);
                    test = new RadioButton(m_Center);
                    RegisterUnitTest("RadioButton", cat, test);
                    test = new ComboBox(m_Center);
                    RegisterUnitTest("ComboBox", cat, test);
                    test = new ListBox(m_Center);
                    RegisterUnitTest("ListBox", cat, test);
                    test = new NumericUpDown(m_Center);
                    RegisterUnitTest("NumericUpDown", cat, test);
                    test = new Slider(m_Center);
                    RegisterUnitTest("Slider", cat, test);
                    test = new Menu(m_Center);
                    RegisterUnitTest("Menu", cat, test);
                    test = new CrossSplitter(m_Center);
                    RegisterUnitTest("CrossSplitter", cat, test);
                }
            }

            {
                CollapsibleCategory cat = m_List.Add("Containers");
                {
                    test = new Window(m_Center);
                    RegisterUnitTest("Window", cat, test);
                    test = new TreeControl(m_Center);
                    RegisterUnitTest("TreeControl", cat, test);
                    test = new Properties(m_Center);
                    RegisterUnitTest("Properties", cat, test);
                    test = new TabControl(m_Center);
                    RegisterUnitTest("TabControl", cat, test);
                    test = new ScrollControl(m_Center);
                    RegisterUnitTest("ScrollControl", cat, test);
                    test = new Docking(m_Center);
                    RegisterUnitTest("Docking", cat, test);
                }
            }

            {
                CollapsibleCategory cat = m_List.Add("Non-standard");
                {
                    test = new CollapsibleList(m_Center);
                    RegisterUnitTest("CollapsibleList", cat, test);
                    test = new ColorPickers(m_Center);
                    RegisterUnitTest("Color pickers", cat, test);
                }
            }

            m_StatusBar.SendToBack();
            PrintText("Unit Test started!");
        }
示例#6
0
        public String Note; // additional text to display in status bar

        public UnitTest(ZGE.Components.ZComponent parent) : base(parent)
        {
            Dock = Pos.Fill;
            SetSize(1024, 768);
            m_List = new Control.CollapsibleList(this);

            LeftDock.TabControl.AddPage("Unit tests", m_List);
            LeftDock.Width = 150;

            m_TextOutput = new Control.ListBox(BottomDock);
            m_Button = BottomDock.TabControl.AddPage("Output", m_TextOutput);
            BottomDock.Height = 200;

            m_DebugCheck = new Control.LabeledCheckBox(m_List);
            m_DebugCheck.Text = "Debug outlines";
            m_DebugCheck.CheckChanged += DebugCheckChanged;

            m_StatusBar = new Control.StatusBar(this);
            m_StatusBar.Dock = Pos.Bottom;
            m_StatusBar.AddControl(m_DebugCheck, true);

            //m_Center = new Center(this);
            //m_Center.Dock = Pos.Fill;
            GUnit test;

            {
                CollapsibleCategory cat = m_List.Add("Non-Interactive");
                {
                    test = new Label(this);
                    RegisterUnitTest("Label", cat, test);
                    test = new RichLabel(this);
                    RegisterUnitTest("RichLabel", cat, test);
                    test = new GroupBox(this);
                    RegisterUnitTest("GroupBox", cat, test);
                    test = new ProgressBar(this);
                    RegisterUnitTest("ProgressBar", cat, test);
                    test = new ImagePanel(this);
                    RegisterUnitTest("ImagePanel", cat, test);
                    test = new StatusBar(this);
                    RegisterUnitTest("StatusBar", cat, test);
                }
            }

            {
                CollapsibleCategory cat = m_List.Add("Standard");
                {
                    test = new Button(this);
                    RegisterUnitTest("Button", cat, test);
                    test = new TextBox(this);
                    RegisterUnitTest("TextBox", cat, test);
                    test = new CheckBox(this);
                    RegisterUnitTest("CheckBox", cat, test);
                    test = new RadioButton(this);
                    RegisterUnitTest("RadioButton", cat, test);
                    test = new ComboBox(this);
                    RegisterUnitTest("ComboBox", cat, test);
                    test = new ListBox(this);
                    RegisterUnitTest("ListBox", cat, test);
                    test = new NumericUpDown(this);
                    RegisterUnitTest("NumericUpDown", cat, test);
                    test = new Slider(this);
                    RegisterUnitTest("Slider", cat, test);
                    test = new MenuStrip(this);
                    RegisterUnitTest("MenuStrip", cat, test);
                    test = new CrossSplitter(this);
                    RegisterUnitTest("CrossSplitter", cat, test);
                }
            }
            
            {
                CollapsibleCategory cat = m_List.Add("Containers");
                {
                    test = new Window(this);
                    RegisterUnitTest("Window", cat, test);
                    test = new TreeControl(this);
                    RegisterUnitTest("TreeControl", cat, test);
                    test = new Properties(this);
                    RegisterUnitTest("Properties", cat, test);
                    test = new TabControl(this);
                    RegisterUnitTest("TabControl", cat, test);
                    test = new ScrollControl(this);
                    RegisterUnitTest("ScrollControl", cat, test);
                    test = new Docking(this);
                    RegisterUnitTest("Docking", cat, test);
                }
            }
            
            {
                CollapsibleCategory cat = m_List.Add("Non-standard");
                {
                    test = new CollapsibleList(this);
                    RegisterUnitTest("CollapsibleList", cat, test);
                    test = new ColorPickers(this);
                    RegisterUnitTest("Color pickers", cat, test);
                }
            }

            m_StatusBar.SendToBack();
            PrintText("Unit Test started!");
        }
示例#7
0
        public string Note;        // additional text to display in status bar

        public UnitTest(ControlBase parent) : base(parent)
        {
            Dock = Dock.Fill;

            DockBase dock = new DockBase(this);

            dock.Dock = Dock.Fill;

            m_List = new Control.CollapsibleList(this);

            dock.LeftDock.TabControl.AddPage("Unit tests", m_List);
            dock.LeftDock.Width = 150;

            m_TextOutput = new Control.ListBox(this);
            m_TextOutput.AlternateColor = false;

            dock.BottomDock.TabControl.AddPage("Output", m_TextOutput);
            dock.BottomDock.Height = 200;

            m_StatusBar      = new Control.StatusBar(this);
            m_StatusBar.Dock = Dock.Bottom;

            m_DebugCheck               = new Control.LabeledCheckBox(m_StatusBar);
            m_DebugCheck.Text          = "Debug outlines";
            m_DebugCheck.CheckChanged += DebugCheckChanged;

            m_IncScale = new Control.Button(m_StatusBar);
            m_IncScale.HorizontalAlignment = HorizontalAlignment.Left;
            m_IncScale.VerticalAlignment   = VerticalAlignment.Stretch;
            m_IncScale.Width       = 30;
            m_IncScale.Margin      = new Margin(0, 0, 8, 0);
            m_IncScale.TextPadding = new Padding(5, 0, 5, 0);
            m_IncScale.Text        = "+";
            m_IncScale.Clicked    += (sender, arguments) => { m_UIScale.Value = Math.Min(m_UIScale.Value + 0.25f, 3.0f); };

            m_UIScale = new Control.TextBoxNumeric(m_StatusBar);
            m_UIScale.VerticalAlignment = VerticalAlignment.Stretch;
            m_UIScale.Width             = 70;
            m_UIScale.Value             = GetCanvas().Scale;
            m_UIScale.TextChanged      += (sender, arguments) => { GetCanvas().Scale = m_UIScale.Value; };

            m_DecScale = new Control.Button(m_StatusBar);
            m_DecScale.HorizontalAlignment = HorizontalAlignment.Left;
            m_DecScale.VerticalAlignment   = VerticalAlignment.Stretch;
            m_DecScale.Width       = 30;
            m_DecScale.Margin      = new Margin(4, 0, 0, 0);
            m_DecScale.TextPadding = new Padding(5, 0, 5, 0);
            m_DecScale.Text        = "-";
            m_DecScale.Clicked    += (sender, arguments) => { m_UIScale.Value = Math.Max(m_UIScale.Value - 0.25f, 1.0f); };

            m_UIScaleText = new Control.Label(m_StatusBar);
            m_UIScaleText.VerticalAlignment = VerticalAlignment.Stretch;
            m_UIScaleText.Alignment         = Alignment.Left | Alignment.CenterV;
            m_UIScaleText.Text = "Scale:";

            m_Center      = new Control.Layout.DockLayout(dock);
            m_Center.Dock = Dock.Fill;

            List <Type> tests = typeof(UnitTest).Assembly.GetTypes().Where(t => t.IsDefined(typeof(UnitTestAttribute), false)).ToList();

            tests.Sort((t1, t2) =>
            {
                object[] a1s = t1.GetCustomAttributes(typeof(UnitTestAttribute), false);
                object[] a2s = t2.GetCustomAttributes(typeof(UnitTestAttribute), false);
                if (a1s.Length > 0 && a2s.Length > 0)
                {
                    UnitTestAttribute a1 = a1s[0] as UnitTestAttribute;
                    UnitTestAttribute a2 = a2s[0] as UnitTestAttribute;
                    if (a1.Order == a2.Order)
                    {
                        if (a1.Category == a2.Category)
                        {
                            return(String.Compare(a1.Name != null ? a1.Name : t1.Name, a2.Name != null ? a2.Name : t2.Name, StringComparison.OrdinalIgnoreCase));
                        }
                        else
                        {
                            return(String.Compare(a1.Category, a2.Category, StringComparison.OrdinalIgnoreCase));
                        }
                    }
                    return(a1.Order - a2.Order);
                }

                return(0);
            });

            foreach (Type type in tests)
            {
                object[] attribs = type.GetCustomAttributes(typeof(UnitTestAttribute), false);
                if (attribs.Length > 0)
                {
                    UnitTestAttribute attrib = attribs[0] as UnitTestAttribute;
                    if (attrib != null)
                    {
                        CollapsibleCategory cat = m_List.FindChildByName(attrib.Category) as CollapsibleCategory;
                        if (cat == null)
                        {
                            cat = m_List.Add(attrib.Category, attrib.Category);
                        }
                        GUnit test = Activator.CreateInstance(type, m_Center) as GUnit;
                        RegisterUnitTest(attrib.Name != null ? attrib.Name : type.Name, cat, test);
                    }
                }
            }

            m_StatusBar.SendToBack();
            PrintText("Unit Test started!");
        }
示例#8
0
        public ListBox(ControlBase parent)
            : base(parent)
        {
            HorizontalLayout hlayout = new HorizontalLayout(this);

            hlayout.Dock = Dock.Top;

            {
                Control.ListBox ctrl = new Control.ListBox(hlayout);
                ctrl.AutoSizeToContent = true;
                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.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.SizeToContent();
            }

            {
                Control.ListBox ctrl = new Control.ListBox(hlayout);
                ctrl.AutoSizeToContent = true;
                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.AutoSizeToContent   = true;
                ctrl.HorizontalAlignment = HorizontalAlignment.Left;
                ctrl.ColumnCount         = 3;

                ctrl.SetColumnWidth(0, 150);
                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.AutoSizeToContent   = true;
                ctrl.HorizontalAlignment = HorizontalAlignment.Left;
                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");
            }

            hlayout      = new HorizontalLayout(this);
            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.Dock          = Dock.Top;
                multiline.Text          = "Enable MultiSelect";
                multiline.CheckChanged += delegate(ControlBase sender, EventArgs args)
                {
                    ctrl.AllowMultiSelect = multiline.IsChecked;
                };

                vlayout = new VerticalLayout(hlayout);
                //Select by Menu Item
                {
                    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.SelectByText("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);
                    };
                }
            }
        }
示例#9
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);
                    };
                }
            }
        }