예제 #1
0
        /// <summary>
        /// <summary>
        /// 为节点插入子节点,包含内容,属性
        /// </summary>
        /// <param name="xmlHelper">XMl文档操作类</param>
        /// <param name="objParentNode">父节点</param>
        /// <param name="objNode">子节点</param>
        private void InsertChildNode(AojXmlHelper xmlHelper, XmlNode objParentNode)
        {
            #region 相关定义
            XmlElement xmlColumnElement;
            XmlAttribute xmlColumnAttribute;
            XmlElement xmlRowElement;
            XmlAttribute xmlRowAttribute;
            XmlElement xmlCellElement;
            XmlAttribute xmlCellAttribute;
            XmlElement xmlCellTextElement;
            XmlAttribute xmlCellTextAttribute;
            #endregion

            #region 表格列
            Column colInfo;
            foreach (string item in this.myDocument.ColumnCollection.Keys)
            {
                colInfo = this.myDocument.ColumnCollection[item];
                xmlColumnElement = xmlHelper.objXmlDoc.CreateElement("Column");
                xmlColumnAttribute = xmlHelper.objXmlDoc.CreateAttribute("Id");
                xmlColumnAttribute.Value = colInfo.ColumnID;
                xmlColumnElement.Attributes.Append(xmlColumnAttribute);
                xmlColumnAttribute = xmlHelper.objXmlDoc.CreateAttribute("Width");
                xmlColumnAttribute.Value = (this.Width * colInfo.ColumnRatio).ToString();
                xmlColumnElement.Attributes.Append(xmlColumnAttribute);
                objParentNode.AppendChild(xmlColumnElement);
            }
            #endregion

            #region 表格行
            Row rowInfo;
            foreach (string item in this.myDocument.RowCollection.Keys)
            {
                #region 表格行的相关属性
                rowInfo = this.myDocument.RowCollection[item];
                xmlRowElement = xmlHelper.objXmlDoc.CreateElement("Row");
                xmlRowAttribute = xmlHelper.objXmlDoc.CreateAttribute("Id");
                xmlRowAttribute.Value = rowInfo.RowID;
                xmlRowElement.Attributes.Append(xmlRowAttribute);
                xmlRowAttribute = xmlHelper.objXmlDoc.CreateAttribute("Height");
                xmlRowAttribute.Value = (this.Height * rowInfo.RowRatio).ToString();
                xmlRowElement.Attributes.Append(xmlRowAttribute);
                objParentNode.AppendChild(xmlRowElement);
                #endregion

                #region 单元格
                Cell cellInfo;
                for (int index = 0; index < this.myDocument.ColumnCollection.Count; index++)
                {
                    cellInfo = rowInfo[index];
                    xmlCellElement = xmlHelper.objXmlDoc.CreateElement("Cell");
                    xmlCellAttribute = xmlHelper.objXmlDoc.CreateAttribute("Id");
                    xmlCellAttribute.Value = cellInfo.CellID;
                    xmlCellElement.Attributes.Append(xmlCellAttribute);

                    #region 文本
                    xmlCellTextElement = xmlHelper.objXmlDoc.CreateElement("Text");

                    xmlCellTextAttribute = xmlHelper.objXmlDoc.CreateAttribute("FamilyName");
                    xmlCellTextAttribute.Value = cellInfo.TextFamilyName;
                    xmlCellTextElement.Attributes.Append(xmlCellTextAttribute);

                    xmlCellTextAttribute = xmlHelper.objXmlDoc.CreateAttribute("FontStyle");
                    xmlCellTextAttribute.Value = cellInfo.TextFontStyle.ToString();
                    xmlCellTextElement.Attributes.Append(xmlCellTextAttribute);

                    xmlCellTextAttribute = xmlHelper.objXmlDoc.CreateAttribute("FontSize");
                    xmlCellTextAttribute.Value = cellInfo.TextFontSize.ToString();
                    xmlCellTextElement.Attributes.Append(xmlCellTextAttribute);

                    xmlCellTextAttribute = xmlHelper.objXmlDoc.CreateAttribute("Color");
                    xmlCellTextAttribute.Value = ColorTranslator.ToHtml(cellInfo.TextColor);
                    xmlCellTextElement.Attributes.Append(xmlCellTextAttribute);

                    xmlCellTextAttribute = xmlHelper.objXmlDoc.CreateAttribute("Alignment");
                    xmlCellTextAttribute.Value = cellInfo.ObjectStringFormat.Alignment.ToString() + cellInfo.ObjectStringFormat.LineAlignment.ToString();
                    xmlCellTextElement.Attributes.Append(xmlCellTextAttribute);

                    if (!string.IsNullOrEmpty(cellInfo.Text))
                    {
                        xmlCellTextElement.InnerText = cellInfo.Text;
                    }

                    xmlCellElement.AppendChild(xmlCellTextElement);
                    #endregion

                    xmlRowElement.AppendChild(xmlCellElement);
                }
                #endregion
            }
            #endregion
        }
예제 #2
0
 /// <summary>
 /// 将对象保存进xml文档中
 /// </summary>
 public override XmlNode SaveToXMl()
 {
     AojXmlHelper xmlHelper = new AojXmlHelper();
     xmlHelper.objXmlDoc.LoadXml("<Label></Label>");
     Dictionary<string, string> dicObjectParentSetting = this.GetObjectParentSetting();
     xmlHelper.InsertAttribute("Label", dicObjectParentSetting);
     Dictionary<string, string> dicObjectChildSetting = this.GetObjectChildSetting();
     xmlHelper.InsertNode("Label", "Text", this.Text, dicObjectChildSetting);
     return xmlHelper.objXmlDoc.SelectSingleNode("Label");
 }
예제 #3
0
 /// <summary>
 /// 将对象保存进xml文档中
 /// </summary>
 public override XmlNode SaveToXMl()
 {
     AojXmlHelper xmlHelper = new AojXmlHelper();
     xmlHelper.objXmlDoc.LoadXml("<Table></Table>");
     Dictionary<string, string> dicObjectParentSetting = this.GetObjectParentSetting();
     xmlHelper.InsertAttribute("Table", dicObjectParentSetting);
     XmlNode rootNode = xmlHelper.objXmlDoc.SelectSingleNode("Table");
     this.InsertChildNode(xmlHelper, rootNode);
     return rootNode;
 }
예제 #4
0
        /// <summary>
        /// 打开报表设计文件进行文件的加载处理
        /// </summary>
        /// <param name="strXmlDocumentPath">报表格式XML文件</param>
        private void OpenReportDocument(string strXmlDocumentPath)
        {
            try
            {
                this.tsbCmbZoom.ComboBox.SelectedValue = "1.0";
                //新建报表绘制区域
                this.NewDrawWorkSpace();
                AojXmlHelper xmlHelper = new AojXmlHelper(strXmlDocumentPath);
                XmlNode rootNode = xmlHelper.objXmlDoc.SelectSingleNode("AojPaper");
                if (rootNode != null)
                {
                    #region 对报表设计器环境进行初始化设置
                    this.drawWorkSpace.Width = int.Parse(rootNode.Attributes["Width"].Value);
                    this.drawWorkSpace.Height = int.Parse(rootNode.Attributes["Height"].Value);
                    string strPaperSizeName = rootNode.Attributes["PaperSizeName"].Value;
                    this.tsbCmbPage.ComboBox.Text = strPaperSizeName;
                    this.drawWorkSpace.PaperSizeName = strPaperSizeName;
                    this.drawWorkSpace.PageStyle = rootNode.Attributes["PageStyle"].Value;
                    bool bGridStyleFlag = Boolean.Parse(rootNode.Attributes["GridStyleFlag"].Value);
                    this.drawWorkSpace.GridStyleFlag = bGridStyleFlag;
                    this.tsbGridStyle.Checked = bGridStyleFlag;
                    bool bDrawByGridStyleFlag = Boolean.Parse(rootNode.Attributes["DrawByGridStyle"].Value);
                    this.drawWorkSpace.DrawByGridStyle = bDrawByGridStyleFlag;
                    this.tsbAutoCompute.Checked = bDrawByGridStyleFlag;
                    int intDistanceAboutGridStyle = int.Parse(rootNode.Attributes["DistanceAboutGridStyle"].Value);
                    this.drawWorkSpace.DistanceAboutGridStyle = intDistanceAboutGridStyle;
                    this.tsbTxtGridStyle.Text = intDistanceAboutGridStyle.ToString();
                    //根据选择的纸张大小对绘制的纸张大小进行重新设置
                    this.ResetDrawWorkSpaceSize(this.tsbCmbPage.ComboBox.SelectedValue.ToString());
                    #endregion

                    //获得报表区域的相关的对象
                    AojCommonFnc.OpenFromReportDocument(this.drawWorkSpace, strXmlDocumentPath);
                }
            }
            catch {
                //根据选择的纸张大小对绘制的纸张大小进行重新设置
                this.ResetDrawWorkSpaceSize(this.tsbCmbPage.ComboBox.SelectedValue.ToString());
                this.drawWorkSpace.PaperSizeName = this.tsbCmbPage.ComboBox.Text;
            }

            this.drawWorkSpace.ReportDocumentURL = strXmlDocumentPath;
        }