public void Run() { var assembly = typeof(Sample).GetTypeInfo().Assembly; using (Stream stream = assembly.GetManifestResourceStream("GwenNetLua.Sample.Lua.Sample.lua")) { DynValue result = Run("GwenNetLua.Sample.Lua.Sample.lua", stream); if (result.Type == DataType.UserData) { Control.ListBox textOutput = result.UserData.Object as Control.ListBox; if (textOutput != null) { script.Options.DebugPrint = t => { textOutput.AddRow(t); textOutput.ScrollToBottom(); } } ; } } foreach (var res in assembly.GetManifestResourceNames()) { if (res != "GwenNetLua.Sample.Lua.Sample.lua" && res.Contains(".lua")) { using (Stream stream = assembly.GetManifestResourceStream(res)) { Run(res, stream); } } } }
public void PrintText(string str) { m_TextOutput.AddRow(str); m_TextOutput.ScrollToBottom(); }
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); } }
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); }; } } }
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); }; } } }
public ListBox(ZGE.Components.ZComponent 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); } }
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); }; } } }
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); }; } } }