public void AddToElement(SXL.XElement parent, int ix)
        {
            var colorentry_el = XMLUtil.CreateVisioSchema2003Element("ColorEntry");

            colorentry_el.SetAttributeValueInt("IX", ix);

            byte rbyte;
            byte gbyte;
            byte bbyte;

            ColorEntry.GetRGBBytes(this.RGB, out rbyte, out gbyte, out bbyte);
            const string format_string = "#{0:x2}{1:x2}{2:x2}";
            string       color_string  = string.Format(System.Globalization.CultureInfo.InvariantCulture, format_string, rbyte, gbyte, bbyte);

            colorentry_el.SetAttributeValue("RGB", color_string);

            parent.Add(colorentry_el);
        }
Example #2
0
        public Drawing(Template template)
        {
            if (template == null)
            {
                throw new System.ArgumentNullException(nameof(template));
            }

            this.dom = template.LoadCleanDOM();

            this.Pages   = new PageList(this);
            this.Faces   = new FaceList();
            this.Windows = new List <Window>();
            this.Colors  = new List <ColorEntry>();

            var masters_el = this.dom.Root.ElementVisioSchema2003("Masters");

            if (masters_el == null)
            {
                throw new System.InvalidOperationException();
            }

            // Store information about each master found in the drawing
            foreach (var master_el in masters_el.ElementsVisioSchema2003("Master"))
            {
                var name = master_el.Attribute("NameU").Value;
                var id   = int.Parse(master_el.Attribute("ID").Value);

                var subshapes = master_el.Descendants()
                                .Where(el => el.Name.LocalName == "Shape")
                                .ToList();

                var count_groups = subshapes.Count(shape_el => shape_el.Attribute("Type").Value == "Group");

                bool master_is_group = count_groups > 0;

                var md = new MasterMetadata();
                md.Name          = name;
                md.ID            = id;
                md.IsGroup       = master_is_group;
                md.SubShapeCount = subshapes.Count();

                this.master_metadata[md.Name] = md;

                this.CurrentShapeID = 1;
            }

            var facenames_el = this.dom.Root.ElementVisioSchema2003("FaceNames");

            foreach (var face_el in facenames_el.ElementsVisioSchema2003("FaceName"))
            {
                var id   = int.Parse(face_el.Attribute("ID").Value);
                var name = face_el.Attribute("Name").Value;
                var face = new Face(id, name);
                this.Faces.Add(face);
            }

            var colors_el = this.dom.Root.ElementVisioSchema2003("Colors");

            foreach (var color_el in colors_el.ElementsVisioSchema2003("ColorEntry"))
            {
                var rgb_s = color_el.Attribute("RGB").Value;
                int rgb   = int.Parse(rgb_s.Substring(1), System.Globalization.NumberStyles.AllowHexSpecifier);
                var ce    = new ColorEntry();
                ce.RGB = rgb;
                this.Colors.Add(ce);
            }
        }
Example #3
0
        public Drawing(Template template)
        {
            if (template == null)
            {
                throw new System.ArgumentNullException(nameof(template));
            }

            this.dom = template.LoadCleanDOM();

            this.Pages = new PageList(this);
            this.Faces = new FaceList();
            this.Windows = new List<Window>();
            this.Colors = new List<ColorEntry>();

            var masters_el = this.dom.Root.ElementVisioSchema2003("Masters");
            if (masters_el == null)
            {
                throw new System.InvalidOperationException();
            }

            // Store information about each master found in the drawing
            foreach (var master_el in masters_el.ElementsVisioSchema2003("Master"))
            {
                var name = master_el.Attribute("NameU").Value;
                var id = int.Parse(master_el.Attribute("ID").Value);

                var subshapes = master_el.Descendants()
                    .Where(el => el.Name.LocalName == "Shape")
                    .ToList();

                var count_groups = subshapes.Count(shape_el => shape_el.Attribute("Type").Value == "Group");

                bool master_is_group = count_groups > 0;

                var md = new MasterMetadata();
                md.Name = name;
                md.ID = id;
                md.IsGroup = master_is_group;
                md.SubShapeCount = subshapes.Count();

                this.master_metadata[md.Name] = md;

                this.CurrentShapeID = 1;
            }

            var facenames_el = this.dom.Root.ElementVisioSchema2003("FaceNames");
            foreach (var face_el in facenames_el.ElementsVisioSchema2003("FaceName"))
            {
                var id = int.Parse(face_el.Attribute("ID").Value);
                var name = face_el.Attribute("Name").Value;
                var face = new Face(id, name);
                this.Faces.Add(face);
            }

            var colors_el = this.dom.Root.ElementVisioSchema2003("Colors");
            foreach (var color_el in colors_el.ElementsVisioSchema2003("ColorEntry"))
            {
                var rgb_s = color_el.Attribute("RGB").Value;
                int rgb = int.Parse(rgb_s.Substring(1), System.Globalization.NumberStyles.AllowHexSpecifier);
                var ce = new ColorEntry();
                ce.RGB = rgb;
                this.Colors.Add(ce);
            }
        }