Exemplo n.º 1
0
        /// <summary>
        /// 对表格中的单元格进行选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxCell_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cell cellInfo = (Cell)this.listBoxCell.SelectedValue;
            this.cellCurrent = cellInfo;

            if (cellInfo != null)
            {
                #region 单元格
                this.txtCellName.Text = cellInfo.CellID;
                this.txtCellConent.Text = cellInfo.Text;
                this.txtCellFont.Text = cellInfo.TextFont.ToString();
                this.txtCellColor.BackColor = cellInfo.TextColor;
                this.cmbCellAlignment.SelectedValue = cellInfo.ObjectAlignment;
                this.cmbCellLineAlignment.SelectedValue = cellInfo.ObjectLineAlignment;
                #endregion
            }
            else
            {
                #region 单元格
                this.txtCellName.Text = string.Empty;
                this.txtCellConent.Text = string.Empty;
                this.txtCellFont.Text = string.Empty;
                this.txtCellColor.BackColor = Color.Black;
                this.cmbCellAlignment.SelectedIndex = 0;
                this.cmbCellLineAlignment.SelectedIndex = 0;
                #endregion
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加表格列的时候,给每行添加相关的单元格
 /// </summary>
 /// <param name="colId">新增的表格列对象ID</param>
 private void DoBusinessAboutAddColumn(string colId)
 {
     Cell cellItem;
     foreach (Row rowItem in this.tbTempObject.MyDocument.RowCollection.Values)
     {
         cellItem = new Cell();
         cellItem.RowID = rowItem.RowID;
         cellItem.ColumnID = colId;
         rowItem.Add(cellItem);
     }
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
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
        }
Exemplo n.º 6
0
 /// <summary>
 /// 添加表格列的时候,给每行添加相关的单元格
 /// </summary>
 /// <param name="column">新增的表格列对象</param>
 private void DoBusinessAboutAddColumn(Column column)
 {
     Cell cellItem;
     foreach (Row rowItem in this.dicRowCollection.Values)
     {
         cellItem = new Cell();
         cellItem.RowID = rowItem.RowID;
         cellItem.ColumnID = column.ColumnID;
         rowItem.Add(cellItem);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 根据指定的格式字符串设置文本格式
 /// </summary>
 /// <param name="cellInfo">指定的表格单元格</param>
 /// <param name="strAlignmentFormat">根据指定的格式字符串</param>
 private void SetStringAlignmentFormat(Cell cellInfo, string strAlignmentFormat)
 {
     if (!string.IsNullOrEmpty(strAlignmentFormat))
     {
         if (char.IsUpper(strAlignmentFormat, 0))
         {
             int endIndex = 0;
             for (int index = 1; index < strAlignmentFormat.Length; index++)
             {
                 if (char.IsUpper(strAlignmentFormat, index))
                 {
                     endIndex = index;
                     break;
                 }
             }
             string strAlignment = strAlignmentFormat.Substring(0, endIndex);
             string strLineAlignment = strAlignmentFormat.Substring(endIndex);
             cellInfo.ObjectAlignment = (StringAlignment)Enum.Parse(typeof(StringAlignment), strAlignment);
             cellInfo.ObjectLineAlignment = (StringAlignment)Enum.Parse(typeof(StringAlignment), strLineAlignment);
         }
     }
 }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 添加单元格对象
 /// </summary>
 /// <param name="text">新增的单元格文本</param>
 /// <returns>新增的单元格对象</returns>
 public Cell Add(string text)
 {
     Cell cell = new Cell();
     cell.Text = text;
     this.List.Add(cell);
     return cell;
 }
Exemplo n.º 10
0
 /// <summary>
 /// 添加单元格对象
 /// </summary>
 /// <param name="cell">单元格对象</param>
 public void Add(Cell cell)
 {
     this.List.Add(cell);
 }