예제 #1
0
        public override object Clone()
        {
            WZCanvas c = new WZCanvas(file, width, height, size, offset, format);

            foreach (WZObject obj in objects)
            {
                c.objects.Add(obj.Clone() as WZObject);
            }

            return(c);
        }
예제 #2
0
 public static Bitmap GetCache(Objects.WZCanvas canvas)
 {
     Start();
     lock (Locker)
     {
         if (cache.Contains(canvas))
         {
             return(((CachedBitmap)cache[canvas]).bitmap);
         }
     }
     return(null);
 }
예제 #3
0
 public static Bitmap FCache(Objects.WZCanvas canvas, Bitmap bitmap)
 {
     Start();
     lock (Locker)
     {
         if (fcache.Contains(canvas))
         {
             return(((CachedBitmap)fcache[canvas]).bitmap);
         }
         fcache.Add(canvas, new CachedBitmap(bitmap));
     }
     return(bitmap);
 }
예제 #4
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);
            }
        }
예제 #5
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;
 }
예제 #6
0
        public override object Clone()
        {
            WZCanvas c = new WZCanvas(file, width, height, size, offset, format);

            foreach (WZObject obj in objects)
            {
                c.objects.Add(obj.Clone() as WZObject);
            }

            return c;
        }
예제 #7
0
        WZObject ReadComplex(int end)
        {
            string type = ReadString();
            switch (type)
            {
                case "Property":
                    {
                        WZProperty p = new WZProperty();
                        file.ReadShort(); // null

                        int count = file.ReadValue();

                        for (int i = 0; i < count; i++)
                        {
                            p.objects.Add(ReadObject());
                        }

                        if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");
                        return p;
                    }
                case "Shape2D#Convex2D":
                    {
                        WZConvex c = new WZConvex();

                        int count = file.ReadValue();

                        for (int i = 0; i < count; i++)
                        {
                            c.objects.Add(ReadComplex());
                        }

                        if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");

                        return c;
                    }
                case "Shape2D#Vector2D":
                    {
                        int x = file.ReadValue();
                        int y = file.ReadValue();


                        if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");
                        return new WZVector(x, y);
                    }
                case "Canvas":
                    {
                        WZCanvas c = new WZCanvas();
                        c.file = file.file;

                        file.ReadByte(); // null

                        if (file.ReadByte() != 0)
                        {
                            file.ReadShort(); // null
                            int count = file.ReadValue();

                            for (int i = 0; i < count; i++)
                            {
                                c.objects.Add(ReadObject());
                            }
                        }

                        c.width = file.ReadValue();
                        c.height = file.ReadValue();
                        int format = file.ReadValue();
                        c.format = (WZCanvas.ImageFormat)(file.ReadValue() + format);
                        file.ReadInt(); // null
                        c.size = file.ReadInt();
                        c.offset = (int)file.file.BaseStream.Position;
                        file.file.BaseStream.Seek(c.size, SeekOrigin.Current);

                        if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");

                        return c;
                    }
                case "Sound_DX8":
                    {
                        // TODO
                        file.file.BaseStream.Seek(end, SeekOrigin.Begin);

                        if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");
                        return new WZSound();
                    }
                case "UOL":
                    {
                        file.ReadByte(); // null

                        //if (end != 0 && end != file.file.BaseStream.Position) throw new Exception("...");

                        return new WZUOL(ReadString());
                    }

            }
            throw new Exception("Invalid Object type: " + type);
        }
예제 #8
0
 private static void CreateEntry(IMGEntry parent, WZCanvas obj)
 {
     parent.value = new WZCanvas(obj.file, obj.width, obj.height, obj.size, obj.offset, obj.format);
     CreateEntryChilds(parent, obj);
 }
예제 #9
0
 public void SetCanvas(string name, WZCanvas set)
 {
     IMGEntry e = GetChild(name);
     if (e == null && name.IndexOf("/") == -1)
     {
         e = new IMGEntry(this);
         e.Name = name;
         e.value = set;
         Add(e);
     }
     else if (e != null)
     {
         e.SetCanvas(set);
     }
 }
예제 #10
0
 public void SetCanvas(WZCanvas set)
 {
     if (value == null)
     {
         value = set;
     }
     if (value.type == WZObject.WZObjectType.WZ_CANVAS)
     {
         value = set;
     }
 }