void DevForm_Load(object sender, EventArgs e) { //load examples Type[] allTypes = this.GetType().Assembly.GetTypes(); Type exBase = typeof(Mini.DemoBase); int j = allTypes.Length; List <ExampleAndDesc> exlist = new List <ExampleAndDesc>(); for (int i = 0; i < j; ++i) { Type t = allTypes[i]; if (exBase.IsAssignableFrom(t) && t != exBase) { ExampleAndDesc ex = new ExampleAndDesc(t, t.Name); exlist.Add(ex); } } //------- exlist.Sort((ex1, ex2) => { return(ex1.OrderCode.CompareTo(ex2.OrderCode)); }); this.listBox1.Items.Clear(); j = exlist.Count; for (int i = 0; i < j; ++i) { this.listBox1.Items.Add(exlist[i]); } }
static DemoBase InitDemo(ExampleAndDesc exampleAndDesc) { if (!(Activator.CreateInstance(exampleAndDesc.Type) is DemoBase exBase)) { return(null); } exBase.Init(); return(exBase); }
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); } } }
static DemoBase InitDemo(ExampleAndDesc exampleAndDesc) { DemoBase exBase = Activator.CreateInstance(exampleAndDesc.Type) as DemoBase; if (exBase == null) { return(null); } exBase.Init(); return(exBase); }
void listBox1_DoubleClick(object sender, EventArgs e) { //load sample form ExampleAndDesc exAndDesc = this.listBox1.SelectedItem as ExampleAndDesc; if (exAndDesc != null) { FormTestBed1 testBed = new FormTestBed1(); testBed.WindowState = FormWindowState.Maximized; testBed.Show(); testBed.LoadExample(exAndDesc); } }
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(); }
static void LoadSamplesFromAssembly(Type srcType, List <ExampleAndDesc> outputList) { //load examples Type[] allTypes = srcType.Assembly.GetTypes(); Type exBase = typeof(Mini.DemoBase); int j = allTypes.Length; for (int i = 0; i < j; ++i) { Type t = allTypes[i]; if (exBase.IsAssignableFrom(t) && t != exBase) { ExampleAndDesc ex = new ExampleAndDesc(t, t.Name); outputList.Add(ex); } } }
void listBox1_DoubleClick(object sender, EventArgs e) { //load sample form ExampleAndDesc exAndDesc = this.listBox1.SelectedItem as ExampleAndDesc; if (exAndDesc != null) { DemoBase exBase = Activator.CreateInstance(exAndDesc.Type) as DemoBase; if (exBase == null) { return; } exBase.Init(); //FormTestBed1 testBed = new FormTestBed1(); //testBed.WindowState = FormWindowState.Maximized; //testBed.Show(); //testBed.LoadExample(exAndDesc); } }
void lstExample_DoubleClick(object sender, EventArgs e) { //load sample form ExampleAndDesc exAndDesc = this.lstExamples.SelectedItem as ExampleAndDesc; if (exAndDesc == null) { return; //early exit } // DemoBase demo = InitDemo(exAndDesc); if (demo == null) { return; } FormTestBed formTestBed = new FormTestBed(); formTestBed.WindowState = FormWindowState.Maximized; RenderBackendChoice selItem = (RenderBackendChoice)lstBackEndRenderer.SelectedItem; CpuBlitAppModule cpuBlitContextWinForm = null; switch (selItem) { case RenderBackendChoice.PureAgg: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.PureAgg, out LayoutFarm.UI.UISurfaceViewportControl surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); formTestBed.Show(); cpuBlitContextWinForm = new CpuBlitAppModule(); cpuBlitContextWinForm.BindSurface(surfaceViewport); cpuBlitContextWinForm.LoadExample(demo); demo.RequestGraphicRefresh += (s, e1) => { surfaceViewport.Refresh(); }; formTestBed.FormClosed += (s1, e1) => cpuBlitContextWinForm.Close(); formTestBed.LoadExample(exAndDesc, demo); } break; case RenderBackendChoice.GdiPlus: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.GdiPlus, out LayoutFarm.UI.UISurfaceViewportControl surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); cpuBlitContextWinForm = new CpuBlitAppModule(); cpuBlitContextWinForm.BindSurface(surfaceViewport); cpuBlitContextWinForm.LoadExample(demo); formTestBed.FormClosed += (s1, e1) => cpuBlitContextWinForm.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } break; case RenderBackendChoice.OpenGLES: //gles 2 and 3 { //-------------------------------------------- LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.GLES, out LayoutFarm.UI.UISurfaceViewportControl surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); GLESAppModule appModule = new GLESAppModule(); appModule.BindSurface(surfaceViewport); appModule.LoadExample(demo); formTestBed.FormClosing += (s2, e2) => appModule.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } break; case RenderBackendChoice.AggOnGLES: case RenderBackendChoice.GdiPlusOnGLES: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.AggOnGLES, out LayoutFarm.UI.UISurfaceViewportControl surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); // CpuBlitOnGLESAppModule appModule = new CpuBlitOnGLESAppModule(); appModule.WithGdiPlusDrawBoard = (selItem == RenderBackendChoice.GdiPlusOnGLES); //** appModule.BindSurface(surfaceViewport); appModule.LoadExample(demo); formTestBed.FormClosing += (s2, e2) => appModule.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } 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(); } }
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; } } } }
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(); } }
void listBox1_DoubleClick(object sender, EventArgs e) { //load sample form ExampleAndDesc exAndDesc = this.listBox1.SelectedItem as ExampleAndDesc; if (exAndDesc != null) { switch ((RenderBackendChoice)cmbRenderBackend.SelectedItem) { case RenderBackendChoice.PureAgg: { FormTestBed1 testBed = new FormTestBed1(); testBed.WindowState = FormWindowState.Maximized; testBed.UseGdiPlusOutput = false; testBed.UseGdiAntiAlias = chkGdiAntiAlias.Checked; testBed.Show(); testBed.LoadExample(exAndDesc); } break; case RenderBackendChoice.GdiPlus: { FormTestBed1 testBed = new FormTestBed1(); testBed.WindowState = FormWindowState.Maximized; testBed.UseGdiPlusOutput = true; testBed.UseGdiAntiAlias = chkGdiAntiAlias.Checked; testBed.Show(); testBed.LoadExample(exAndDesc); } break; case RenderBackendChoice.OpenGLES2: { FormGLTest formGLTest = new FormGLTest(); formGLTest.InitGLControl(); formGLTest.Show(); formGLTest.WindowState = FormWindowState.Maximized; formGLTest.LoadExample(exAndDesc); } break; 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; default: throw new NotSupportedException(); } } }