public void previewUpdate() { { //ovpSettings.polyList.Clear(); lock (previewPoly) { ovpSettings.addPolygon(previewPoly.ToArray(), new Color(0, 0.5f, 0), 0.7f, false, 0); } viewport.updateViewport(); double progress = currentProgress / (double)numberOfCases; statusLine.Text = (progress * 100).ToString("#.##") + "% complete"; progressBar.Value = currentProgress; // * 100.0f; } }
private void addPolys() { ovpSettings.clear(); float r = 0.0f; PointF[] testPoly = new PointF[6]; testPoly[0] = new PointF(2.0f + r, 2.0f + r); testPoly[1] = new PointF(15.0f + r, 12.0f + r); testPoly[2] = new PointF(8.0f + r, 24.0f + r); testPoly[3] = new PointF(8.0f + r, 15.0f + r); testPoly[4] = new PointF(3.0f + r, 2.0f + r); testPoly[5] = new PointF(2.0f + r, 2.0f + r); PointF[] testPoly2 = new PointF[6]; testPoly2[0] = new PointF(12.0f + r, 2.0f + r); testPoly2[1] = new PointF(25.0f + r, 12.0f + r); testPoly2[2] = new PointF(18.0f + r, 24.0f + r); testPoly2[3] = new PointF(18.0f + r, 15.0f + r); testPoly2[4] = new PointF(13.0f + r, 2.0f + r); testPoly2[5] = new PointF(12.0f + r, 2.0f + r); ovpSettings.addPolygon(testPoly2, Color.FromArgb(0, 255, 255), 1.0f, true, 1); ovpSettings.addPolygon(testPoly, Color.FromArgb(255, 0, 0), 1.0f, true, 2); r = -30.0f; PointF[] testPolyF1 = new PointF[6]; testPolyF1[0] = new PointF(2.0f + r, 2.0f + r); testPolyF1[1] = new PointF(15.0f + r, 12.0f + r); testPolyF1[2] = new PointF(8.0f + r, 24.0f + r); testPolyF1[3] = new PointF(8.0f + r, 15.0f + r); testPolyF1[4] = new PointF(3.0f + r, 2.0f + r); testPolyF1[5] = new PointF(2.0f + r, 2.0f + r); PointF[] testPolyF2 = new PointF[6]; testPolyF2[0] = new PointF(12.0f + r, 2.0f + r); testPolyF2[1] = new PointF(25.0f + r, 12.0f + r); testPolyF2[2] = new PointF(18.0f + r, 24.0f + r); testPolyF2[3] = new PointF(18.0f + r, 15.0f + r); testPolyF2[4] = new PointF(13.0f + r, 2.0f + r); testPolyF2[5] = new PointF(12.0f + r, 2.0f + r); ovpSettings.addPolygon(testPolyF2, Color.FromArgb(0, 255, 255), 0.5f, false, 3); ovpSettings.addPolygon(testPolyF1, Color.FromArgb(255, 0, 0), 1.0f, false, 4); r = 30.0f; PointF[] testPolyBG1 = new PointF[6]; testPolyBG1[0] = new PointF(2.0f + r, 2.0f + r); testPolyBG1[1] = new PointF(15.0f + r, 12.0f + r); testPolyBG1[2] = new PointF(8.0f + r, 24.0f + r); testPolyBG1[3] = new PointF(8.0f + r, 15.0f + r); testPolyBG1[4] = new PointF(3.0f + r, 2.0f + r); testPolyBG1[5] = new PointF(2.0f + r, 2.0f + r); PointF[] testPolyBG2 = new PointF[6]; testPolyBG2[0] = new PointF(12.0f + r, 2.0f + r); testPolyBG2[1] = new PointF(25.0f + r, 12.0f + r); testPolyBG2[2] = new PointF(18.0f + r, 24.0f + r); testPolyBG2[3] = new PointF(18.0f + r, 15.0f + r); testPolyBG2[4] = new PointF(13.0f + r, 2.0f + r); testPolyBG2[5] = new PointF(12.0f + r, 2.0f + r); ovpSettings.addBGPolygon(testPolyBG2, Color.FromArgb(0, 255, 255), 1.0f, 3); ovpSettings.addBGPolygon(testPolyBG1, Color.FromArgb(255, 0, 0), 1.0f, 4); }
public MainForm() { myList = new List <ObservableCollection <string> > { new() { "First", "Second" } }; DataContext = new myStuff { entries = myList }; refPoly = new PointF[5]; refPoly[0] = new PointF(-50, 50); refPoly[1] = new PointF(50, 50); refPoly[2] = new PointF(50, -50); refPoly[3] = new PointF(-50, -50); refPoly[4] = refPoly[0]; drawingLock = new object(); MinimumSize = new Size(200, 200); updateSimUIMTFunc = updateSimUIMT_; configureProgressBarFunc = configureProgressBar_; numberOfCases = 25000; timer_interval = 10; ovpSettings = new OVPSettings(); ovp2Settings = new OVPSettings { zoomFactor = 3 }; Title = "My Eto Form"; /* * Test flags. * 0 : stamdard viewports in splitter test. * 1 : viewports in tabs (WPF has issues here due to the deferred evaluation; still need a better fix) * 3 : single viewport in panel, dropdown switches out the view settings. */ int mode = 0; switch (mode) { case 0: { viewport = new TestViewport(ref ovpSettings); viewport.Size = new Size(250, 250); viewport2 = new TestViewport(ref ovp2Settings); viewport2.Size = new Size(200, 200); Panel testing = new(); testing.Size = new Size(viewport.Width + viewport2.Width, viewport.Height); testing.Content = new Splitter { Orientation = Orientation.Horizontal, FixedPanel = SplitterFixedPanel.None, Panel1 = viewport, Panel2 = viewport2 }; Panel testing2 = new(); testing2.Content = new Splitter { Orientation = Orientation.Horizontal, FixedPanel = SplitterFixedPanel.None, Panel1 = statusLine, Panel2 = progressBar }; testComboBox_SelEntry = new Button(); testComboBox_SelEntry.Text = "Change"; testComboBox_SelEntry.Click += changeSelEntry; testComboBox = new DropDown(); testComboBox.DataContext = DataContext; testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]); testComboBox.SelectedIndex = 0; //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index); Panel testing3 = new(); testing3.Content = new Splitter { Orientation = Orientation.Horizontal, FixedPanel = SplitterFixedPanel.None, Panel1 = testComboBox_SelEntry, Panel2 = testComboBox }; Panel testing4 = new(); testing4.Content = new Splitter { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, Panel1 = testing3, Panel2 = testing }; Splitter mySplitter = new() { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, Panel1 = testing4, Panel2 = testing2 }; Content = mySplitter; break; } case 1: { TabControl tabControl_main = new(); tabControl_main.Size = new Size(300, 300); Content = tabControl_main; TabPage tab_0 = new(); tab_0.Text = "0"; tabControl_main.Pages.Add(tab_0); PixelLayout tabPage_0_content = new(); tabPage_0_content.Size = new Size(280, 280); TabPage tab_1 = new(); tab_1.Text = "1"; tabControl_main.Pages.Add(tab_1); PixelLayout tabPage_1_content = new(); tabPage_1_content.Size = new Size(280, 280); tab_1.Content = tabPage_1_content; TabPage tab_2 = new(); tab_2.Text = "2"; tabControl_main.Pages.Add(tab_2); viewport = new TestViewport(ref ovpSettings); viewport.Size = new Size(200, 200); tabPage_1_content.Add(viewport, 5, 5); viewport2 = new TestViewport(ref ovp2Settings); viewport2.Size = new Size(200, 200); tab_2.Content = viewport2; break; } case 2: { ovpSettings.addPolygon(refPoly, Color.FromArgb(0, 255, 0), 0.7f, false, 0); ovp2Settings.addPolygon(refPoly, Color.FromArgb(255, 0, 0), 0.7f, false, 0); vSettings = new OVPSettings(); viewport = new TestViewport(ref vSettings); viewport.Size = new Size(250, 250); Panel testing = new(); testing.Size = new Size(viewport.Width, viewport.Height); PixelLayout p = new(); p.Add(viewport, 0, 0); testing.Content = p; testComboBox_SelEntry = new Button(); testComboBox_SelEntry.Text = "Change"; testComboBox_SelEntry.Click += changeSelEntry; testComboBox = new DropDown(); testComboBox.DataContext = DataContext; testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]); testComboBox.SelectedIndex = 0; testComboBox.SelectedIndexChanged += adjustView_; //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index); Splitter testing3 = new() { Orientation = Orientation.Horizontal, FixedPanel = SplitterFixedPanel.None, Panel1 = testComboBox_SelEntry, Panel2 = testComboBox }; Splitter testing4 = new() { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, Panel1 = testing3, Panel2 = testing }; Splitter mySplitter = new() { Orientation = Orientation.Vertical, FixedPanel = SplitterFixedPanel.None, Panel1 = testing4, Panel2 = new Panel() }; Content = mySplitter; break; } } statusLine = new Label(); statusLine.Size = new Size(150, 11); statusLine.Text = "Hello world"; progressBar = new ProgressBar(); progressBar.Height = 15; progressBar.MaxValue = numberOfCases; // create a few commands that can be used for the menu and toolbar Command clickMe = new() { MenuText = "Run", ToolBarText = "Run" }; clickMe.Executed += runCases; Command abort = new() { MenuText = "Abort", ToolBarText = "Abort" }; abort.Executed += abortTheRun; Command adjustList = new() { MenuText = "Add to list", ToolBarText = "Add" }; if (mode != 3) { adjustList.Executed += adjustList_; } Command quitCommand = new() { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); Command aboutCommand = new() { MenuText = "About..." }; aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app..."); // create menu Menu = new MenuBar { Items = { // File submenu new ButtonMenuItem { Text = "&File", Items ={ clickMe } }, // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } }, // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } }, }, ApplicationItems = { // application (OS X) or file menu (others) new ButtonMenuItem { Text = "&Preferences..." }, }, QuitItem = quitCommand, AboutItem = aboutCommand }; // create toolbar ToolBar = new ToolBar { Items = { clickMe, abort, adjustList } }; //mySplitter.Panel1.SizeChanged += splitterSize; //mySplitter.Panel2.SizeChanged += splitterSize; } private void adjustView_(object sender, EventArgs e) { switch (testComboBox.SelectedIndex) { case 0: viewport.changeSettingsRef(ref ovpSettings); break; default: viewport.changeSettingsRef(ref ovp2Settings); break; } } private void adjustList_(object sender, EventArgs e) { myList[0].Add("Entry " + myList[0].Count.ToString(CultureInfo.InvariantCulture)); testComboBox.SelectedIndex = testComboBox.SelectedIndex switch { -1 => 0, _ => testComboBox.SelectedIndex }; if (testComboBox.SelectedIndex >= myList[0].Count) { testComboBox.SelectedIndex = myList[0].Count - 1; } // testComboBox.SelectedIndex = 1; } /* These shouldn't be necessary * protected override void OnWindowStateChanged(EventArgs e) * { * base.OnWindowStateChanged(e); * viewport.updateViewport(); * viewport.updateViewport(); * if (viewport2 != null) * { * viewport2.updateViewport(); * } * } * * void splitterSize(object sender, EventArgs e) * { * viewport.updateViewport(); * viewport.updateViewport(); * if (viewport2 != null) * { * viewport2.updateViewport(); * } * } * * protected override void OnSizeChanged(EventArgs e) * { * base.OnSizeChanged(e); * viewport.updateViewport(); * if (viewport2 != null) * { * viewport2.updateViewport(); * } * } * * protected override void OnShown(EventArgs e) * { * base.OnShown(e); * viewport.updateViewport(); * viewport.updateViewport(); * if (viewport2 != null) * { * viewport2.updateViewport(); * } * } */ } public static class RNG {