private RoutePlotter CreateRoutePlotter() { RoutePlotter p = new RoutePlotter(); string maxrangetext = textBox_Range.Text; if (!float.TryParse(maxrangetext, out p.maxrange)) { p.maxrange = 30; } p.usingcoordsfrom = textBox_From.ReadOnly == true; p.usingcoordsto = textBox_To.ReadOnly == true; GetCoordsFrom(out p.coordsfrom); // will be valid for a system or a co-ords box GetCoordsTo(out p.coordsto); p.fromsys = textBox_From.Text; p.tosys = textBox_To.Text; p.routemethod = comboBoxRoutingMetric.SelectedIndex; if (p.usingcoordsfrom) { p.fromsys = "START POINT"; } if (p.usingcoordsto) { p.tosys = "END POINT"; } p.possiblejumps = (int)(Point3D.DistanceBetween(p.coordsfrom, p.coordsto) / p.maxrange); return(p); }
private void RouteMain(object _plotter) { RoutePlotter p = (RoutePlotter)_plotter; routeSystems = p.RouteIterative(AppendText); this.BeginInvoke(new Action(() => ToggleButtons(true))); }
private void button_Route_Click_1(object sender, EventArgs e) { ToggleButtons(false); // beware the tab order, this moves the focus onto the next control, which in this dialog can be not what we want. richTextBox_routeresult.Clear(); RoutePlotter plotter = CreateRoutePlotter(); if (plotter.possiblejumps > 100) { DialogResult res = ExtendedControls.MessageBoxTheme.Show(_discoveryForm, "This will result in a large number (" + plotter.possiblejumps.ToString("0") + ") of jumps" + Environment.NewLine + Environment.NewLine + "Confirm please", "Confirm you want to compute", MessageBoxButtons.YesNo); if (res != System.Windows.Forms.DialogResult.Yes) { ToggleButtons(true); return; } } ThreadRoute = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(RouteMain)); ThreadRoute.Name = "Thread Route"; ThreadRoute.Start(plotter); }