예제 #1
0
        /// <summary>
        /// 获得指定表格行对象中的所有列
        /// </summary>
        /// <param name="rowItem">表格行对象</param>
        /// <returns>所有列</returns>
        private DataTable GetCellData(Row rowItem)
        {
            DataTable dtCellData = new DataTable();

            #region 列
            DataColumn colName = new DataColumn("columnname", typeof(string));
            dtCellData.Columns.Add(colName);
            colName = new DataColumn("columnvalue", typeof(Cell));
            dtCellData.Columns.Add(colName);
            #endregion

            #region 行
            DataRow drNew;
            foreach (Cell cellItem in rowItem)
            {
                drNew = dtCellData.NewRow();
                drNew["columnname"] = cellItem.CellID;
                drNew["columnvalue"] = cellItem;
                dtCellData.Rows.Add(drNew);
            }
            #endregion

            return dtCellData;
        }
예제 #2
0
        /// <summary>
        /// 对表格中的行进行选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxRow_SelectedIndexChanged(object sender, EventArgs e)
        {
            Row rowInfo = (Row)this.listBoxRow.SelectedValue;
            this.rowCurrent = rowInfo;
            if (rowInfo != null)
            {
                #region 行
                this.txtRowName.Text = rowInfo.RowID;
                this.txtRowHeight.Text = rowInfo.RowHeight.ToString();
                #endregion

                this.listBoxCell.DisplayMember = "columnname";
                this.listBoxCell.ValueMember = "columnvalue";
                this.listBoxCell.DataSource = this.GetCellData(rowInfo);
            }
            else
            {
                #region 行
                this.txtRowName.Text = string.Empty;
                this.txtRowHeight.Text = string.Empty;
                #endregion

                this.listBoxCell.DataSource = null;
            }
        }
예제 #3
0
        /// <summary>
        /// 将Table对象复制一份
        /// </summary>
        private void CopyObject(AojTable tbObjectFrom, AojTable tbObjectTo)
        {
            #region 表格
            tbObjectTo.Name = tbObjectFrom.Name;
            tbObjectTo.Left = tbObjectFrom.Left;
            tbObjectTo.Top = tbObjectFrom.Top;
            tbObjectTo.Width = tbObjectFrom.Width;
            tbObjectTo.Height = tbObjectFrom.Height;
            tbObjectTo.MyDocument = new CellDocument(true);
            #endregion

            #region 表格列
            Column colItem;
            Column colNewItem;
            foreach (string strColId in tbObjectFrom.MyDocument.ColumnCollection.Keys)
            {
                colItem = tbObjectFrom.MyDocument.ColumnCollection[strColId];
                colNewItem = new Column();
                colNewItem.ColumnID = colItem.ColumnID;
                colNewItem.ColumnRatio = colItem.ColumnRatio;
                colNewItem.ColumnWidth = colItem.ColumnWidth;
                tbObjectTo.MyDocument.ColumnCollection.Add(strColId, colNewItem);
            }
            #endregion

            #region 表格行
            Row rowItem;
            Row rowNewItem;
            Cell cellNewItem;
            foreach (string strRowId in tbObjectFrom.MyDocument.RowCollection.Keys)
            {
                rowItem = tbObjectFrom.MyDocument.RowCollection[strRowId];
                rowNewItem = new Row();
                rowNewItem.RowID = rowItem.RowID;
                rowNewItem.RowHeight = rowItem.RowHeight;
                rowNewItem.RowRatio = rowItem.RowRatio;
                tbObjectTo.MyDocument.RowCollection.Add(strRowId, rowNewItem);

                #region 单元格
                int index = 0;
                foreach (string strColId in tbObjectFrom.MyDocument.ColumnCollection.Keys)
                {
                    colItem = tbObjectFrom.MyDocument.ColumnCollection[strColId];
                    cellNewItem = new Cell();
                    cellNewItem.ColumnID = colItem.ColumnID;
                    cellNewItem.RowID = rowItem[index].RowID;
                    cellNewItem.Text = rowItem[index].Text;
                    cellNewItem.TextFamilyName = rowItem[index].TextFamilyName;
                    cellNewItem.TextFontSize = rowItem[index].TextFontSize;
                    cellNewItem.TextFontStyle = rowItem[index].TextFontStyle;
                    cellNewItem.TextColor = rowItem[index].TextColor;
                    cellNewItem.ObjectAlignment = rowItem[index].ObjectAlignment;
                    cellNewItem.ObjectLineAlignment = rowItem[index].ObjectLineAlignment;
                    rowNewItem.Add(cellNewItem);
                    ++index;
                }
                #endregion
            }
            #endregion
        }
예제 #4
0
 /// <summary>
 /// 添加表格行时候,给每列添加相关的单元格
 /// </summary>
 /// <param name="row">新增的表格行对象</param>
 private void DoBusinessAboutAddRow(Row row)
 {
     Cell cellItem;
     foreach (Column colItem in this.tbTempObject.MyDocument.ColumnCollection.Values)
     {
         cellItem = new Cell();
         cellItem.RowID = row.RowID;
         cellItem.ColumnID = colItem.ColumnID;
         row.Add(cellItem);
     }
 }
예제 #5
0
        /// <summary>
        /// 添加表格行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            string rowId = "h" + this.GetRowCountInfo().ToString();
            Row rowNew = new Row();
            rowNew.RowID = rowId;
            rowNew.RowHeight = 30;
            this.tbTempObject.MyDocument.RowCollection.Add(rowId, rowNew);
            this.tbTempObject.Height += rowNew.RowHeight;
            this.txtTableHeight.Text = this.tbTempObject.Height.ToString();
            this.SetRowRatioInfo();
            this.DoBusinessAboutAddRow(rowNew);

            #region 表格行
            this.listBoxRow.DataSource = this.GetRowData(this.tbTempObject);
            #endregion
        }
예제 #6
0
        /// <summary>
        /// 初始化网格数据结构对象操作
        /// </summary>
        private void InitializeTableCellDocument()
        {
            #region 绘制表结构时候的初始化操作

            Row rowItem = new Row();
            rowItem.RowID = "h1";
            rowItem.RowRatio = 0.5f;
            this.AddRow("h1", rowItem);
            rowItem = new Row();
            rowItem.RowID = "h2";
            rowItem.RowRatio = 0.5f;
            this.AddRow("h2", rowItem);

            Column colItem = new Column();
            colItem.ColumnID = "w1";
            colItem.ColumnRatio = 0.5f;
            this.AddColumn("w1", colItem);
            colItem = new Column();
            colItem.ColumnID = "w2";
            colItem.ColumnRatio = 0.5f;
            this.AddColumn("w2", colItem);

            #endregion
        }
예제 #7
0
 /// <summary>
 /// 添加表格行时候,给每列添加相关的单元格
 /// </summary>
 /// <param name="row">新增的表格行对象</param>
 private void DoBusinessAboutAddRow(Row row)
 {
     Cell cellItem;
     Column colInfo;
     foreach (string item in this.dicColumnCollection.Keys)
     {
         colInfo = this.dicColumnCollection[item];
         cellItem = new Cell();
         cellItem.RowID = row.RowID;
         cellItem.ColumnID = colInfo.ColumnID;
         row.Add(cellItem);
     }
 }
예제 #8
0
 /// <summary>
 /// 添加表格行
 /// </summary>
 /// <param name="strRowID">表格行纵项目名称</param>
 /// <param name="row">新增的表格行对象</param>
 public void AddRow(string strRowID, Row row)
 {
     if (!this.dicRowCollection.ContainsKey(strRowID))
     {
         this.dicRowCollection.Add(strRowID, row);
         //给每列添加相关的单元格
         this.DoBusinessAboutAddRow(row);
     }
 }
예제 #9
0
        /// <summary>
        /// 从xml文档中获得对象
        /// </summary>
        public override void OpenFormXML(XmlNode objNode)
        {
            if (objNode != null)
            {
                #region 对象的相关属性
                this.Name = objNode.Attributes["Id"].Value;
                this.Left = float.Parse(objNode.Attributes["PositionX"].Value);
                this.Top = float.Parse(objNode.Attributes["PositionY"].Value);
                this.Width = float.Parse(objNode.Attributes["Width"].Value);
                this.Height = float.Parse(objNode.Attributes["Height"].Value);
                #endregion

                XmlNodeList lstColumn = objNode.SelectNodes("Column");
                XmlNodeList lstRow = objNode.SelectNodes("Row");

                if (lstColumn != null && lstRow != null)
                {
                    int columnCount = lstColumn.Count;
                    int rowCount = lstRow.Count;
                    if (columnCount > 0 && rowCount > 0)
                    {
                        Column colItem;
                        Row rowItem;
                        XmlNodeList lstChildNode;
                        Cell cellItem;
                        XmlNode childCellNode;

                        this.myDocument = new CellDocument(true);

                        #region 表格列
                        foreach (XmlNode nodeColumnItem in lstColumn)
                        {
                            colItem = new Column();
                            colItem.ColumnID = nodeColumnItem.Attributes["Id"].Value;
                            colItem.ColumnWidth = float.Parse(nodeColumnItem.Attributes["Width"].Value);
                            this.myDocument.AddColumn(colItem.ColumnID, colItem);

                            #region 表格行
                            foreach (XmlNode nodeRowItem in lstRow)
                            {
                                lstChildNode = nodeRowItem.SelectNodes("Cell");
                                if (lstChildNode != null && lstChildNode.Count > 0)
                                {
                                    if (columnCount == lstChildNode.Count)
                                    {
                                        rowItem = new Row();
                                        rowItem.RowID = nodeRowItem.Attributes["Id"].Value;
                                        rowItem.RowHeight = float.Parse(nodeRowItem.Attributes["Height"].Value);
                                        this.myDocument.AddRow(rowItem.RowID, rowItem);

                                        rowItem.Clear();

                                        #region 单元格
                                        foreach (XmlNode nodeCellItem in lstChildNode)
                                        {
                                            cellItem = new Cell();
                                            cellItem.ColumnID = colItem.ColumnID;
                                            cellItem.RowID = rowItem.RowID;
                                            cellItem.Width = colItem.ColumnWidth;
                                            cellItem.Height = rowItem.RowHeight;
                                            childCellNode = nodeCellItem.SelectSingleNode("Text");
                                            if (childCellNode != null)
                                            {
                                                cellItem.TextFamilyName = childCellNode.Attributes["FamilyName"].Value;
                                                cellItem.TextFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), childCellNode.Attributes["FontStyle"].Value);
                                                cellItem.TextFontSize = float.Parse(childCellNode.Attributes["FontSize"].Value);
                                                cellItem.TextColor = ColorTranslator.FromHtml(childCellNode.Attributes["Color"].Value);
                                                cellItem.Text = childCellNode.InnerText;
                                                this.SetStringAlignmentFormat(cellItem, childCellNode.Attributes["Alignment"].Value);
                                            }
                                            rowItem.Add(cellItem);
                                        }
                                        #endregion
                                    }
                                }
                            }
                            #endregion
                        }
                        #endregion
                    }
                }

                //设置表格中每列的比例
                this.SetColumnRatioInfo();
                //设置表格中每行的比例
                this.SetRowRatioInfo();
            }
        }