Ejemplo n.º 1
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            GCMap map = new GCMap();

            map.Title = "New Map " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            map.Id    = Guid.NewGuid();

            GCMapService.Maps.Add(map);
            listBoxMaps.Items.Add(map);
            listBoxMaps.SelectedIndex = listBoxMaps.Items.Count - 1;
        }
Ejemplo n.º 2
0
        public static void OnStart()
        {
            string rootFile = GCGlobal.GetFileName(GCGlobal.MapsFolderPath, "root.xml");

            if (File.Exists(rootFile))
            {
                Maps.Clear();
                XmlDocument doc = new XmlDocument();
                doc.Load(rootFile);
                foreach (XmlNode mapXmlNode in doc.GetElementsByTagName("maprec"))
                {
                    if (mapXmlNode is XmlElement mapXmlElement)
                    {
                        GCMap map = new GCMap();
                        map.Id             = new Guid(mapXmlElement.GetAttribute("guid"));
                        map.ImageFilePath  = mapXmlElement.GetAttribute("filePath");
                        map.Title          = mapXmlElement.GetAttribute("title");
                        map.ImageSize      = new Size(int.Parse(mapXmlElement.GetAttribute("sizex")), int.Parse(mapXmlElement.GetAttribute("sizey")));
                        map.LatitudeEnd    = double.Parse(mapXmlElement.GetAttribute("latend"));
                        map.LatitudeStart  = double.Parse(mapXmlElement.GetAttribute("latstart"));
                        map.LongitudeEnd   = double.Parse(mapXmlElement.GetAttribute("longend"));
                        map.LongitudeStart = double.Parse(mapXmlElement.GetAttribute("longstart"));
                        map.MapUsable      = (int.Parse(mapXmlElement.GetAttribute("usable")) == 1);
                        foreach (XmlElement anchorXmlNode in mapXmlElement.GetElementsByTagName("anchor"))
                        {
                            GCMapAnchor anchorPoint = new GCMapAnchor();
                            anchorPoint.relX      = double.Parse(anchorXmlNode.GetAttribute("relX"));
                            anchorPoint.relY      = double.Parse(anchorXmlNode.GetAttribute("relY"));
                            anchorPoint.Location  = anchorXmlNode.GetAttribute("title");
                            anchorPoint.Latitude  = double.Parse(anchorXmlNode.GetAttribute("latitude"));
                            anchorPoint.Longitude = double.Parse(anchorXmlNode.GetAttribute("longitude"));
                            map.AnchorPoints.Add(anchorPoint);
                        }

                        map.RecalculateDimensions();
                        Maps.Add(map);
                    }
                }
            }
        }