Esempio n. 1
0
 public static void Export(EditorDocument document, string fileName)
 {
     //初始化XML文档
     var xmlDocument = new XmlDocument();
     xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null));
     var docElement = xmlDocument.CreateElement("document");
     xmlDocument.AppendChild(docElement);
     //导出页面设置
     ExportPage(xmlDocument, docElement, document.Context.Pages[0]);
     //导出行设置及内容属性
     var row = document.FirstRow;
     while (row != null)
     {
         ExportRow(xmlDocument, docElement, row);
         row = row.NextDocRow;
     }
     //保存文件
     xmlDocument.Save(fileName);
 }
Esempio n. 2
0
        public new DTextInput Xml2Object(XmlElement xmlElement, EditorDocument editorDocument)
        {
            foreach (XmlNode node in xmlElement.ChildNodes)
            {
                if ("items".Equals(node.Name))
                {
                    var element = (XmlElement) node;
                    foreach (XmlElement item in element.ChildNodes)
                    {
                        this.Items.Add(new TextData(){Value = item.InnerText});
                    }
                }
                else if ("textChar".Equals(node.Name))
                {
                    var element = (XmlElement)node;
                    var color = element.GetAttribute("fontColor");
                    var fontColor = Color.Black;
                    if (!string.IsNullOrEmpty(color))
                    {
                        fontColor = System.Drawing.ColorTranslator.FromHtml(color);
                    }
                    var fontName = element.GetAttribute("fontName");
                    var fontSize = Convert.ToSingle(element.GetAttribute("fontSize"));
                    var fontStyle = element.GetAttribute("fontStyle");

                    var text = element.InnerText;
                    var singleTexts = text.ToCharArray();
                    foreach (var singleText in singleTexts)
                    {
                        var textChar = editorDocument.CreateTextChar(Convert.ToString(singleText), fontName, fontSize,
                                                                fontColor, GetFontStyle(fontStyle));
                        this.Add(textChar);
                    }
                }
            }
            return this;
        }