Пример #1
0
        public void UpdateGalObjects(ref List <IData3DSet> _datasets, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DSet dataset in _datasets)
            {
                TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                foreach (TexturedQuadData tqd in tqdc.BaseTextures)
                {
                    GalacticMapObject gmo = tqd.Tag as GalacticMapObject;
                    Debug.Assert(gmo != null);
                    PointData pd = (gmo.points.Count > 0) ? gmo.points[0] : null;     // lets be paranoid
                    Debug.Assert(pd != null);

                    int id = (int)tqd.Tag2;
                    if (id == 0)
                    {
                        tqd.UpdateVertices(pd, rotation, widthly, heightly);
                    }
                    else if (id == 1)
                    {
                        tqd.UpdateVertices(pd, rotation, (widthly / 10 * gmo.name.Length), (heightly / 3), 0, heightly * gmonameoff);
                    }
                    else
                    {
                        tqd.UpdateVertices(pd, rotation, widthly, heightly, 0, heightly * gmotargetoff);
                    }
                }
            }
        }
Пример #2
0
        public static ISystem FindSystem(List <VisitedSystemsClass> visitedSystems, GalacticMapping glist, string name)         // in system or name
        {
            EDDiscovery2.DB.ISystem ds1 = SystemClass.GetSystem(name);

            if (ds1 == null)
            {
                VisitedSystemsClass vs = VisitedSystemsClass.FindByName(visitedSystems, name);

                if (vs != null && vs.HasTravelCoordinates)
                {
                    ds1 = vs.curSystem;
                }
                else
                {
                    GalacticMapObject gmo = glist.Find(name, true, true);

                    if (gmo != null && gmo.points.Count > 0)
                    {
                        return(new SystemClass(gmo.name, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z));        // fudge it into a system
                    }
                }
            }

            return(ds1);
        }
Пример #3
0
        public void UpdateGalObjects(ref List <IData3DCollection> _datasets, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DCollection dataset in _datasets)
            {
                if (dataset is TexturedQuadDataCollection)
                {
                    TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                    foreach (TexturedQuadData tqd in tqdc.Primatives)
                    {
                        GalacticMapObject gmo = tqd.Tag as GalacticMapObject;
                        Debug.Assert(gmo != null);

                        if (gmo.Points.Count > 0)       // paranoia since its an external data source
                        {
                            int id = (int)tqd.Tag2;
                            if (id == 0)
                            {
                                tqd.UpdateVertices(gmo.Points[0].Convert(), rotation, widthly, heightly);
                            }
                            else if (id == 1)
                            {
                                tqd.UpdateVertices(gmo.Points[0].Convert(), rotation, (widthly / 10 * gmo.Name.Length), (heightly / 3), 0, heightly * gmonameoff);
                            }
                            else
                            {
                                tqd.UpdateVertices(gmo.Points[0].Convert(), rotation, widthly, heightly, 0, heightly * gmotargetoff);
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public static void setTargetSystem(Object sender, EDDiscoveryForm _discoveryForm, String sn, Boolean prompt)
        {
            Form senderForm = ((Control)sender)?.FindForm() ?? _discoveryForm;

            if (string.IsNullOrWhiteSpace(sn))
            {
                if (prompt && TargetClass.IsTargetSet())      // if prompting, and target is set, ask for delete
                {
                    if (ExtendedControls.MessageBoxTheme.Show(senderForm, "Confirm deletion of target", "Delete a target", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        TargetClass.ClearTarget();
                        _discoveryForm.NewTargetSet(sender);          // tells everyone who cares a new target was set
                    }
                }

                return;
            }

            ISystem sc         = _discoveryForm.history.FindSystem(sn);
            string  msgboxtext = null;

            if (sc != null && sc.HasCoordinate)
            {
                SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(sc.Name, sc.EDSMID);        // has it got a note?

                if (nc != null)
                {
                    TargetClass.SetTargetNotedSystem(sc.Name, nc.id, sc.X, sc.Y, sc.Z);
                    msgboxtext = "Target set on system with note " + sc.Name;
                }
                else
                {
                    BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sn);    // has it been bookmarked?

                    if (bk != null)
                    {
                        TargetClass.SetTargetBookmark(sc.Name, bk.id, bk.x, bk.y, bk.z);
                        msgboxtext = "Target set on bookmarked system " + sc.Name;
                    }
                    else
                    {
                        bool createbookmark = false;
                        if ((prompt && ExtendedControls.MessageBoxTheme.Show(senderForm, "Make a bookmark on " + sc.Name + " and set as target?", "Make Bookmark", MessageBoxButtons.OKCancel) == DialogResult.OK) || !prompt)
                        {
                            createbookmark = true;
                        }

                        if (createbookmark)
                        {
                            BookmarkClass newbk = GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, true, sn, sc.X, sc.Y, sc.Z, DateTime.Now, "");
                            TargetClass.SetTargetBookmark(sc.Name, newbk.id, newbk.x, newbk.y, newbk.z);
                        }
                    }
                }
            }
            else
            {
                if (sn.Length > 2 && sn.Substring(0, 2).Equals("G:"))
                {
                    sn = sn.Substring(2, sn.Length - 2);
                }

                GalacticMapObject gmo = _discoveryForm.galacticMapping.Find(sn, true, true);    // ignore if its off, find any part of string, find if disabled

                if (gmo != null)
                {
                    TargetClass.SetTargetGMO("G:" + gmo.name, gmo.id, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z);
                    msgboxtext = "Target set on galaxy object " + gmo.name;
                }
                else
                {
                    msgboxtext = "Unknown system, system is without co-ordinates or galaxy object not found";
                }
            }

            _discoveryForm.NewTargetSet(sender);          // tells everyone who cares a new target was set

            if (msgboxtext != null && prompt)
            {
                ExtendedControls.MessageBoxTheme.Show(senderForm, msgboxtext, "Create a target", MessageBoxButtons.OK);
            }
        }
Пример #5
0
        public void UpdateSelected(ref List <IData3DCollection> _datasets, ISystem selectedsystem, GalacticMapObject selectedgmo, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DCollection dataset in _datasets)
            {
                if (dataset is TexturedQuadDataCollection)
                {
                    TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                    foreach (TexturedQuadData tqd in tqdc.Primatives)
                    {
                        int id = (int)tqd.Tag;

                        if (id == 0)
                        {
                            tqd.UpdateVertices(new PointData(selectedsystem.X, selectedsystem.Y, selectedsystem.Z), rotation, widthly, heightly / 2, 0, heightly / 4 + heightly / 16);
                        }
                        else if (selectedgmo.Points.Count > 0)
                        {
                            long  gmotarget = TargetClass.GetTargetGMO();
                            float hoff      = (gmotarget == selectedgmo.ID) ? (heightly * gmoseltarget) : (heightly * gmoselonly);
                            tqd.UpdateVertices(selectedgmo.Points[0].Convert(), rotation, widthly, heightly / 2, 0, hoff);
                        }
                    }
                }
            }
        }
Пример #6
0
        public List <IData3DCollection> BuildSelected(ISystem centersystem, ISystem selectedsystem, GalacticMapObject selectedgmo, float widthly, float heightly, Vector3 rotation)
        {
            Bitmap selmark = SelectedMarker;

            if (centersystem != null)
            {
                var dataset = Data3DCollection <PointData> .Create("Center", CentredSystem, 5.0f);

                dataset.Add(new PointData(centersystem.X, centersystem.Y, centersystem.Z));
                _datasets.Add(dataset);
            }

            if (selectedsystem != null)
            {
                var datasetbks = Data3DCollection <TexturedQuadData> .Create("selstar", Color.White, 1f);

                TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, new PointData(selectedsystem.X, selectedsystem.Y, selectedsystem.Z), rotation, widthly, heightly / 2, 0, heightly / 4 + heightly / 16);
                newtexture.Tag = 0;
                datasetbks.Add(newtexture);
                _datasets.Add(datasetbks);
            }

            if (selectedgmo != null)
            {
                if (selectedgmo.Points.Count > 0)               // paranoia
                {
                    var datasetbks = Data3DCollection <TexturedQuadData> .Create("selgmo", Color.White, 1f);

                    long             gmotarget  = TargetClass.GetTargetGMO();
                    float            hoff       = (gmotarget == selectedgmo.ID) ? (heightly * gmoseltarget) : (heightly * gmoselonly);
                    TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, selectedgmo.Points[0].Convert(), rotation, widthly, heightly / 2, 0, hoff);
                    newtexture.Tag = 1;
                    datasetbks.Add(newtexture);
                    _datasets.Add(datasetbks);
                }
            }

            return(_datasets);
        }
Пример #7
0
        public List <IData3DCollection> AddGalMapObjectsToDataset(GalacticMapping galmap, Bitmap target, float widthly, float heightly, Vector3 rotation, bool namethem, Color textc, int gmosel)
        {
            var datasetbks = Data3DCollection <TexturedQuadData> .Create("galobj", Color.White, 1f);

            if (galmap != null && galmap.Loaded)
            {
                long gmotarget = TargetClass.GetTargetGMO();

                foreach (GalacticMapObject gmo in galmap.GalacticMapObjects)
                {
                    bool enabled = (gmosel & (1 << gmo.GalMapType.Index)) != 0;         // if selected
                    if (enabled && gmo.GalMapType.VisibleType.HasValue)
                    {
                        Bitmap touse = GalMapTypeIcons[gmo.GalMapType.VisibleType.Value] as Bitmap; // under our control, so must have it

                        if (touse != null && gmo.Points.Count > 0)                                  // if it has an image its a point object , and has co-ord
                        {
                            Vector3          pd          = gmo.Points[0].Convert();
                            string           tucachename = "GalMapType:" + gmo.GalMapType.TypeName;
                            TexturedQuadData tubasetex   = null;

                            if (_cachedTextures.ContainsKey(tucachename))
                            {
                                tubasetex = _cachedTextures[tucachename];
                            }
                            else
                            {
                                tubasetex = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly);
                                _cachedTextures[tucachename] = tubasetex;
                            }


                            TexturedQuadData newtexture = TexturedQuadData.FromBaseTexture(tubasetex, pd, rotation, widthly, heightly);
                            newtexture.Tag  = gmo;
                            newtexture.Tag2 = 0;
                            datasetbks.Add(newtexture);

                            if (gmo.ID == gmotarget)
                            {
                                TexturedQuadData ntag = TexturedQuadData.FromBitmap(target, pd, rotation, widthly, heightly, 0, heightly * gmotargetoff);
                                ntag.Tag  = gmo;
                                ntag.Tag2 = 2;
                                datasetbks.Add(ntag);
                            }
                        }
                    }
                }

                if (namethem)
                {
                    bool useaggregate = true;

                    if (useaggregate)
                    {
                        foreach (GalMapType t in GalMapType.GalTypes)
                        {
                            bool enabled = (gmosel & (1 << t.Index)) != 0;         // if selected
                            if (enabled)
                            {
                                Bitmap                  bmp      = null;
                                TexturedQuadData        nbasetex = null;
                                List <TexturedQuadData> ntex     = new List <TexturedQuadData>();

                                string ncachename = "GalMapNames:" + t.TypeName + textc.ToString();
                                if (_cachedBitmaps.ContainsKey(ncachename) && _cachedTextures.ContainsKey(ncachename))
                                {
                                    bmp      = _cachedBitmaps[ncachename];
                                    nbasetex = _cachedTextures[ncachename];
                                    ntex     = nbasetex.Children.ToList();
                                }
                                else
                                {
                                    List <GalacticMapObject> tgmos = galmap.GalacticMapObjects.Where(o => o.GalMapType.TypeName == t.TypeName && o.Points.Count > 0).ToList();

                                    float            maxheight = 32;
                                    List <Rectangle> bounds    = new List <Rectangle>();
                                    List <float>     widths    = new List <float>();

                                    Bitmap stringstarmeasurebitmap = new Bitmap(1, 1);
                                    using (Graphics g = Graphics.FromImage(stringstarmeasurebitmap))
                                    {
                                        foreach (GalacticMapObject gmo in tgmos)
                                        {
                                            SizeF sz = g.MeasureString(gmo.Name, gmostarfont);
                                            if (sz.Height > maxheight)
                                            {
                                                maxheight = sz.Height;
                                            }
                                            widths.Add(sz.Width);
                                        }
                                    }

                                    int textheight = (int)(maxheight + 4);

                                    int x = 0;
                                    int y = 0;

                                    foreach (float twidth in widths)
                                    {
                                        int w = (int)(twidth + 4);

                                        if ((w + x) > 1024)
                                        {
                                            x = 0;
                                            y = y + textheight;

                                            if (((y + textheight) % 1024) < (y % 1024))
                                            {
                                                y = y + ((1024 - y) % 1024);
                                            }
                                        }

                                        bounds.Add(new Rectangle(x, y, w, textheight));
                                        x = x + w;
                                    }

                                    y = y + textheight;

                                    bmp      = new Bitmap(1024, y);
                                    nbasetex = new TexturedQuadData(null, null, bmp);

                                    using (Graphics g = Graphics.FromImage(bmp))
                                    {
                                        for (int i = 0; i < tgmos.Count; i++)
                                        {
                                            GalacticMapObject gmo       = tgmos[i];
                                            string            cachename = gmo.Name + textc.ToString();
                                            Vector3           pd        = gmo.Points[0].Convert();
                                            Rectangle         clip      = bounds[i];
                                            Point             pos       = clip.Location;
                                            g.SetClip(clip);
                                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                                            using (Brush br = new SolidBrush(textc))
                                                g.DrawString(gmo.Name, gmostarfont, br, pos);
                                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;

                                            TexturedQuadData tex = TexturedQuadData.FromBaseTexture(nbasetex, pd, rotation, clip,
                                                                                                    (widthly / 10 * gmo.Name.Length),
                                                                                                    (heightly / 3),
                                                                                                    0, heightly * gmonameoff);
                                            tex.Tag  = gmo;
                                            tex.Tag2 = 1;
                                            _cachedTextures[cachename] = tex;
                                            ntex.Add(tex);
                                        }
                                    }

                                    _cachedBitmaps[ncachename]  = bmp;
                                    _cachedTextures[ncachename] = nbasetex;
                                }

                                foreach (TexturedQuadData tex in ntex)
                                {
                                    datasetbks.Add(tex);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (GalacticMapObject gmo in galmap.GalacticMapObjects)
                        {
                            bool enabled = (gmosel & (1 << gmo.GalMapType.Index)) != 0;         // if selected
                            if (enabled && gmo.Points.Count > 0)
                            {
                                Vector3 pd        = gmo.Points[0].Convert();
                                Bitmap  map       = null;
                                string  cachename = gmo.Name + textc.ToString();

                                if (_cachedBitmaps.ContainsKey(cachename))      // cache them, they take a long time to compute..
                                {
                                    map = _cachedBitmaps[cachename];
                                }
                                else
                                {
                                    map = DrawString(gmo.Name, textc, gmostarfont);
                                    _cachedBitmaps.Add(cachename, map);
                                }

                                TexturedQuadData ntext = TexturedQuadData.FromBitmap(map, pd, rotation,
                                                                                     (widthly / 10 * gmo.Name.Length),
                                                                                     (heightly / 3),
                                                                                     0, heightly * gmonameoff);
                                ntext.Tag  = gmo;
                                ntext.Tag2 = 1;
                                datasetbks.Add(ntext);
                            }
                        }
                    }
                }
            }

            _datasets.Add(datasetbks);

            return(_datasets);
        }
Пример #8
0
        public List <IData3DSet> BuildSelected(ISystem centersystem, ISystem selectedsystem, GalacticMapObject selectedgmo, float widthly, float heightly, Vector3 rotation)
        {
            Bitmap selmark = (Bitmap)EDDiscovery.Properties.Resources.selectedmarker;

            if (centersystem != null)
            {
                var dataset = Data3DSetClass <PointData> .Create("Center", MapColours.CentredSystem, 5.0f);

                dataset.Add(new PointData(centersystem.x, centersystem.y, centersystem.z));
                _datasets.Add(dataset);
            }

            if (selectedsystem != null)
            {
                var datasetbks = Data3DSetClass <TexturedQuadData> .Create("selstar", Color.White, 1f);

                TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, new PointData(selectedsystem.x, selectedsystem.y, selectedsystem.z), rotation, widthly, heightly / 2, 0, heightly / 4 + heightly / 16);
                newtexture.Tag = 0;
                datasetbks.Add(newtexture);
                _datasets.Add(datasetbks);
            }

            if (selectedgmo != null)
            {
                if (selectedgmo.points.Count > 0)               // paranoia
                {
                    var datasetbks = Data3DSetClass <TexturedQuadData> .Create("selgmo", Color.White, 1f);

                    long             gmotarget  = TargetClass.GetTargetGMO();
                    float            hoff       = (gmotarget == selectedgmo.id) ? (heightly * gmoseltarget) : (heightly * gmoselonly);
                    TexturedQuadData newtexture = TexturedQuadData.FromBitmap(selmark, selectedgmo.points[0], rotation, widthly, heightly / 2, 0, hoff);
                    newtexture.Tag = 1;
                    datasetbks.Add(newtexture);
                    _datasets.Add(datasetbks);
                }
            }

            return(_datasets);
        }
Пример #9
0
        public static void setTargetSystem(EDDiscoveryForm _discoveryForm, String sn, Boolean prompt)
        {
            if (string.IsNullOrWhiteSpace(sn))
            {
                return;
            }

            ISystem sc         = _discoveryForm.history.FindSystem(sn);
            string  msgboxtext = null;

            if (sc != null && sc.HasCoordinate)
            {
                SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(sc.name, sc.id_edsm);        // has it got a note?

                if (nc != null)
                {
                    TargetClass.SetTargetNotedSystem(sc.name, nc.id, sc.x, sc.y, sc.z);
                    msgboxtext = "Target set on system with note " + sc.name;
                }
                else
                {
                    BookmarkClass bk = BookmarkClass.FindBookmarkOnSystem(sn);    // has it been bookmarked?

                    if (bk != null)
                    {
                        TargetClass.SetTargetBookmark(sc.name, bk.id, bk.x, bk.y, bk.z);
                        msgboxtext = "Target set on booked marked system " + sc.name;
                    }
                    else
                    {
                        bool createbookmark = false;
                        if ((prompt && ExtendedControls.MessageBoxTheme.Show("Make a bookmark on " + sc.name + " and set as target?", "Make Bookmark", MessageBoxButtons.OKCancel) == DialogResult.OK) || !prompt)
                        {
                            createbookmark = true;
                        }
                        if (createbookmark)
                        {
                            BookmarkClass newbk = new BookmarkClass();
                            newbk.StarName = sn;
                            newbk.x        = sc.x;
                            newbk.y        = sc.y;
                            newbk.z        = sc.z;
                            newbk.Time     = DateTime.Now;
                            newbk.Note     = "";
                            newbk.Add();
                            TargetClass.SetTargetBookmark(sc.name, newbk.id, newbk.x, newbk.y, newbk.z);
                        }
                    }
                }
            }
            else
            {
                if (sn.Length > 2 && sn.Substring(0, 2).Equals("G:"))
                {
                    sn = sn.Substring(2, sn.Length - 2);
                }

                GalacticMapObject gmo = _discoveryForm.galacticMapping.Find(sn, true, true);    // ignore if its off, find any part of string, find if disabled

                if (gmo != null)
                {
                    TargetClass.SetTargetGMO("G:" + gmo.name, gmo.id, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z);
                    msgboxtext = "Target set on galaxy object " + gmo.name;
                }
                else
                {
                    msgboxtext = "Unknown system, system is without co-ordinates or galaxy object not found";
                }
            }

            _discoveryForm.NewTargetSet();          // tells everyone who cares a new target was set

            if (msgboxtext != null && prompt)
            {
                ExtendedControls.MessageBoxTheme.Show(msgboxtext, "Create a target", MessageBoxButtons.OK);
            }
        }
Пример #10
0
        public void UpdateSelected(ref List <IData3DSet> _datasets, ISystem selectedsystem, GalacticMapObject selectedgmo, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DSet dataset in _datasets)
            {
                if (dataset is TexturedQuadDataCollection)
                {
                    TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                    foreach (TexturedQuadData tqd in tqdc.BaseTextures)
                    {
                        int id = (int)tqd.Tag;

                        if (id == 0)
                        {
                            tqd.UpdateVertices(new PointData(selectedsystem.x, selectedsystem.y, selectedsystem.z), rotation, widthly, heightly / 2, 0, heightly / 4 + heightly / 16);
                        }
                        else
                        {
                            long      gmotarget = TargetClass.GetTargetGMO();
                            float     hoff      = (gmotarget == selectedgmo.id) ? (heightly * gmoseltarget) : (heightly * gmoselonly);
                            PointData pd        = (selectedgmo.points.Count > 0) ? selectedgmo.points[0] : null; // lets be paranoid
                            tqd.UpdateVertices(pd, rotation, widthly, heightly / 2, 0, hoff);
                        }
                    }
                }
            }
        }
Пример #11
0
        private void UpdateTo(object sender, string optupdateto = null)
        {
            changesilence = true;

            if (optupdateto != null)
            {
                textBox_To.Text = optupdateto;
            }

            if (sender == textBox_To)
            {
                ISystem ds1 = SystemCache.FindSystem(SystemNameOnly(textBox_To.Text), discoveryform.galacticMapping, true);
                if (ds1 != null)
                {
                    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
            {
                string res = "", resname = "";

                if (GetCoordsTo(out Point3D curpos))
                {
                    ISystem           nearest    = SystemCache.FindNearestSystemTo(curpos.X, curpos.Y, curpos.Z, 100);
                    GalacticMapObject nearestgmo = discoveryform.galacticMapping.FindNearest(curpos.X, curpos.Y, curpos.Z);

                    if (nearest != null)
                    {
                        if (nearestgmo != null && nearest.Distance(curpos.X, curpos.Y, curpos.Z) > nearestgmo.GetSystem().Distance(curpos.X, curpos.Y, curpos.Z))
                        {
                            nearest = nearestgmo.GetSystem();
                        }
                    }
                    else
                    {
                        nearest = nearestgmo?.GetSystem();
                    }

                    if (nearest != null)
                    {
                        res = resname = nearest.Name;

                        double distance = Point3D.DistanceBetween(curpos, new Point3D(nearest.X, nearest.Y, nearest.Z));
                        if (distance > 0.1)
                        {
                            resname = nearest.Name + " @ " + distance.ToString("0.00") + "ly";
                        }
                    }
                }

                textBox_To.Text     = res;
                textBox_ToName.Text = resname;
            }

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