Exemplo 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);
            }
        }
Exemplo n.º 2
0
 private static WZCanvas CanvasFromEntry(IMGEntry entry)
 {
     WZCanvas c = (WZCanvas)entry.value;
     WZCanvas obj = new WZCanvas(c.file, c.width, c.height, c.size, c.offset, c.format);
     obj.SetBitmap(c.GetBitmap());
     for (int i = 0; i < entry.childs.Count; i++)
     {
         obj.objects.Add(ObjectFromEntry(entry.childs[i]));
     }
     return obj;
 }