示例#1
0
        public void LoadExample(ExampleAndDesc exAndDesc, DemoBase exBase)
        {
            _exampleBase = exBase;
            this.Text    = exAndDesc.ToString();
            //-------------------------------------------
            //description:
            if (!string.IsNullOrEmpty(exAndDesc.Description))
            {
                TextBox tt = new TextBox();
                tt.Width      = this.flowLayoutPanel1.Width - 5;
                tt.Text       = exAndDesc.Description;
                tt.Multiline  = true;
                tt.ScrollBars = ScrollBars.Vertical;
                tt.Height     = 250;
                tt.BackColor  = Color.Gainsboro;
                tt.Font       = new Font("tahoma", 10);
                this.flowLayoutPanel1.Controls.Add(tt);
            }
            //-------------------------------------------
            _allConfigs.Clear();

            _mainConfigs                    = new ExampleConfigs();
            _mainConfigs._configList        = exAndDesc.GetConfigList();
            _mainConfigs._exampleActionList = exAndDesc.GetActionList();
            _allConfigs.Add(_mainConfigs);

            CreateConfigPresentation(_exampleBase, _mainConfigs, this.flowLayoutPanel1);

            ////--------------------
            var _groupConfigs = exAndDesc.GetGroupConfigList();

            if (_groupConfigs != null)
            {
                int j = _groupConfigs.Count;
                for (int i = 0; i < j; ++i)
                {
                    ExampleGroupConfigDesc groupConfig = _groupConfigs[i];
                    object groupOwner = groupConfig.OwnerProperty.GetGetMethod().Invoke(_exampleBase, null);

                    var subConfig = new ExampleConfigs();

                    subConfig._configList        = groupConfig._configList;
                    subConfig._exampleActionList = groupConfig._configActionList;
                    _allConfigs.Add(subConfig);
                    //
                    Panel subPanel = new Panel();
                    subPanel.Width  = flowLayoutPanel1.Width;
                    subPanel.Height = 300;//example
                    flowLayoutPanel1.Controls.Add(subPanel);

                    CreateConfigPresentation(groupOwner, subConfig, subPanel);
                }
            }
        }
示例#2
0
        public void LoadExample(ExampleAndDesc exAndDesc)
        {
            DemoBase exBase = Activator.CreateInstance(exAndDesc.Type) as DemoBase;

            if (exBase == null)
            {
                return;
            }

            this.Text = exAndDesc.ToString();
            //----------------------------------------------------------------------------
            this.exampleBase = exBase;
            exampleBase.Init();
        }
示例#3
0
        public void LoadExample(ExampleAndDesc exAndDesc)
        {
            DemoBase exBase = Activator.CreateInstance(exAndDesc.Type) as DemoBase;

            if (exBase == null)
            {
                return;
            }

            this.exampleBase = exBase;
            exampleBase.Init();
            this.softAggControl2.LoadExample(exampleBase);
            this.Text = exAndDesc.ToString();
            //-------------------------------------------
            //description:
            if (!string.IsNullOrEmpty(exAndDesc.Description))
            {
                TextBox tt = new TextBox();
                tt.Width      = this.flowLayoutPanel1.Width - 5;
                tt.Text       = exAndDesc.Description;
                tt.Multiline  = true;
                tt.ScrollBars = ScrollBars.Vertical;
                tt.Height     = 250;
                tt.BackColor  = Color.Gainsboro;
                tt.Font       = new Font("tahoma", 10);
                this.flowLayoutPanel1.Controls.Add(tt);
            }
            //-------------------------------------------
            this.configList = exAndDesc.GetConfigList();
            if (configList != null)
            {
                int j = configList.Count;
                for (int i = 0; i < j; ++i)
                {
                    ExampleConfigDesc config = configList[i];
                    switch (config.PresentaionHint)
                    {
                    case DemoConfigPresentaionHint.CheckBox:
                    {
                        CheckBox checkBox = new CheckBox();
                        checkBox.Text  = config.Name;
                        checkBox.Width = 400;
                        bool currentValue = (bool)config.InvokeGet(exampleBase);
                        checkBox.Checked         = currentValue;
                        checkBox.CheckedChanged += (s, e) =>
                        {
                            config.InvokeSet(exBase, checkBox.Checked);
                            InvalidateSampleViewPort();
                        };
                        this.flowLayoutPanel1.Controls.Add(checkBox);
                    }
                    break;

                    case DemoConfigPresentaionHint.SlideBarDiscrete:
                    {
                        Label descLabel = new Label();
                        descLabel.Width = 400;
                        this.flowLayoutPanel1.Controls.Add(descLabel);
                        var        originalConfig = config.OriginalConfigAttribute;
                        HScrollBar hscrollBar     = new HScrollBar();
                        hscrollBar.Width       = flowLayoutPanel1.Width;
                        hscrollBar.Minimum     = originalConfig.MinValue;
                        hscrollBar.Maximum     = originalConfig.MaxValue + 10;
                        hscrollBar.SmallChange = 1;
                        //current value
                        int value = (int)config.InvokeGet(exampleBase);
                        hscrollBar.Value = value;
                        //-------------
                        descLabel.Text           = config.Name + ":" + hscrollBar.Value;
                        hscrollBar.ValueChanged += (s, e) =>
                        {
                            config.InvokeSet(exampleBase, hscrollBar.Value);
                            descLabel.Text = config.Name + ":" + hscrollBar.Value;
                            InvalidateSampleViewPort();
                        };
                        this.flowLayoutPanel1.Controls.Add(hscrollBar);
                    }
                    break;

                    case DemoConfigPresentaionHint.SlideBarContinuous_R4:
                    {
                        Label descLabel = new Label();
                        descLabel.Width = 400;
                        this.flowLayoutPanel1.Controls.Add(descLabel);
                        var        originalConfig = config.OriginalConfigAttribute;
                        HScrollBar hscrollBar     = new HScrollBar();
                        //100 => for scale factor

                        hscrollBar.Width       = flowLayoutPanel1.Width;
                        hscrollBar.Minimum     = originalConfig.MinValue * 100;
                        hscrollBar.Maximum     = (originalConfig.MaxValue * 100) + 10;
                        hscrollBar.SmallChange = 1;
                        //current value

                        float doubleValue = ((float)config.InvokeGet(exampleBase) * 100);
                        hscrollBar.Value = (int)doubleValue;
                        //-------------
                        descLabel.Text           = config.Name + ":" + ((float)hscrollBar.Value / 100d).ToString();
                        hscrollBar.ValueChanged += (s, e) =>
                        {
                            float value = (float)(hscrollBar.Value / 100f);
                            config.InvokeSet(exampleBase, value);
                            descLabel.Text = config.Name + ":" + value.ToString();
                            InvalidateSampleViewPort();
                        };
                        this.flowLayoutPanel1.Controls.Add(hscrollBar);
                    }
                    break;

                    case DemoConfigPresentaionHint.SlideBarContinuous_R8:
                    {
                        Label descLabel = new Label();
                        descLabel.Width = 400;
                        this.flowLayoutPanel1.Controls.Add(descLabel);
                        var        originalConfig = config.OriginalConfigAttribute;
                        HScrollBar hscrollBar     = new HScrollBar();
                        //100 => for scale factor

                        hscrollBar.Width       = flowLayoutPanel1.Width;
                        hscrollBar.Minimum     = originalConfig.MinValue * 100;
                        hscrollBar.Maximum     = (originalConfig.MaxValue * 100) + 10;
                        hscrollBar.SmallChange = 1;
                        //current value

                        double doubleValue = ((double)config.InvokeGet(exampleBase) * 100);
                        hscrollBar.Value = (int)doubleValue;
                        //-------------
                        descLabel.Text           = config.Name + ":" + ((double)hscrollBar.Value / 100d).ToString();
                        hscrollBar.ValueChanged += (s, e) =>
                        {
                            double value = (double)hscrollBar.Value / 100d;
                            config.InvokeSet(exampleBase, value);
                            descLabel.Text = config.Name + ":" + value.ToString();
                            InvalidateSampleViewPort();
                        };
                        this.flowLayoutPanel1.Controls.Add(hscrollBar);
                    }
                    break;

                    case DemoConfigPresentaionHint.OptionBoxes:
                    {
                        List <ExampleConfigValue> optionFields = config.GetOptionFields();
                        FlowLayoutPanel           panelOption  = new FlowLayoutPanel();
                        int totalHeight = 0;
                        int m           = optionFields.Count;
                        //current value
                        int currentValue = (int)config.InvokeGet(exampleBase);
                        for (int n = 0; n < m; ++n)
                        {
                            ExampleConfigValue ofield = optionFields[n];
                            RadioButton        radio  = new RadioButton();
                            panelOption.Controls.Add(radio);
                            radio.Text    = ofield.Name;
                            radio.Width   = 400;
                            radio.Checked = ofield.ValueAsInt32 == currentValue;
                            radio.Click  += (s, e) =>
                            {
                                if (radio.Checked)
                                {
                                    ofield.InvokeSet(this.exampleBase);
                                    InvalidateSampleViewPort();
                                }
                            };
                            totalHeight += radio.Height + 10;
                        }



                        panelOption.Height        = totalHeight;
                        panelOption.FlowDirection = FlowDirection.TopDown;
                        this.flowLayoutPanel1.Controls.Add(panelOption);
                    }
                    break;

                    case DemoConfigPresentaionHint.TextBox:
                    {
                        Label descLabel = new Label();
                        descLabel.Width = 400;
                        descLabel.Text  = config.Name;
                        this.flowLayoutPanel1.Controls.Add(descLabel);
                        TextBox textBox = new TextBox();
                        textBox.Width = 400;
                        this.flowLayoutPanel1.Controls.Add(textBox);
                    }
                    break;
                    }
                }
            }
        }
示例#4
0
        void listBox1_DoubleClick(object sender, EventArgs e)
        {
            //load sample form
            ExampleAndDesc exAndDesc = this.listBox1.SelectedItem as ExampleAndDesc;

            if (exAndDesc == null)
            {
                return; //early exit
            }
            //
            //
            switch ((RenderBackendChoice)lstBackEndRenderer.SelectedItem)
            {
            case RenderBackendChoice.PureAgg:
            {
                FormTestBed testBed = new FormTestBed();
                testBed.WindowState      = FormWindowState.Maximized;
                testBed.UseGdiPlusOutput = false;
                testBed.UseGdiAntiAlias  = chkGdiAntiAlias.Checked;
                testBed.Show();
                testBed.LoadExample(exAndDesc);
            }
            break;

            case RenderBackendChoice.GdiPlus:
            {
                FormTestBed testBed = new FormTestBed();
                testBed.WindowState      = FormWindowState.Maximized;
                testBed.UseGdiPlusOutput = true;
                testBed.UseGdiAntiAlias  = chkGdiAntiAlias.Checked;
                testBed.Show();
                testBed.LoadExample(exAndDesc);
            }
            break;

            case RenderBackendChoice.OpenGLES2:
            {
                //create demo
                DemoBase exBase = Activator.CreateInstance(exAndDesc.Type) as DemoBase;
                if (exBase == null)
                {
                    return;
                }

                //create form
                FormGLTest formGLTest = new FormGLTest();
                formGLTest.Text = exAndDesc.ToString();
                formGLTest.Show();
                //----------------------
                //get target control that used to present the example
                OpenTK.MyGLControl control = formGLTest.InitMiniGLControl(800, 600);

                {
                    GLDemoContextWinForm glbaseDemo = new GLDemoContextWinForm();
                    glbaseDemo.LoadGLControl(control);
                    glbaseDemo.LoadSample(exBase);
                    //----------------------
                    formGLTest.FormClosing += (s2, e2) =>
                    {
                        glbaseDemo.CloseDemo();
                    };
                }
                //{
                //    //test another example
                //    DemoBase exBase2 = Activator.CreateInstance(exAndDesc.Type) as DemoBase;
                //    OpenTK.MyGLControl control2 = formGLTest.InitMiniGLControl2(400, 300);
                //    GLDemoContextWinForm glbaseDemo = new GLDemoContextWinForm();
                //    glbaseDemo.LoadGLControl(control2);
                //    glbaseDemo.LoadSample(exBase2);
                //    //----------------------
                //    formGLTest.FormClosing += (s2, e2) =>
                //    {
                //        glbaseDemo.CloseDemo();
                //    };
                //}


                formGLTest.WindowState = FormWindowState.Maximized;
            }
            break;

#if SKIA_ENABLE
            case RenderBackendChoice.SkiaMemoryBackend:
            {
                TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1();
                formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.Memory);
                formSkia.Show();
                formSkia.LoadExample(exAndDesc);
            }
            break;

            case RenderBackendChoice.SkiaGLBackend:
            {
                TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1();
                formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.GLES);
                formSkia.Show();
                formSkia.LoadExample(exAndDesc);
            }
            break;
#endif
            default:
                throw new NotSupportedException();
            }
        }