Пример #1
0
        public void AddCanvasItem(Point point, PaletteItem paletteItem)
        {
            CanvasItem canvasItem = new CanvasItem(point, paletteItem, this.sourceSpriteSheet);

            this.listCanvasItems.Add(canvasItem);

            Graphics g = this.pictureBox.CreateGraphics();

            g.DrawImage(canvasItem.Cropped, canvasItem.Point);
        }
Пример #2
0
        public void GenerateXML()
        {
            XmlTextWriter writer = new XmlTextWriter(Project.Instance.ProjectLocation + "\\" + "JetCanvas.xml", null);

            writer.Formatting = Formatting.Indented;

            //
            // For now, we'll hard-code the Levels and Level sections
            //
            writer.WriteStartElement("Levels");

            //
            // Write out CabElements based on the ProjectItem list
            //
            writer.WriteStartElement("CabElements");
            for (int i = 0; i < Project.Instance.ListProjectItems.Count; i++)
            {
                ProjectItem projectItem = Project.Instance.ListProjectItems.ElementAt(i);
                writer.WriteStartElement("CabElement");
                writer.WriteAttributeString("FileName", projectItem.ItemName);
                writer.WriteAttributeString("ContentType", projectItem.ProjectItemType.ToString());
                writer.WriteEndElement(); // CabElement
            }
            writer.WriteEndElement();     // CabElements

            writer.WriteStartElement("Level");
            writer.WriteAttributeString("Number", "1");
            for (int i = 0; i < this.listCanvasItems.Count; i++)
            {
                CanvasItem canvasItem = this.listCanvasItems.ElementAt(i);
                writer.WriteStartElement("Object");
                writer.WriteAttributeString("Name", canvasItem.PaletteItem.name);
                writer.WriteAttributeString("Type", canvasItem.PaletteItem.paletteTypeEnum.ToString());
                writer.WriteAttributeString("XPosition", canvasItem.Point.X.ToString());
                writer.WriteAttributeString("YPosition", canvasItem.Point.Y.ToString());
                writer.WriteStartElement("Rectangle");
                writer.WriteAttributeString("X", canvasItem.PaletteItem.rectangle.X.ToString());
                writer.WriteAttributeString("Y", canvasItem.PaletteItem.rectangle.Y.ToString());
                writer.WriteAttributeString("Width", canvasItem.PaletteItem.rectangle.Width.ToString());
                writer.WriteAttributeString("Height", canvasItem.PaletteItem.rectangle.Height.ToString());
                writer.WriteEndElement(); // Rectangle
                writer.WriteEndElement(); // Object
            }
            writer.WriteEndElement();     // Level
            writer.WriteEndElement();     // Levels

            writer.Close();
        }
Пример #3
0
        public void Initialize(PictureBox pictureBox, Bitmap sourceSpriteSheet)
        {
            this.sourceSpriteSheet = sourceSpriteSheet;
            this.pictureBox        = pictureBox;

            //
            // If we detect a Saved state, re-initialize the CanvasItems' non-serialized fields
            //
            if (this.listCanvasItems.Count > 0)
            {
                for (int i = 0; i < this.listCanvasItems.Count; i++)
                {
                    CanvasItem canvasItem = this.listCanvasItems.ElementAt(i);
                    canvasItem.RestoreNonserializedFields(this.sourceSpriteSheet);
                }

                this.pictureBox.Invalidate();
            }
        }