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 RoutingThread(object _plotter) { RoutePlotter p = (RoutePlotter)_plotter; routeSystems = null; // so its null until route interative finishes routeSystems = p.RouteIterative(AppendData); this.BeginInvoke(new Action(() => { discoveryform.NewCalculatedRoute(routeSystems); ToggleButtons(true); })); }
private void button_Route_Click(object sender, EventArgs e) { if (routingthread == null || !routingthread.IsAlive) { plotter = new RoutePlotter(); plotter.MaxRange = textBox_Range.Value; GetCoordsFrom(out plotter.Coordsfrom); // will be valid for a system or a co-ords box GetCoordsTo(out plotter.Coordsto); plotter.FromSystem = textBox_From.Text; plotter.ToSystem = textBox_To.Text; plotter.RouteMethod = (SystemsDB.SystemsNearestMetric)comboBoxRoutingMetric.SelectedIndex; plotter.UseFsdBoost = checkBox_FsdBoost.Checked; if (textBox_From.ReadOnly == true) { plotter.FromSystem = "START POINT"; } if (textBox_To.ReadOnly == true) { plotter.ToSystem = "END POINT"; } int PossibleJumps = (int)(Point3D.DistanceBetween(plotter.Coordsfrom, plotter.Coordsto) / plotter.MaxRange); if (PossibleJumps > 100) { DialogResult res = ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format(("This will result in a large number ({0}) of jumps" + Environment.NewLine + "Confirm please").T(EDTx.UserControlRoute_Confirm), PossibleJumps), "Warning".T(EDTx.Warning), MessageBoxButtons.YesNo); if (res != System.Windows.Forms.DialogResult.Yes) { return; } } dataGridViewRoute.Rows.Clear(); routingthread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(RoutingThread)); routingthread.Name = "Thread Route"; cmd3DMap.Enabled = false; button_Route.Text = "Cancel".T(EDTx.Cancel); routingthread.Start(plotter); } else { plotter.StopPlotter = true; button_Route.Enabled = false; } }
private void RoutingThread(object _plotter) { RoutePlotter p = (RoutePlotter)_plotter; routeSystems = null; // so its null until route interative finishes routeSystems = p.RouteIterative(AppendData); this.BeginInvoke(new Action(() => { discoveryform.NewCalculatedRoute(routeSystems); cmd3DMap.Enabled = true; button_Route.Text = "Find Route".Tx(this, "button_Route"); button_Route.Enabled = true; })); }
private void button_Route_Click(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. RoutePlotter plotter = CreateRoutePlotter(); if (plotter.possiblejumps > 100) { DialogResult res = ExtendedControls.MessageBoxTheme.Show(FindForm(), "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; } } dataGridViewRoute.Rows.Clear(); ThreadRoute = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(RouteMain)); ThreadRoute.Name = "Thread Route"; ThreadRoute.Start(plotter); }
private void button_Route_Click(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. plotter = new RoutePlotter(); plotter.MaxRange = textBox_Range.Value; GetCoordsFrom(out plotter.Coordsfrom); // will be valid for a system or a co-ords box GetCoordsTo(out plotter.Coordsto); plotter.FromSystem = textBox_From.Text; plotter.ToSystem = textBox_To.Text; plotter.RouteMethod = comboBoxRoutingMetric.SelectedIndex; if (textBox_From.ReadOnly == true) { plotter.FromSystem = "START POINT"; } if (textBox_To.ReadOnly == true) { plotter.ToSystem = "END POINT"; } int PossibleJumps = (int)(Point3D.DistanceBetween(plotter.Coordsfrom, plotter.Coordsto) / plotter.MaxRange); if (PossibleJumps > 100) { DialogResult res = ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format(("This will result in a large number ({0}) of jumps" + Environment.NewLine + "Confirm please").Tx(this, "Confirm"), PossibleJumps), "Warning".Tx(), MessageBoxButtons.YesNo); if (res != System.Windows.Forms.DialogResult.Yes) { ToggleButtons(true); return; } } dataGridViewRoute.Rows.Clear(); routingthread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(RoutingThread)); routingthread.Name = "Thread Route"; routingthread.Start(plotter); }