Example #1
0
        /// <summary>
        /// Here is actual save method. Element should be already created one
        /// </summary>
        /// <param name="node"></param>
        public virtual void SaveItem(XmlDocument doc, System.Xml.XmlElement element)
        {
            UnitsManager unitMng = new UnitsManager();

            // save name attribute
            XmlAttribute attr = doc.CreateAttribute("Name");
            attr.Value = Name;
            element.SetAttributeNode(attr);

            // save location
            XmlElement el = doc.CreateElement("Location");
            attr = doc.CreateAttribute("PositionX");
            attr.Value = LocationInUnitsX.ToString() + unitMng.UnitToString(MeasureUnit);
            el.SetAttributeNode(attr);

            attr = doc.CreateAttribute("PositionY");
            attr.Value = LocationInUnitsY.ToString() + unitMng.UnitToString(MeasureUnit);
            el.SetAttributeNode(attr);

            element.AppendChild(el);

            // save Width and Height. This is same as shape but generator wants those information as well
            el = doc.CreateElement("Width");
            attr = doc.CreateAttribute("Value");
            attr.Value = this.WidthInUnits.ToString() + unitMng.UnitToString(MeasureUnit);
            el.SetAttributeNode(attr);
            element.AppendChild(el);

            el = doc.CreateElement("Height");
            attr = doc.CreateAttribute("Value");
            attr.Value = this.HeightInUnits.ToString() + unitMng.UnitToString(MeasureUnit);
            el.SetAttributeNode(attr);
            element.AppendChild(el);

            el = doc.CreateElement("WidthInPixels");
            attr = doc.CreateAttribute("Value");
            attr.Value = this.WidthInPixels.ToString();
            el.SetAttributeNode(attr);
            element.AppendChild(el);

            el = doc.CreateElement("HeightInPixels");
            attr = doc.CreateAttribute("Value");
            attr.Value = this.HeightInPixels.ToString();
            el.SetAttributeNode(attr);
            element.AppendChild(el);

            // save Shape
            el = doc.CreateElement("Shape");
            attr = doc.CreateAttribute("Type");
            attr.Value = "Rectangle";
            el.SetAttributeNode(attr);

            XmlElement el2 = doc.CreateElement("Dimensions");
            attr = doc.CreateAttribute("Width");
            attr.Value = this.WidthInUnits.ToString() + unitMng.UnitToString(MeasureUnit);
            el2.SetAttributeNode(attr);
            el.AppendChild(el2);

            attr = doc.CreateAttribute("Height");
            attr.Value = this.HeightInUnits.ToString() + unitMng.UnitToString(MeasureUnit);
            el2.SetAttributeNode(attr);
            el.AppendChild(el2);

            element.AppendChild(el);

            // Save Scale
            el = doc.CreateElement("Scale");
            attr = doc.CreateAttribute("x");
            attr.Value = this.ScaleXFactor.ToString();
            el.SetAttributeNode(attr);

            attr = doc.CreateAttribute("y");
            attr.Value = this.ScaleXFactor.ToString();
            el.SetAttributeNode(attr);

            element.AppendChild(el);

            // save transformations
            el = doc.CreateElement("Transformation");
            attr = doc.CreateAttribute("a");
            attr.Value = this.TransformationMatrix.Elements[0].ToString();
            el.SetAttributeNode(attr);

            attr = doc.CreateAttribute("b");
            attr.Value = this.TransformationMatrix.Elements[1].ToString();
            el.SetAttributeNode(attr);

            attr = doc.CreateAttribute("c");
            attr.Value = this.TransformationMatrix.Elements[2].ToString();
            el.SetAttributeNode(attr);

            attr = doc.CreateAttribute("d");
            attr.Value = this.TransformationMatrix.Elements[3].ToString();
            el.SetAttributeNode(attr);

            element.AppendChild(el);

            // save rotation
            el = doc.CreateElement("Rotation");
            attr = doc.CreateAttribute("Value");
            attr.Value = this.RotationAngle.ToString();
            el.SetAttributeNode(attr);

            element.AppendChild(el);

            // save dock position
            el = doc.CreateElement("DockPosition");
            attr = doc.CreateAttribute("Dock");
            attr.Value = this.DockPositionString;
            el.SetAttributeNode(attr);

            element.AppendChild(el);

            // save anchor properties
            if(anchor != null)
            {
                el = doc.CreateElement("Anchor");
                attr = doc.CreateAttribute("Top");
                attr.Value = this.anchor.TopAnchor.ToString();
                el.SetAttributeNode(attr);
                attr = doc.CreateAttribute("Bottom");
                attr.Value = this.anchor.Bottomanchor.ToString();
                el.SetAttributeNode(attr);
                attr = doc.CreateAttribute("Left");
                attr.Value = this.anchor.LeftAnchor.ToString();
                el.SetAttributeNode(attr);
                attr = doc.CreateAttribute("Right");
                attr.Value = this.anchor.RightAnchor.ToString();
                el.SetAttributeNode(attr);

                element.AppendChild(el);
            }
        }
Example #2
0
        /// <summary>
        /// Set the handle
        /// </summary>
        /// <param name="oNode"></param>
        /// <param name="strHandle"></param>
        private void SetHandle(System.Xml.XmlElement oNode, string strHandle)
        {
            if (strHandle != null && strHandle.Length != 0)
            {
                System.Xml.XmlAttribute hAttr;
                hAttr = oNode.OwnerDocument.CreateAttribute(Constant.Attribute.HANDLE_ATTR);
                hAttr.Value = strHandle;

                oNode.SetAttributeNode(hAttr);
            }
        }