public static void UnloadToXML(TownList <Point, string> townList)
        {
            var xmlDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
                                       new XElement("Towns"));

            for (int i = 0; i < townList.Count; i++)
            {
                InsideDataTown <Point, string> town = townList.GetObject(i);

                xmlDoc.Root.Add(new XElement("Town", new XAttribute("id", i),
                                             new XElement("Name", town.Name),
                                             new XElement("Point", town.TownPoint)));
            }

            xmlDoc.Save(Path.Combine(Environment.CurrentDirectory, "townsMap.xml"));
        }
        public void Add(Point data, string name)
        {
            InsideDataTown <Point, string> newTown = new InsideDataTown <Point, string>(data, name);

            if (head == null)
            {
                head = newTown;
            }
            else
            {
                tail.Next = newTown;
            }

            tail = newTown;

            Count++;
        }
        public int GetIndex(Point pt)
        {
            if (head != null)
            {
                InsideDataTown <Point, string> current = head;

                int index = 0;

                while (current != null && current != ProcessingData.GetTown(pt, "obj"))
                {
                    current = current.Next;
                    index++;
                }

                return(index);
            }
            else
            {
                return(0);
            }
        }
        internal InsideDataTown <Point, string> GetObject(int indexFind)
        {
            if (head != null)
            {
                InsideDataTown <Point, string> current = head;

                int index = 0;

                while (current.Next != null && index != indexFind)
                {
                    current = current.Next;
                    index++;
                }

                return(current);
            }
            else
            {
                Console.WriteLine("Невозможно найти элемент по индексу. Список пуст.");
                return(null);
            }
        }
        public string GetElementName(int index)
        {
            InsideDataTown <Point, string> element = GetObject(index);

            return(element.Name);
        }