Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofdOpen = new OpenFileDialog();

            ofdOpen.Filter = "Mark|*.png";
            if (ofdOpen.ShowDialog() != DialogResult.Cancel)
            {
                string FileName  = ofdOpen.FileName;
                string ImageName = Path.GetFileNameWithoutExtension(FileName);
                foreach (ImageViewer iv in Panel.Controls)
                {
                    if (iv.Name == ImageName)
                    {
                        Error.Text = "Error: There is already a mark with this name.";
                        return;
                    }
                }
                Image i = Bitmap.FromFile(FileName);
                if (i.Width > 38 || i.Height > 38)
                {
                    Error.Text = "Error: The size of the image must not be larger than 38x38";
                    return;
                }
                IMGEntry marks = MapEditor.file.Directory.GetIMG("MapHelper.img").GetChild("mark");
                IMGEntry entry = new IMGEntry();

                WZCanvas c = new WZCanvas();
                c.SetBitmap((Bitmap)i);
                c.format = WZCanvas.ImageFormat.FORMAT_4444;
                entry.SetCanvas(c);
                entry.Name = ImageName;

                marks.Add(entry);

                marks.parent.ToSave = true;
                Error.Text          = "";
                ImageViewer imageViewer = new ImageViewer();
                imageViewer.Dock = DockStyle.Bottom;

                imageViewer.Image             = c.GetBitmap();
                imageViewer.Width             = c.GetBitmap().Width + 6;
                imageViewer.Height            = c.GetBitmap().Height + 6;
                imageViewer.Name              = entry.Name;
                imageViewer.MouseClick       += new MouseEventHandler(ImageViewer_MouseClick);
                imageViewer.MouseDoubleClick += new MouseEventHandler(ImageViewer_MouseDoubleClick);
                imageViewer.IsThumbnail       = false;

                Panel.Controls.Add(imageViewer);
            }
        }
Ejemplo n.º 2
0
 public void Add(MapItem item)
 {
     if (item is MapLife)
     {
         MapLife  l  = (MapLife)item;
         int      id = 0;
         IMGEntry le = map.GetChild("life");
         if (le == null)
         {
             le      = new IMGEntry();
             le.Name = "life";
             Map.Instance.map.Add(le);
         }
         while (le.childs.Contains(id.ToString()))
         {
             id++;
         }
         l.ID          = id;
         l.Object.Name = l.ID.ToString();
         lifes.Add(l);
         lifes.Sort(Map.CompareItems);
         le.Add(l.Object);
     }
     else if (item is MapReactor)
     {
         MapReactor r  = (MapReactor)item;
         int        id = 0;
         IMGEntry   re = map.GetChild("reactor");
         if (re == null)
         {
             re      = new IMGEntry();
             re.Name = "reactor";
             Map.Instance.map.Add(re);
         }
         while (re.childs.Contains(id.ToString()))
         {
             id++;
         }
         r.ID          = id;
         r.Object.Name = r.ID.ToString();
         reactors.Add(r);
         reactors.Sort(Map.CompareItems);
         re.Add(r.Object);
     }
     else if (item is MapLR)
     {
         MapLR    l    = (MapLR)item;
         int      id   = 1;
         IMGEntry lrse = map.GetChild("ladderRope");
         if (lrse == null)
         {
             lrse      = new IMGEntry();
             lrse.Name = "ladderRope";
             Map.Instance.map.Add(lrse);
         }
         while (lrse.childs.Contains(id.ToString()))
         {
             id++;
         }
         l.ID          = id;
         l.Object.Name = l.ID.ToString();
         lrs.Add(l);
         lrs.Sort(Map.CompareItems);
         lrse.Add(l.Object);
     }
     else if (item is MapSeat)
     {
         MapSeat  s     = (MapSeat)item;
         int      id    = 0;
         IMGEntry seate = map.GetChild("seat");
         if (seate == null)
         {
             seate      = new IMGEntry();
             seate.Name = "seat";
             Map.Instance.map.Add(seate);
         }
         while (seate.childs.Contains(id.ToString()))
         {
             id++;
         }
         s.ID          = id;
         s.Object.Name = s.ID.ToString();
         seats.Add(s);
         seats.Sort(Map.CompareItems);
         seate.Add(s.Object);
     }
     else if (item is MapPortal)
     {
         MapPortal p        = (MapPortal)item;
         int       id       = 0;
         IMGEntry  portalse = map.GetChild("portal");
         if (portalse == null)
         {
             portalse      = new IMGEntry();
             portalse.Name = "portal";
             Map.Instance.map.Add(portalse);
         }
         while (portalse.childs.Contains(id.ToString()))
         {
             id++;
         }
         p.ID          = id;
         p.Object.Name = p.ID.ToString();
         p.Image       = MapEditor.file.Directory.GetIMG("MapHelper.img").GetChild("portal/game/pv/0");
         portals.Add(p);
         portals.Sort(Map.CompareItems);
         portalse.Add(p.Object);
     }
     else if (item is MapToolTip)
     {
         MapToolTip t        = (MapToolTip)item;
         int        id       = 0;
         IMGEntry   ToolTips = map.GetChild("ToolTip");
         if (ToolTips == null)
         {
             ToolTips      = new IMGEntry();
             ToolTips.Name = "ToolTip";
             Map.Instance.map.Add(ToolTips);
         }
         while (ToolTips.childs.Contains(id.ToString()))
         {
             id++;
         }
         t.ID          = id;
         t.Object.Name = t.ID.ToString();
         tooltips.Add(t);
         tooltips.Sort(Map.CompareItems);
         ToolTips.Add(t.Object);
     }
     else if (item is MapClock)
     {
         if (clock == null)
         {
             clock             = item as MapClock;
             clock.Object.Name = "clock";
             clock.Image       = MapEditor.file.Directory.GetIMG("Obj/etc.img").GetChild("clock/fontTime");
             map.Add(clock.Object);
         }
     }
     else
     {
         layers[(int)MapEditor.Instance.Layer.Value].Add(item);
     }
 }