コード例 #1
0
        private void tsbImportSphere_Click(object sender, EventArgs e)
        {
            string systemName;
            double radius;

            if (!ImportSphere.showDialog(_discoveryForm, out systemName, out radius))
            {
                return;
            }
            if (String.IsNullOrWhiteSpace(systemName))
            {
                EDDiscovery.Forms.MessageBoxTheme.Show("System name not set");
                return;
            }

            if (radius < 0 || radius > 1000.0)
            {
                EDDiscovery.Forms.MessageBoxTheme.Show("Radius should be a number 0.0 and 1000.0");
                return;
            }

            ClearExplorationSet();
            EDSMClass edsm = new EDSMClass();

            Cursor.Current = Cursors.WaitCursor;
            Task <List <String> > taskEDSM = Task <List <String> > .Factory.StartNew(() =>
            {
                return(edsm.GetSphereSystems(systemName, radius));
            });

            Task.WaitAll();
            LoadSphereData(taskEDSM);
            Cursor.Current = Cursors.Default;
        }
コード例 #2
0
        private void EDSMLookup(bool spherical)
        {
            if (numberBoxMaxRadius.Value > 100)
            {
                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), "This is a large radius, it make take a long time or not work, are you sure?", "Warning - Large radius", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.Cancel)
                {
                    return;
                }
            }

            Cursor = Cursors.WaitCursor;

            Task taskEDSM = Task <List <Tuple <ISystem, double> > > .Factory.StartNew(() =>
            {
                EDSMClass edsm = new EDSMClass();
                // cube: use *1.412 (sqrt(2)) to reach out to far corner of cube
                // cube: must get centre system, to know what co-ords it is..
                return(edsm.GetSphereSystems(textBoxSystemName.Text, numberBoxMaxRadius.Value * (spherical ? 1.00 : 1.412), spherical ? numberBoxMinRadius.Value : 0));
            }).ContinueWith(task => this.Invoke(new Action(() =>
            {
                List <Tuple <ISystem, double> > listsphere = task.Result;

                if (!spherical && listsphere != null)                           // if cubed, need to filter them out
                {
                    ISystem centre = listsphere.Find(x => x.Item2 <= 1)?.Item1; // find centre, i.e less 1 ly distance
                    if (centre != null)
                    {
                        //System.Diagnostics.Debug.WriteLine("From " + listsphere.Count());
                        //foreach (var x in listsphere) System.Diagnostics.Debug.WriteLine("<" + x.Item1.ToString());

                        double mindistsq = numberBoxMinRadius.Value * numberBoxMinRadius.Value;         // mindist is the square line distance, per stardistance use

                        listsphere = (from s in listsphere
                                      where
                                      (s.Item1.X - centre.X) * (s.Item1.X - centre.X) + (s.Item1.Y - centre.Y) * (s.Item1.Y - centre.Y) + (s.Item1.Z - centre.Z) * (s.Item1.Z - centre.Z) >= mindistsq &&
                                      Math.Abs(s.Item1.X - centre.X) <= numberBoxMaxRadius.Value &&
                                      Math.Abs(s.Item1.Y - centre.Y) <= numberBoxMaxRadius.Value &&
                                      Math.Abs(s.Item1.Z - centre.Z) <= numberBoxMaxRadius.Value
                                      select s).ToList();

                        //System.Diagnostics.Debug.WriteLine("To " + listsphere.Count());
                        //foreach (var x in listsphere) System.Diagnostics.Debug.WriteLine(">" + x.Item1.ToString());
                    }
                    else
                    {
                        listsphere = null;
                    }
                }

                if (listsphere == null)
                {
                    ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "EDSM did not return any data on " + textBoxSystemName.Text + Environment.NewLine + "It may be a galactic object that it does not know about", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                Cursor = Cursors.Default;
                ReturnSystems(listsphere);
            }
                                                           )));
        }
コード例 #3
0
        public void Execute(String systemName, double radius)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter   = "SphereSystems export| *.txt";
            dlg.Title    = TITLE;
            dlg.FileName = "SphereSystems.txt";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            String    fileName = dlg.FileName;
            EDSMClass edsm     = new EDSMClass();
            Task      taskEDSM = Task <List <String> > .Factory.StartNew(() =>
            {
                return(edsm.GetSphereSystems(systemName, radius));
            }).ContinueWith(task => ExportFile(task, fileName));
        }
コード例 #4
0
        private void buttonExtEDSMSphere_Click(object sender, EventArgs e)
        {
            double radius = textBoxRadius.Text.InvariantParseDouble(20);

            if (radius > 100)
            {
                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), "This is a large radius, it make take a long time or not work, are you sure?", "Warning - Large radius", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.Cancel)
                {
                    return;
                }
            }

            Cursor = Cursors.WaitCursor;

            Task taskEDSM = Task <List <Tuple <ISystem, double> > > .Factory.StartNew(() =>
            {
                EDSMClass edsm = new EDSMClass();
                return(edsm.GetSphereSystems(textBoxSystemName.Text, radius));
            }).ContinueWith(task => this.Invoke(new Action(() => { SphereGrid(task); })));
        }
コード例 #5
0
        private void buttonExtEDSMClick(object sender, EventArgs e)
        {
            if (numberBoxMaxRadius.Value > 100)
            {
                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), "This is a large radius, it make take a long time or not work, are you sure?", "Warning - Large radius", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.Cancel)
                {
                    return;
                }
            }

            Cursor = Cursors.WaitCursor;

            bool spherical = !checkBoxCustomCube.Checked;

            Task taskEDSM = Task <List <Tuple <ISystem, double> > > .Factory.StartNew(() =>
            {
                EDSMClass edsm = new EDSMClass();
                // cube: use *1.412 (sqrt(2)) to reach out to far corner of cube
                // cube: must get centre system, to know what co-ords it is..
                return(edsm.GetSphereSystems(textBoxSystemName.Text, numberBoxMaxRadius.Value * (spherical ? 1.00 : 1.412), spherical ? numberBoxMinRadius.Value : 0));
            }).ContinueWith(task => this.Invoke(new Action(() =>
            {
                List <Tuple <ISystem, double> > listsphere = task.Result;

                if (listsphere != null)
                {
                    bool excvisited = extCheckBoxExcludeVisitedSystems.Checked;

                    if (!spherical)                                                 // if cubed, need to filter them out
                    {
                        ISystem centre = listsphere.Find(x => x.Item2 <= 1)?.Item1; // find centre, i.e less 1 ly distance
                        if (centre != null)
                        {
                            //System.Diagnostics.Debug.WriteLine("From " + listsphere.Count());
                            //foreach (var x in listsphere) System.Diagnostics.Debug.WriteLine("<" + x.Item1.ToString());

                            double mindistsq = numberBoxMinRadius.Value * numberBoxMinRadius.Value;     // mindist is the square line distance, per stardistance use

                            listsphere = (from s in listsphere
                                          where
                                          (s.Item1.X - centre.X) * (s.Item1.X - centre.X) + (s.Item1.Y - centre.Y) * (s.Item1.Y - centre.Y) + (s.Item1.Z - centre.Z) * (s.Item1.Z - centre.Z) >= mindistsq &&
                                          Math.Abs(s.Item1.X - centre.X) <= numberBoxMaxRadius.Value &&
                                          Math.Abs(s.Item1.Y - centre.Y) <= numberBoxMaxRadius.Value &&
                                          Math.Abs(s.Item1.Z - centre.Z) <= numberBoxMaxRadius.Value &&
                                          (!excvisited || discoveryform.history.FindByName(s.Item1.Name) == null)
                                          select s).ToList();

                            //System.Diagnostics.Debug.WriteLine("To " + listsphere.Count());
                            //foreach (var x in listsphere) System.Diagnostics.Debug.WriteLine(">" + x.Item1.ToString());
                        }
                    }
                    else if (excvisited)    // if exc visited, need to filter them out
                    {
                        listsphere = (from s in listsphere
                                      where discoveryform.history.FindByName(s.Item1.Name) == null
                                      select s).ToList();
                    }
                }

                if (listsphere == null)
                {
                    string resp = String.Format("EDSM did not return any data on {0}\nIt may be a galactic object that it does not know about".T(EDTx.FindSystemsUserControl_EDSM), textBoxSystemName.Text);
                    ExtendedControls.MessageBoxTheme.Show(this.FindForm(), resp, "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                Cursor = Cursors.Default;
                ReturnSystems(listsphere);
            }
                                                           )));
        }