Exemplo n.º 1
0
        Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string name, CollapsibleCategory cat, Type exampleType, Example__Base example)
        {
            Alt.GUI.Temporary.Gwen.Control.Button btn = cat.Add(name);
            btn.UserData = new ExampleNode(exampleType, example, m_Center, this);
            btn.Clicked += OnExampleSelect;

            return(btn);
        }
Exemplo n.º 2
0
        Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string name, CollapsibleCategory cat, Type exampleType, Example__Base example, Color textColor)
        {
            Alt.GUI.Temporary.Gwen.Control.Button btn = RegisterDemo(name, cat, exampleType, example);
            btn.TextColor = textColor;
            btn.UseCurrentColorAsNormal = true;

            return(btn);
        }
 public void RegisterUnitTest(string name, CollapsibleCategory cat, GUnit test)
 {
     Control.Button btn = cat.Add(name);
     test.Dock = Pos.Fill;
     test.Hide();
     test.UnitTest = this;
     btn.UserData  = test;
     btn.Clicked  += OnCategorySelect;
 }
Exemplo n.º 4
0
        CollapsibleCategory AddCategory(string name, Color textColor)
        {
            CollapsibleCategory cat = m_ExamplesList.Add(name);

            cat.TextColor = textColor;
            cat.UseCurrentColorAsNormal = true;

            return(cat);
        }
Exemplo n.º 5
0
        private ControlBase AddPage(CollapsibleCategory category, string name)
        {
            var   btn   = category.Add(name);
            Panel panel = new Panel(this);

            panel.Dock = Dock.Fill;
            panel.Hide();
            btn.UserData       = panel;
            category.Selected += CategorySelected;
            return(panel);
        }
Exemplo n.º 6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            CollapsibleList control = new CollapsibleList(this);

            //control.ClientBackColor = Color.CornflowerBlue;
            control.SetSize(100, 200);
            control.SetPosition(10, 10);
            control.ItemSelected      += OnSelection;
            control.CategoryCollapsed += OnCollapsed;

            {
                CollapsibleCategory cat = control.Add("Category One");
                cat.TextColor = Color.LightGreen;
                cat.UseCurrentColorAsNormal = true;
                cat.Add("Hello");
                cat.Add("Two");
                cat.Add("Three");
                cat.Add("Four");
            }

            {
                CollapsibleCategory cat = control.Add("Shopping");
                cat.TextColor = Color.Yellow;
                cat.UseCurrentColorAsNormal = true;
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
            }

            {
                CollapsibleCategory cat = control.Add("Category Two");
                cat.TextColor = Color.Pink;
                cat.UseCurrentColorAsNormal = true;
                cat.Add("Hello 2");
                cat.Add("Two 2");
                cat.Add("Three 2");
                cat.Add("Four 2");
            }
        }
Exemplo n.º 7
0
        public void Shutdown()
        {
            foreach (Base b in m_ExamplesList.Children)
            {
                CollapsibleCategory cat = b as CollapsibleCategory;

                foreach (Base button in cat.Children)
                {
                    ExampleNode node = button.UserData as ExampleNode;

                    if (node != null &&
                        node.m_Example != null)
                    {
                        if (node.m_Example == m_LastControl)
                        {
                            node.m_Example = null;
                            continue;
                        }

                        try
                        {
                            node.m_Example.Dispose();
                            node.m_Example = null;
                        }
                        catch
                        {
                        }
                    }
                }
            }

            if (m_LastControl != null)
            {
                if (m_Center != null)
                {
                    m_Center.RemoveChild(m_LastControl, false);
                }

                try
                {
                    m_LastControl.Dispose();
                    m_LastControl = null;
                }
                catch
                {
                }
            }

            m_Center.Children.Clear();
        }
Exemplo n.º 8
0
        public CollapsibleListTest(ControlBase parent)
            : base(parent)
        {
            CollapsibleList control = new CollapsibleList(this);

            control.Dock = Net.Dock.Fill;
            control.HorizontalAlignment = Net.HorizontalAlignment.Left;
            control.ItemSelected       += OnSelection;
            control.CategoryCollapsed  += OnCollapsed;

            {
                CollapsibleCategory cat = control.Add("Category One");
                cat.Add("Hello");
                cat.Add("Two");
                cat.Add("Three");
                cat.Add("Four");
            }

            {
                CollapsibleCategory cat = control.Add("Shopping");
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
                cat.Add("Special");
                cat.Add("Two Noses");
                cat.Add("Orange ears");
                cat.Add("Beer");
                cat.Add("Three Eyes");
            }

            {
                CollapsibleCategory cat = control.Add("Category One");
                cat.Add("Hello");
                cat.Add("Two");
                cat.Add("Three");
                cat.Add("Four");
            }
        }
        private ControlBase AddPage(CollapsibleCategory category, string name)
        {
            var   btn   = category.Add(name);
            Panel panel = new Panel(this);

            panel.Dock    = Dock.Fill;
            panel.Padding = Padding.Five;
            panel.Hide();
            panel.UserData     = _tabscount;
            btn.UserData       = panel;
            category.Selected += CategorySelected;
            if (_tabscount == Settings.SettingsPane)
            {
                btn.Press();
            }
            _tabscount += 1;
            return(panel);
        }
Exemplo n.º 10
0
        internal Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string category, string caption, Type exampleType, Color categoryTextColor, Color captionTextColor)
        {
            CollapsibleCategory cat = null;

            foreach (Base b in m_ExamplesList.Children)
            {
                cat = b as CollapsibleCategory;
                if (cat != null &&
                    string.Equals(cat.Text, category))
                {
                    break;
                }

                cat = null;
            }

            if (cat == null)
            {
                cat = AddCategory(category, categoryTextColor);
            }

            return(RegisterDemo(caption, cat, exampleType, captionTextColor));
        }
Exemplo n.º 11
0
        public UnitTestHarnessControls(ControlBase parent) : base(parent)
        {
            Dock = Dock.Fill;

            DockBase dock = new DockBase(this);

            dock.Dock = Dock.Fill;

            m_List = new CollapsibleList(this);

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

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

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

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

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

            m_IncScale = new 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 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 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 Label(m_StatusBar);
            m_UIScaleText.VerticalAlignment = VerticalAlignment.Stretch;
            m_UIScaleText.Alignment         = Alignment.Left | Alignment.CenterV;
            m_UIScaleText.Text = "Scale:";

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

            List <Type> tests = typeof(UnitTestHarnessControls).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!");
        }
        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!");
        }
Exemplo n.º 13
0
 Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string name, CollapsibleCategory cat, Type exampleType)
 {
     return(RegisterDemo(name, cat, exampleType, null));
 }
Exemplo n.º 14
0
        void OnCollapsed(ControlBase control, EventArgs args)
        {
            CollapsibleCategory cat = control as CollapsibleCategory;

            UnitPrint(String.Format("CollapsibleCategory: CategoryCollapsed: {0} {1}", cat.Text, cat.IsCollapsed));
        }
Exemplo n.º 15
0
        public UnitTest(Base parent, bool showStatusBar) :
            base(parent)
        {
            Dock = Alt.GUI.Temporary.Gwen.Pos.Fill;
            //NoNeed    SetSize(1024, 768);

            m_List = new CollapsibleList(this);
            m_List.ShouldCacheToTexture = true;

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

            m_TextOutput = new Alt.GUI.Temporary.Gwen.Control.ListBox(BottomDock);
            m_TextOutput.ShouldCacheToTexture = true;

            m_Button = BottomDock.TabControl.AddPage("Output", m_TextOutput);
            m_Button.ShouldCacheToTexture = true;
            BottomDock.Height             = 120;

            m_StatusBar      = new Alt.GUI.Temporary.Gwen.Control.StatusBar(this);
            m_StatusBar.Dock = Alt.GUI.Temporary.Gwen.Pos.Bottom;
            //m_StatusBar.ShouldCacheToTexture = true;
            m_StatusBar.IsHidden = !showStatusBar;

            m_DebugCheck               = new Alt.GUI.Temporary.Gwen.Control.LabeledCheckBox(m_StatusBar);
            m_DebugCheck.Text          = "Debug outlines";
            m_DebugCheck.CheckChanged += DebugCheckChanged;
            m_StatusBar.AddControl(m_DebugCheck, true);

            m_Center      = new Center(this);
            m_Center.Dock = Alt.GUI.Temporary.Gwen.Pos.Fill;
            GUnit test;

            bool cat_ShouldCacheToTexture = false;

            {
                CollapsibleCategory cat = m_List.Add("Non-Interactive");
                {
                    test = new GUnit_Label(m_Center);
                    RegisterUnitTest("Label", cat, test);
                    test = new GUnit_RichLabel(m_Center);
                    RegisterUnitTest("RichLabel", cat, test);
                    test = new GUnit_GroupBox(m_Center);
                    RegisterUnitTest("GroupBox", cat, test);
                    test = new GUnit_ProgressBar(m_Center);
                    RegisterUnitTest("ProgressBar", cat, test);
                    test = new GUnit_ImagePanel(m_Center);
                    RegisterUnitTest("ImagePanel", cat, test);
                    test = new GUnit_StatusBar(m_Center);
                    RegisterUnitTest("StatusBar", cat, test);
                }
                cat.ShouldCacheToTexture = cat_ShouldCacheToTexture;
            }

            {
                CollapsibleCategory cat = m_List.Add("Standard");
                {
                    test = new GUnit_Button(m_Center);
                    RegisterUnitTest("Button", cat, test);
                    test = new GUnit_TextBox(m_Center);
                    RegisterUnitTest("TextBox", cat, test);
                    test = new GUnit_CheckBox(m_Center);
                    RegisterUnitTest("CheckBox", cat, test);
                    test = new GUnit_RadioButton(m_Center);
                    RegisterUnitTest("RadioButton", cat, test);
                    test = new GUnit_ComboBox(m_Center);
                    RegisterUnitTest("ComboBox", cat, test);
                    test = new GUnit_ListBox(m_Center);
                    RegisterUnitTest("ListBox", cat, test);
                    test = new GUnit_NumericUpDown(m_Center);
                    RegisterUnitTest("NumericUpDown", cat, test);
                    test = new GUnit_Slider(m_Center);
                    RegisterUnitTest("Slider", cat, test);
                    test = new GUnit_MenuStrip(m_Center);
                    RegisterUnitTest("MenuStrip", cat, test);
                    test = new GUnit_CrossSplitter(m_Center);
                    RegisterUnitTest("CrossSplitter", cat, test);
                }
                cat.ShouldCacheToTexture = cat_ShouldCacheToTexture;
            }

            {
                CollapsibleCategory cat = m_List.Add("Containers");
                {
                    test = new GUnit_Window(m_Center);
                    RegisterUnitTest("Window", cat, test);
                    test = new GUnit_TreeControl(m_Center);
                    RegisterUnitTest("TreeControl", cat, test);
                    test = new GUnit_Properties(m_Center);
                    RegisterUnitTest("Properties", cat, test);
                    test = new GUnit_TabControl(m_Center);
                    RegisterUnitTest("TabControl", cat, test);
                    test = new GUnit_ScrollControl(m_Center);
                    RegisterUnitTest("ScrollControl", cat, test);
                    test = new GUnit_Docking(m_Center);
                    RegisterUnitTest("Docking", cat, test);
                }
                cat.ShouldCacheToTexture = cat_ShouldCacheToTexture;
            }

            {
                CollapsibleCategory cat = m_List.Add("Non-standard");
                {
                    test = new GUnit_CollapsibleList(m_Center);
                    RegisterUnitTest("CollapsibleList", cat, test);
                    test = new GUnit_ColorPickers(m_Center);
                    RegisterUnitTest("Color pickers", cat, test);
                    test = new GUnit_PictureBox(m_Center);
                    RegisterUnitTest("PictureBox", cat, test);
                }
                cat.ShouldCacheToTexture = cat_ShouldCacheToTexture;
            }

            m_StatusBar.SendToBack();
            PrintText("AltGUI.Temporary.Gwen Unit Test started!");
        }