Ejemplo n.º 1
0
        protected static void ProcessObject(XmlElement element, IsoMap map)
        {
            MapObject obj = new MapObject();
            obj.Name = element.GetAttribute("name");
            obj.ObjectType = element.GetAttribute("type");
            if (element.HasAttribute("x") && element.HasAttribute("y"))
                obj.Origin = new Point(int.Parse(element.GetAttribute("x")), int.Parse(element.GetAttribute("y")));
            if (element.HasAttribute("width") && element.HasAttribute("height"))
                obj.Bounds = new Size(int.Parse(element.GetAttribute("width")), int.Parse(element.GetAttribute("height")));

            foreach (XmlElement p in element.GetElementsByTagName("properties"))
            {
                foreach (XmlElement prop in p.GetElementsByTagName("property"))
                    obj.Properties.Add(new KeyValuePair<string, string>(prop.GetAttribute("name"), prop.GetAttribute("value")));
            }

            map.Objects.Add(obj);
        }
Ejemplo n.º 2
0
        protected void DrawObjects(MapObject obj, Point originGraphics, Graphics graphics)
        {
            Brush brush = new SolidBrush(Color.FromArgb(64, Color.White));
            Brush textBrush = new SolidBrush(Color.Black);

            Rectangle rect = new Rectangle(obj.Origin.X+originGraphics.X,obj.Origin.Y+originGraphics.Y,obj.Bounds.Width,obj.Bounds.Height);
            graphics.FillRectangle(brush, rect);

            Pen pen = Pens.Wheat;
            graphics.DrawRectangle(pen, rect);

            graphics.DrawString(obj.Name,new Font(FontFamily.GenericSansSerif,12),textBrush,new Point(obj.Origin.X+originGraphics.X,obj.Origin.Y+originGraphics.Y));
        }