Example #1
0
        private void UpdateTo(bool updatename)
        {
            changesilence = true;

            if (textBox_To.ReadOnly == false)                // if entering system name..
            {
                EDDiscovery2.DB.ISystem ds1 = SystemClass.GetSystem(SystemNameOnly(textBox_To.Text));

                if (ds1 != null)
                {
                    if (updatename)                          // can't fix it as you type.. so leave alone
                    {
                        textBox_To.Text = ds1.name;
                    }

                    textBox_ToX.Text = ds1.x.ToString("0.00");
                    textBox_ToY.Text = ds1.y.ToString("0.00");
                    textBox_ToZ.Text = ds1.z.ToString("0.00");
                }
                else
                {
                    textBox_ToX.Text = textBox_ToY.Text = textBox_ToZ.Text = "";
                }
            }
            else // Co-ords..
            {
                string  res = "";
                Point3D curpos;
                if (GetCoordsTo(out curpos))
                {
                    ISystem nearest = SystemClass.FindNearestSystem(curpos.X, curpos.Y, curpos.Z);

                    if (nearest != null)
                    {
                        double distance = Point3D.DistanceBetween(curpos, new Point3D(nearest.x, nearest.y, nearest.z));
                        if (distance < 0.1)
                        {
                            res = nearest.name;
                        }
                        else
                        {
                            res = nearest.name + " @ " + distance.ToString("0.00") + "ly";
                        }
                    }
                }

                textBox_To.Text = res;
            }

            UpdateDistance();

            changesilence        = false;
            button_Route.Enabled = IsValid();
        }