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

            if (textBox_To.ReadOnly == false)                // if entering system name..
            {
                ISystem ds1 = discoveryform.history.FindSystem(SystemNameOnly(textBox_To.Text), discoveryform.galacticMapping);

                if (ds1 != null)
                {
                    if (updatename)                          // can't fix it as you type.. so leave alone
                    {
                        if (ds1 is GalacticMapSystem)
                        {
                            GalacticMapSystem gms = (GalacticMapSystem)ds1;
                            textBox_To.Text     = gms.GalMapObject.name;
                            textBox_ToName.Text = gms.name;
                        }
                        else
                        {
                            textBox_To.Text     = ds1.name;
                            textBox_ToName.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 = SystemClassDB.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;
                textBox_ToName.Text = res;
            }

            UpdateDistance();

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