コード例 #1
0
ファイル: Sample.cs プロジェクト: kpalosaa/gwen-net-lua
        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);
                    }
                }
            }
        }
コード例 #2
0
 void RowUnSelected(Base control)
 {
     // todo: how to determine which one was unselected (store somewhere)
     // or pass row as the event param?
     Control.ListBox list = control as Control.ListBox;
     UnitPrint(String.Format("ListBox: OnRowUnselected"));
 }
コード例 #3
0
        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!");
        }
コード例 #4
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!");
        }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: ListBox.cs プロジェクト: slagusev/gwen-dotnet
        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);
                    };
                }
            }
        }
コード例 #7
0
 void RowSelected(Base control)
 {
     Control.ListBox list = control as Control.ListBox;
     UnitPrint(String.Format("ListBox: RowSelected: {0} [{1}]", list.SelectedRows.Last().Text, list[list.SelectedRowIndex].Text));
 }
コード例 #8
0
ファイル: ListBox.cs プロジェクト: Sprunth/gwen-dotnet
        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); };
                }
            }
        }
コード例 #9
0
ファイル: ListBox.cs プロジェクト: petya2164/ZsharpGameEditor
        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);
            }
        }
コード例 #10
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!");
        }
コード例 #11
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);
                    };
                }
            }
        }
コード例 #12
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);
                    };
                }
            }
        }