public void SetBorderSettingsStyle() { if (this.LeftBorder && this.TopBorder && this.RightBorder && this.BottomBorder) { if (this.CenterVerticalBorder && this.MiddleHorizontalBorder) { this.BorderSettingsStyle = BorderSettingsStyle.Both; } else if (this.CenterVerticalBorder == false && this.MiddleHorizontalBorder == false) { this.BorderSettingsStyle = BorderSettingsStyle.Rectangle; } else { this.BorderSettingsStyle = BorderSettingsStyle.Custom; } } else if (this.LeftBorder == false && this.TopBorder == false && this.RightBorder == false && this.BottomBorder == false && this.CenterVerticalBorder == false && this.MiddleHorizontalBorder == false) { this.BorderSettingsStyle = BorderSettingsStyle.None; } else { this.BorderSettingsStyle = BorderSettingsStyle.Custom; } }
//public void Read(XTextSelection selection ) //{ // if (selection == null) // { // throw new ArgumentNullException("selection"); // } // this.Clear(); // this.ForTable = false; // XTextElementList cells = null ; // if (selection.Mode == ContentRangeMode.Cell) // { // cells = selection.Cells; // } // else // { // XTextTableCellElement cell = selection.ContentElements[0].OwnerCell; // if (cell != null) // { // cells.Add(cell); // } // } // if ( cells != null && cells.Count > 0 ) // { // // 纯粹的选择了表格单元格 // this.ForTable = true; // // 获得左上角的单元格 // XTextTableCellElement firstCell = ( XTextTableCellElement ) selection.Cells[0]; // this.TopBorder = firstCell.RuntimeStyle.BorderTop; // this.LeftBorder = firstCell.RuntimeStyle.BorderLeft; // this.BorderColor = firstCell.RuntimeStyle.BorderColor; // this.BorderStyle = firstCell.RuntimeStyle.BorderStyle; // // 获得占据右下角的单元格 // XTextTableCellElement lastCell = firstCell; // bool hasBothBorder = true ; // foreach (XTextTableCellElement cell in selection.Cells) // { // if (cell.IsOverrided) // { // continue; // } // DocumentContentStyle rs = cell.RuntimeStyle; // if (hasBothBorder) // { // if (rs.BorderLeft == false // || rs.BorderTop == false // || rs.BorderRight == false // || rs.BorderBottom == false) // { // hasBothBorder = false; // } // } // if (this.BackgroundColor.A != 0) // { // if (rs.BackgroundColor.A != 0) // { // this.BackgroundColor = rs.BackgroundColor; // } // } // if (cell.RowIndex + cell.RowSpan > lastCell.RowIndex + lastCell.RowSpan) // { // lastCell = cell; // } // else if (cell.ColIndex + cell.ColSpan > lastCell.ColIndex + lastCell.ColSpan) // { // lastCell = cell; // } // }//foreach // if (hasBothBorder) // { // this.BorderSettingsStyle = Commands.BorderSettingsStyle.Both; // } // this.RightBorder = lastCell.RuntimeStyle.BorderRight; // this.BottomBorder = lastCell.RuntimeStyle.BorderBottom; // this.MiddleHorizontalBorder = false; // this.CenterVerticalBorder = false; // foreach (XTextTableCellElement cell in selection.Cells) // { // if (cell != firstCell && cell != lastCell) // { // if (this.CenterVerticalBorder == false) // { // if (cell.ColIndex > firstCell.ColIndex // && cell.RuntimeStyle.BorderLeft) // { // this.CenterVerticalBorder = true; // } // else if (cell.ColIndex + cell.ColSpan < lastCell.ColIndex + lastCell.ColSpan // && cell.RuntimeStyle.BorderRight ) // { // this.CenterVerticalBorder = true; // } // } // if (this.MiddleHorizontalBorder == false) // { // if (cell.RowIndex > firstCell.RowIndex && cell.RuntimeStyle.BorderTop) // { // this.MiddleHorizontalBorder = true; // } // else if (cell.RowIndex + cell.RowSpan < lastCell.RowIndex + lastCell.RowSpan // && cell.RuntimeStyle.BorderBottom ) // { // this.MiddleHorizontalBorder = true; // } // } // if (this.CenterVerticalBorder && this.MiddleHorizontalBorder) // { // // 判断完成,提前退出循环 // break; // } // }//if // }//foreach // this.ApplyRange = BorderCommandApplyRange.Cell; // } // else // { // } //} public void Clear() { this.TopBorder = true; this.MiddleHorizontalBorder = true; this.BottomBorder = true; this.LeftBorder = true; this.CenterVerticalBorder = true; this.RightBorder = true; this.BorderColor = Color.Black; this.BorderWidth = 1; this.BorderStyle = DashStyle.Solid; this.BackgroundColor = Color.Transparent; this.ForTable = false; this.BorderSettingsStyle = BorderSettingsStyle.None; }