Ejemplo n.º 1
0
        public string SaveToString()
        {
            StringBuilder     output   = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings()
            {
                Indent       = true,
                IndentChars  = " ",
                NewLineChars = "\n"
            };

            using (XmlWriter xml = XmlWriter.Create(output, settings))
            {
                xml.WriteStartElement("Ink");
                xml.WriteStartElement("Name");
                xml.WriteAttributeString("value", Name);
                xml.WriteEndElement();
                xml.WriteStartElement("Format");
                string bgrName = "null";
                if (Background != null)
                {
                    bgrName = Background.GetType().FullName;
                }
                xml.WriteAttributeString("w", Util.FToS(Format.Width));
                xml.WriteAttributeString("h", Util.FToS(Format.Height));
                xml.WriteAttributeString("background", bgrName);
                xml.WriteAttributeString("border", Util.FToS(Border));
                xml.WriteEndElement();
                xml.WriteStartElement("CreationTime");
                xml.WriteAttributeString("show", ShowDate ? "true" : "false");
                xml.WriteAttributeString("date", CreationTime.ToFileTime().ToString());
                xml.WriteEndElement();
                xml.WriteElementString("Filter", Filter.ToString());
                foreach (Line l in lines)
                {
                    xml.WriteStartElement("Line");
                    xml.WriteAttributeString("color", ColorTranslator.ToHtml(l.Brush.GetRawColor()));
                    xml.WriteAttributeString("type", l.GetType().FullName);
                    if (l is Forms.TransformableForm)
                    {
                        var transformable = (Forms.TransformableForm)l;
                        xml.WriteAttributeString("matrix", transformable.Transformation.StoreToString());
                    }
                    xml.WriteAttributeString("params", l.ToParamString());

                    /*xml.WriteStartElement("Brush");
                     * xml.WriteAttributeString("type", l.Brush.SType());
                     * xml.WriteAttributeString("color", l.Brush.SColors());
                     * xml.WriteAttributeString("nums", l.Brush.SFloats());
                     * xml.WriteEndElement();*/
                    xml.WriteEndElement();
                }
                xml.WriteEndElement();
            }
            return(output.ToString());
        }