Exemplo n.º 1
0
 private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
 {
     if (add == MapsOType.Camera && (sender is PictureBox pb) && !pb.Name.Contains("camera"))
     {
         add = MapsOType.None;
         var l = maps.Manifest.Objects.ToList();
         var s = new MapsObjectSetting()
         {
             TypeObject = 0, Files = maps.GetAllImages()
         };
         if (s.ShowDialog() == DialogResult.OK)
         {
             maps.UploadFile(s.ToLoadFile);
             var obj = new MapsObject(s.NameObject, e.Location, (int)MapsOType.Camera, s.Camera, s.SelectFile);
             l.Add(obj);
         }
         maps.Manifest.Objects = l.ToArray();
         //maps.Save();
         LoadCameras();
     }
     else if (add == MapsOType.Delete)
     {
         add = MapsOType.None;
         var l = maps.Manifest.Objects.ToList();
         if ((sender is PictureBox pb1) && pb1.Name.Contains("camera"))
         {
             var od = l.Where(t => t.Name == pb1.Name.Split('_')[1]).First();
             l.Remove(od);
         }
         maps.Manifest.Objects = l.ToArray();
         //maps.Save();
         LoadCameras();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Создание манифеста карты из xml строки
        /// </summary>
        /// <param name="text"></param>
        public MapsManifest(string text)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(text);
            Name        = xDoc["Manifest"]["Name"].InnerText;
            Descreption = xDoc["Manifest"]["Descreption"].InnerText;
            MainImage   = xDoc["Manifest"]["BackgroundImage"].InnerText;
            MainText    = xDoc["Manifest"]["MainText"].InnerText;
            List <MapsObject> mp = new List <MapsObject>();

            foreach (var item in xDoc["Manifest"]["Objects"])
            {
                var        t = item as XmlElement;
                MapsObject m = new MapsObject(t.GetAttribute("name"), XMLElementToPoint(t), (MapsOType)int.Parse(t["Type"].InnerText), int.Parse(t["OID"].InnerText), t["Icon"].InnerText);
                mp.Add(m);
            }
            Objects = mp.ToArray();
        }