/// <summary> /// Creates a border line with a specified theme color and style type. /// </summary> /// <param name="themeColor">The theme color name.</param> /// <param name="styleType">The border style type.</param> public BorderLine(string themeColor, BorderLineStyle styleType) { this._context = null; this._themeColor = themeColor; this._style = styleType; this._builtIn = false; }
/// <summary> /// Creates a new instance of the <see cref="BorderStyle"/> object. /// </summary> /// <param name="position">Border's position.</param> /// <param name="color">Border's color.</param> /// <param name="lineStyle">Border's line style.</param> internal BorderStyle(BorderStylePosition position, string color, BorderLineStyle lineStyle) { Position = position; Color = color; LineStyle = lineStyle; Weight = 1; }
/// <summary> A constructor used when creating a writable record /// /// </summary> /// <param name="fnt">the font /// </param> /// <param name="form">the format /// </param> public XFRecord(FontRecord fnt, DisplayFormat form) : base(NExcel.Biff.Type.XF) { initialized = false; locked = true; hidden = false; align = Alignment.GENERAL; valign = VerticalAlignment.BOTTOM; orientation = Orientation.HORIZONTAL; wrap = false; leftBorder = BorderLineStyle.NONE; rightBorder = BorderLineStyle.NONE; topBorder = BorderLineStyle.NONE; bottomBorder = BorderLineStyle.NONE; leftBorderColour = Colour.PALETTE_BLACK; rightBorderColour = Colour.PALETTE_BLACK; topBorderColour = Colour.PALETTE_BLACK; bottomBorderColour = Colour.PALETTE_BLACK; pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; shrinkToFit = false; // This will be set by the initialize method and the subclass respectively parentFormat = 0; xfFormatType = null; font = fnt; format = form; biffType = biff8; read = false; copied = false; formatInfoInitialized = true; Assert.verify(font != null); Assert.verify(format != null); }
/// <summary> /// Creates a new instance of the <see cref="BorderStyle"/> object. /// </summary> /// <param name="position">Border's position.</param> /// <param name="color">Border's color.</param> /// <param name="lineStyle">Border's line style.</param> /// <param name="weight">Border's weight.</param> internal BorderStyle(BorderStylePosition position, string color, BorderLineStyle lineStyle, double weight) { Position = position; Color = color; LineStyle = lineStyle; Weight = weight; }
/** * Sets the border style for cells with this format * * @exception WriteException * @param b the border * @param ls the line for the specified border */ public virtual void setBorder(Border b, BorderLineStyle ls, Colour c) { if (isInitialized()) { throw new JxlWriteException(JxlWriteException.formatInitialized); } if (b == Border.ALL) { // Apply to all base.setXFBorder(Border.LEFT, ls, c); base.setXFBorder(Border.RIGHT, ls, c); base.setXFBorder(Border.TOP, ls, c); base.setXFBorder(Border.BOTTOM, ls, c); return; } if (b == Border.NONE) { // Apply to all base.setXFBorder(Border.LEFT, BorderLineStyle.NONE, Colour.BLACK); base.setXFBorder(Border.RIGHT, BorderLineStyle.NONE, Colour.BLACK); base.setXFBorder(Border.TOP, BorderLineStyle.NONE, Colour.BLACK); base.setXFBorder(Border.BOTTOM, BorderLineStyle.NONE, Colour.BLACK); return; } base.setXFBorder(b, ls, c); }
private static string ToHTMLBorderLineStyle(BorderLineStyle borderLineStyle) { switch (borderLineStyle) { default: case BorderLineStyle.Solid: return("solid 1px"); case BorderLineStyle.Dashed: case BorderLineStyle.Dashed2: case BorderLineStyle.DashDotDot: case BorderLineStyle.DashDot: return("dashed 1px"); case BorderLineStyle.Dotted: return("dotted 1px"); case BorderLineStyle.BoldSolid: return("solid 2px"); case BorderLineStyle.BoldDashed: case BorderLineStyle.BoldDashDot: case BorderLineStyle.BoldDashDotDot: return("dashed 2px"); case BorderLineStyle.BoldDotted: return("dotted 2px"); case BorderLineStyle.BoldSolidStrong: return("solid 3px"); } }
private static string GetBorderLineStyleName(BorderLineStyle style, float weight) { switch (style) { default: case BorderLineStyle.None: return(""); case BorderLineStyle.Continuous: return(weight >= 2.0f ? "medium" : weight >= 3.0f ? "thick" : "thin"); case BorderLineStyle.Dot: return("dotted"); case BorderLineStyle.DashDot: return(weight >= 2.0f ? "mediumDashDot" : "dashDot"); case BorderLineStyle.DashDotDot: return(weight >= 2.0f ? "mediumDashDotDot" : "dashDotDot"); case BorderLineStyle.Dash: return(weight >= 2.0f ? "mediumDashDot" : "dashed"); case BorderLineStyle.SlantDashDot: return("slantDashDot"); case BorderLineStyle.Double: return("double"); } }
/// <summary> Sets the border for this cell /// This method should only be called from its writable subclass /// CellXFRecord /// /// </summary> /// <param name="b">the border /// </param> /// <param name="ls">the border line style /// </param> protected internal virtual void setXFBorder(Border b, BorderLineStyle ls, Colour c) { Assert.verify(!initialized); if (c == Colour.BLACK) { c = Colour.PALETTE_BLACK; } if (b == Border.LEFT) { leftBorder = ls; leftBorderColour = c; } else if (b == Border.RIGHT) { rightBorder = ls; rightBorderColour = c; } else if (b == Border.TOP) { topBorder = ls; topBorderColour = c; } else if (b == Border.BOTTOM) { bottomBorder = ls; bottomBorderColour = c; } return; }
/// <summary> /// Creates a border line with a specified color and style. /// </summary> /// <param name="color">The border color.</param> /// <param name="styleType">The border style type.</param> public BorderLine(Windows.UI.Color color, BorderLineStyle styleType) { this._context = null; this._themeColor = null; this._color = color; this._style = styleType; this._builtIn = false; }
/// <summary> /// Caution, only use for built-in borders creating. /// </summary> internal BorderLine(Windows.UI.Color color, BorderLineData style) { this._context = null; this._style = BorderLineStyle.None; this._color = color; this._styleData = style; this._builtIn = true; }
/// <summary> /// Converts an object into its XML representation. /// </summary> /// <param name="writer">The <see cref="T:System.Xml.XmlWriter" /> stream to which the object is serialized.</param> public void WriteXml(XmlWriter writer) { writer.WriteElementString("BorderLineStyle", BorderLineStyle.ToString()); writer.WriteElementString("BorderVisibility", BorderVisibility.ToString()); writer.WriteStartElement("CornerShape"); CornerShape.WriteXml(writer); writer.WriteEndElement(); }
/// <summary> /// Adds a new border style. /// </summary> /// <remarks> /// <para>The border applies to bottom, top, left and right.</para> /// </remarks> /// <param name="color">Border's color.</param> /// <param name="lineStyle">Border's line style.</param> public void Add(string color, BorderLineStyle lineStyle) { RemoveAll(); items.Add(new BorderStyle(BorderStylePosition.Bottom, color, lineStyle)); items.Add(new BorderStyle(BorderStylePosition.Left, color, lineStyle)); items.Add(new BorderStyle(BorderStylePosition.Right, color, lineStyle)); items.Add(new BorderStyle(BorderStylePosition.Top, color, lineStyle)); }
public Border( BorderPosition position, Color?color = null, BorderLineStyle lineStyle = BorderLineStyle.Continuous, float weight = 1.0f) { this.Position = position; this.Color = color ?? Color.Black; this.LineStyle = lineStyle; this.Weight = weight; }
public void SelectBorderStyle(BorderLineStyle style) { foreach (var i in items) { i.IsSelected = (i.Style == style); } Invalidate(); if (BorderStyleSelectionChanged != null) { BorderStyleSelectionChanged(this, null); } }
public static void DrawBorder(Control control, ref int?renderRef, ControlRenderer renderer, StyleDirection direction, BorderLineStyle lineStyle, ColorValue color, int lineSize, Rectangle rectangle) { if (lineStyle == BorderLineStyle.Inset || lineStyle == BorderLineStyle.Outset) { DrawSetBorder(control, ref renderRef, renderer, direction, lineStyle == BorderLineStyle.Inset, color, lineSize, rectangle); return; } int x = direction switch { StyleDirection.Right => rectangle.X + rectangle.Width - lineSize, _ => rectangle.X }; int y = direction switch { StyleDirection.Top => rectangle.Y, StyleDirection.Bottom => rectangle.Y + rectangle.Height - lineSize, _ => rectangle.Y + lineSize }; int width = (int)direction % 2 == 0 ? rectangle.Width : lineSize; int height = (int)direction % 2 == 0 ? lineSize : rectangle.Height - 2 * lineSize; switch (lineStyle) { case BorderLineStyle.Solid: renderRef = renderer.DrawRectangleLine(control, renderRef, x, y, width, height, color, LineStyle.Solid); break; case BorderLineStyle.Dotted: renderRef = renderer.DrawRectangleLine(control, renderRef, x, y, width, height, color, LineStyle.Dotted); break; case BorderLineStyle.Dashed: renderRef = renderer.DrawRectangleLine(control, renderRef, x, y, width, height, color, LineStyle.Dashed); break; case BorderLineStyle.Double: case BorderLineStyle.Groove: case BorderLineStyle.Ridge: // TODO break; case BorderLineStyle.None: default: break; } }
/// <summary> /// Generates an object from its XML representation. /// </summary> /// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is deserialized.</param> void IXmlSerializable.ReadXml(XmlReader reader) { Serializer.InitReader(reader); this._context = null; this._color = Colors.Transparent; this._themeColor = null; this._style = BorderLineStyle.None; this._styleData = null; while (reader.Read()) { string str; if ((reader.NodeType == XmlNodeType.Element) && ((str = reader.Name) != null)) { if (str != "Type") { if (str == "Color") { goto Label_008E; } if (str == "Theme") { goto Label_00AB; } } else { this._style = (BorderLineStyle)Serializer.DeserializeObj(typeof(BorderLineStyle), reader); } } continue; Label_008E: this._color = (Windows.UI.Color)Serializer.DeserializeObj(typeof(Windows.UI.Color), reader); continue; Label_00AB: this._themeColor = (string)(Serializer.DeserializeObj(typeof(string), reader) as string); } }
/// <summary> Copy constructor. Used for copying writable formats, typically /// when duplicating formats to handle merged cells /// /// </summary> /// <param name="fmt">XFRecord /// </param> protected internal XFRecord(XFRecord fmt) : base(NExcel.Biff.Type.XF) { initialized = false; locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; shrinkToFit = fmt.shrinkToFit; parentFormat = fmt.parentFormat; backgroundColour = fmt.backgroundColour; // Shallow copy is sufficient for these purposes font = fmt.font; format = fmt.format; fontIndex = fmt.fontIndex; formatIndex = fmt.formatIndex; formatInfoInitialized = fmt.formatInfoInitialized; biffType = biff8; read = false; copied = true; }
/** * A public copy constructor which can be used for copy formats between * different sheets. Unlike the the other copy constructor, this * version does a deep copy * * @param cellFormat the format to copy */ protected XFRecord(CellFormat cellFormat) : base(Type.XF) { Assert.verify(cellFormat != null); Assert.verify(cellFormat is XFRecord); XFRecord fmt = (XFRecord)cellFormat; if (!fmt.formatInfoInitialized) { fmt.initializeFormatInformation(); } locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; parentFormat = fmt.parentFormat; indentation = fmt.indentation; shrinkToFit = fmt.shrinkToFit; backgroundColour = fmt.backgroundColour; // Deep copy of the font font = new FontRecord(fmt.getFont()); // Copy the format if (fmt.getFormat() == null) { // format is writable if (fmt.format.isBuiltIn()) { format = fmt.format; } else { // Format is not built in, so do a deep copy format = new FormatRecord((FormatRecord)fmt.format); } } else if (fmt.getFormat() is BuiltInFormat) { // read excel format is built in excelFormat = (BuiltInFormat)fmt.excelFormat; format = (BuiltInFormat)fmt.excelFormat; } else { // read excel format is user defined Assert.verify(fmt.formatInfoInitialized); // in this case FormattingRecords should initialize the excelFormat // field with an instance of FormatRecord Assert.verify(fmt.excelFormat is FormatRecord); // Format is not built in, so do a deep copy FormatRecord fr = new FormatRecord((FormatRecord)fmt.excelFormat); // Set both format fields to be the same object, since // FormatRecord implements all the necessary interfaces excelFormat = fr; format = fr; } biffType = biff8; // The format info should be all OK by virtue of the deep copy formatInfoInitialized = true; // This format was not read in read = false; // Treat this as a new cell record, so set the copied flag to false copied = false; // The font or format indexes need to be set, so set initialized to false initialized = false; }
/// <summary> /// Adds a new border style. /// </summary> /// <param name="position">Border's position.</param> /// <param name="color">Border's color.</param> /// <param name="lineStyle">Border's line style.</param> /// <param name="weight">Border's weight.</param> public void Add(BorderStylePosition position, string color, BorderLineStyle lineStyle, double weight) { Remove(position); items.Add(new BorderStyle(position, color, lineStyle, weight)); }
/// <summary> /// Draw border at specified position. /// </summary> /// <param name="g">Instance for graphics object.</param> /// <param name="x">X coordinate of start point.</param> /// <param name="y">Y coordinate of start point.</param> /// <param name="x2">X coordinate of end point.</param> /// <param name="y2">Y coordinate of end point.</param> /// <param name="style">Style flag of border.</param> /// <param name="color">Color of border.</param> /// <param name="bgPen">Fill pen used when drawing double outline.</param> public void DrawLine(PlatformGraphics g, RGFloat x, RGFloat y, RGFloat x2, RGFloat y2, BorderLineStyle style, SolidColor color, RGPen bgPen = null) { if (style == BorderLineStyle.None) { return; } RGPen p = pens[(byte)style]; lock (p) { p.Color = color; p.StartCap = System.Drawing.Drawing2D.LineCap.Square; p.EndCap = System.Drawing.Drawing2D.LineCap.Square; g.DrawLine(p, new RGPointF(x, y), new RGPointF(x2, y2)); } if (style == BorderLineStyle.DoubleLine && bgPen != null) { lock (bgPen) { g.DrawLine(bgPen, new RGPointF(x, y), new RGPointF(x2, y2)); } } }
/** * Initializes the internal format information from the data read in */ private void initializeFormatInformation() { // Initialize the cell format string if (formatIndex < BuiltInFormat.builtIns.Length && BuiltInFormat.builtIns[formatIndex] != null) { excelFormat = BuiltInFormat.builtIns[formatIndex]; } else { excelFormat = formattingRecords.getFormatRecord(formatIndex); } // Initialize the font font = formattingRecords.getFonts().getFont(fontIndex); // Initialize the cell format data from the binary record byte[] data = getRecord().getData(); // Get the parent record int cellAttributes = IntegerHelper.getInt(data[4],data[5]); parentFormat = (cellAttributes & 0xfff0) >> 4; int formatType = cellAttributes & 0x4; xfFormatType = formatType == 0 ? cell : style; locked = ((cellAttributes & 0x1) != 0); hidden = ((cellAttributes & 0x2) != 0); if (xfFormatType == cell && (parentFormat & 0xfff) == 0xfff) { // Something is screwy with the parent format - set to zero parentFormat = 0; //logger.warn("Invalid parent format found - ignoring"); } int alignMask = IntegerHelper.getInt(data[6],data[7]); // Get the wrap if ((alignMask & 0x08) != 0) wrap = true; // Get the horizontal alignment align = Alignment.getAlignment(alignMask & 0x7); // Get the vertical alignment valign = VerticalAlignment.getAlignment((alignMask >> 4) & 0x7); // Get the orientation orientation = Orientation.getOrientation((alignMask >> 8) & 0xff); int attr = IntegerHelper.getInt(data[8],data[9]); // Get the indentation indentation = attr & 0x0F; // Get the shrink to fit flag shrinkToFit = (attr & 0x10) != 0; // Get the used attribute if (biffType == biff8) usedAttributes = data[9]; // Get the borders int borderMask = IntegerHelper.getInt(data[10],data[11]); leftBorder = BorderLineStyle.getStyle(borderMask & 0x7); rightBorder = BorderLineStyle.getStyle((borderMask >> 4) & 0x7); topBorder = BorderLineStyle.getStyle((borderMask >> 8) & 0x7); bottomBorder = BorderLineStyle.getStyle((borderMask >> 12) & 0x7); int borderColourMask = IntegerHelper.getInt(data[12],data[13]); leftBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); rightBorderColour = Colour.getInternalColour ((borderColourMask & 0x3f80) >> 7); borderColourMask = IntegerHelper.getInt(data[14],data[15]); topBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); bottomBorderColour = Colour.getInternalColour ((borderColourMask & 0x3f80) >> 7); if (biffType == biff8) { // Get the background pattern. This is the six most significant bits int patternVal = IntegerHelper.getInt(data[16],data[17]); patternVal = patternVal & 0xfc00; patternVal = patternVal >> 10; pattern = Pattern.getPattern(patternVal); // Get the background colour int colourPaletteMask = IntegerHelper.getInt(data[18],data[19]); backgroundColour = Colour.getInternalColour(colourPaletteMask & 0x3f); if (backgroundColour == Colour.UNKNOWN || backgroundColour == Colour.DEFAULT_BACKGROUND1) { backgroundColour = Colour.DEFAULT_BACKGROUND; } } else { pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; } // Set the lazy initialization flag formatInfoInitialized = true; }
/** * A constructor used when creating a writable record * * @param fnt the font * @param form the format */ public XFRecord(FontRecord fnt,DisplayFormat form) : base(Type.XF) { initialized = false; locked = true; hidden = false; align = Alignment.GENERAL; valign = VerticalAlignment.BOTTOM; orientation = Orientation.HORIZONTAL; wrap = false; leftBorder = BorderLineStyle.NONE; rightBorder = BorderLineStyle.NONE; topBorder = BorderLineStyle.NONE; bottomBorder = BorderLineStyle.NONE; leftBorderColour = Colour.AUTOMATIC; rightBorderColour = Colour.AUTOMATIC; topBorderColour = Colour.AUTOMATIC; bottomBorderColour = Colour.AUTOMATIC; pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; indentation = 0; shrinkToFit = false; usedAttributes = (byte)(USE_FONT | USE_FORMAT | USE_BACKGROUND | USE_ALIGNMENT | USE_BORDER); // This will be set by the initialize method and the subclass respectively parentFormat = 0; xfFormatType = null; font = fnt; format = form; biffType = biff8; read = false; copied = false; formatInfoInitialized = true; Assert.verify(font != null); Assert.verify(format != null); }
/** * Dummy override * @param line dummy * @param border dummy */ public void setBorder(Border border,BorderLineStyle line) { }
private void SetSelectionBorder(ReoGridBorderPos borderPos, BorderLineStyle style) { grid.DoAction(new RGSetRangeBorderAction(grid.SelectionRange, borderPos, new ReoGridBorderStyle { Color = borderColorPickToolStripItem.SolidColor, Style = style })); }
/// <summary> Initializes the internal format information from the data read in</summary> private void initializeFormatInformation() { // Initialize the cell format string if (formatIndex < BuiltInFormat.builtIns.Length && BuiltInFormat.builtIns[formatIndex] != null) { excelFormat = BuiltInFormat.builtIns[formatIndex]; } else { excelFormat = formattingRecords.getFormatRecord(formatIndex); } // Initialize the font font = formattingRecords.Fonts.getFont(fontIndex); // Initialize the cell format data from the binary record sbyte[] data = getRecord().Data; // Get the parent record int cellAttributes = IntegerHelper.getInt(data[4], data[5]); parentFormat = (cellAttributes & 0xfff0) >> 4; int formatType = cellAttributes & 0x4; xfFormatType = formatType == 0?cell:style; locked = ((cellAttributes & 0x1) != 0); hidden = ((cellAttributes & 0x2) != 0); if (xfFormatType == cell && (parentFormat & 0xfff) == 0xfff) { // Something is screwy with the parent format - set to zero parentFormat = 0; logger.warn("Invalid parent format found - ignoring"); } int alignMask = IntegerHelper.getInt(data[6], data[7]); // Get the wrap if ((alignMask & 0x08) != 0) { wrap = true; } // Get the horizontal alignment align = Alignment.getAlignment(alignMask & 0x7); // Get the vertical alignment valign = VerticalAlignment.getAlignment((alignMask >> 4) & 0x7); // Get the orientation orientation = Orientation.getOrientation((alignMask >> 8) & 0xff); int attr = IntegerHelper.getInt(data[8], data[9]); // Get the shrink to fit flag shrinkToFit = (attr & 0x10) != 0; // Get the used attribute if (biffType == biff8) { usedAttributes = data[9]; } // Get the borders int borderMask = IntegerHelper.getInt(data[10], data[11]); leftBorder = BorderLineStyle.getStyle(borderMask & 0x7); rightBorder = BorderLineStyle.getStyle((borderMask >> 4) & 0x7); topBorder = BorderLineStyle.getStyle((borderMask >> 8) & 0x7); bottomBorder = BorderLineStyle.getStyle((borderMask >> 12) & 0x7); int borderColourMask = IntegerHelper.getInt(data[12], data[13]); leftBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); rightBorderColour = Colour.getInternalColour((borderColourMask & 0x3f80) >> 7); borderColourMask = IntegerHelper.getInt(data[14], data[15]); topBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); bottomBorderColour = Colour.getInternalColour((borderColourMask & 0x3f80) >> 7); if (biffType == biff8) { // Get the background pattern int patternVal = IntegerHelper.getInt(data[16], data[17]); pattern = Pattern.getPattern(patternVal); // Get the background colour int colourPaletteMask = IntegerHelper.getInt(data[18], data[19]); backgroundColour = Colour.getInternalColour(colourPaletteMask & 0x3f); if (backgroundColour == Colour.UNKNOWN || backgroundColour == Colour.DEFAULT_BACKGROUND1) { backgroundColour = Colour.DEFAULT_BACKGROUND; } } else { pattern = Pattern.NONE; backgroundColour = Colour.DEFAULT_BACKGROUND; } // Set the lazy initialization flag formatInfoInitialized = true; }
/** * Sets the border for this cell * This method should only be called from its writable subclass * CellXFRecord * * @param b the border * @param ls the border line style */ protected void setXFBorder(Border b,BorderLineStyle ls,Colour c) { Assert.verify(!initialized); if (c == Colour.BLACK || c == Colour.UNKNOWN) { c = Colour.PALETTE_BLACK; } if (b == Border.LEFT) { leftBorder = ls; leftBorderColour = c; } else if (b == Border.RIGHT) { rightBorder = ls; rightBorderColour = c; } else if (b == Border.TOP) { topBorder = ls; topBorderColour = c; } else if (b == Border.BOTTOM) { bottomBorder = ls; bottomBorderColour = c; } usedAttributes |= USE_BORDER; return; }
/// <summary> /// 設定 Cell 格式 (Detal時, 沒有 tr 和 td, 此時兩個參數傳入同一個物件, 不影響判斷) /// </summary> /// <param name="trInfo" /> /// <param name="tdInfo" /> private WritableCellFormat getCellFormat(AbstractStyleInfo trInfo, AbstractStyleInfo tdInfo) { //style 設定 StyleInfo styleInfo = ((ExportConfigInfo)configInfo).StyleInfo; // 字體名稱 WritableFont.FontName font = styleInfo.Font; if (tdInfo.Font != null) { font = tdInfo.Font; } else if (trInfo.Font != null) { font = trInfo.Font; } // 字體大小 int size = 0; if (ExcelStringUtil.NotEmpty(tdInfo.Size)) { size = Convert.ToInt32(ExcelStringUtil.SafeTrim(tdInfo.Size, "0")); } else if (ExcelStringUtil.NotEmpty(trInfo.Size)) { size = Convert.ToInt32(ExcelStringUtil.SafeTrim(trInfo.Size, "0")); } if (size == 0) { size = Convert.ToInt32(styleInfo.Size); } // 粗體 bool isBold = ("true".Equals(styleInfo.Bold, StringComparison.CurrentCultureIgnoreCase)); if (ExcelStringUtil.NotEmpty(tdInfo.Bold)) { isBold = ("true".Equals(tdInfo.Bold, StringComparison.CurrentCultureIgnoreCase)); } else if (ExcelStringUtil.NotEmpty(trInfo.Bold)) { isBold = ("true".Equals(trInfo.Bold, StringComparison.CurrentCultureIgnoreCase)); } // 斜體 bool isItalic = ("true".Equals(styleInfo.Italic, StringComparison.CurrentCultureIgnoreCase)); if (ExcelStringUtil.NotEmpty(tdInfo.Italic)) { isItalic = ("true".Equals(tdInfo.Italic, StringComparison.CurrentCultureIgnoreCase)); } else if (ExcelStringUtil.NotEmpty(trInfo.Bold)) { isItalic = ("true".Equals(trInfo.Italic, StringComparison.CurrentCultureIgnoreCase)); } // 底線 UnderlineStyle underlineStyle = styleInfo.Underline; if (tdInfo.Underline != null) { underlineStyle = tdInfo.Underline; } else if (trInfo.Underline != null) { underlineStyle = trInfo.Underline; } // 字體顏色 Colour color = styleInfo.Color; if (tdInfo.Color != null) { color = tdInfo.Color; } else if (trInfo.Color != null) { color = trInfo.Color; } // 水平位置 Alignment align = styleInfo.Align; if (tdInfo.Align != null) { align = tdInfo.Align; } else if (trInfo.Align != null) { align = trInfo.Align; } // 垂直位置 VerticalAlignment valign = styleInfo.Valign; if (tdInfo.Valign != null) { valign = tdInfo.Valign; } else if (trInfo.Valign != null) { valign = trInfo.Valign; } // 文字換行 bool isTextWrap = ("true".Equals(styleInfo.Wrap, StringComparison.CurrentCultureIgnoreCase)); if (ExcelStringUtil.NotEmpty(tdInfo.Wrap)) { isTextWrap = ("true".Equals(tdInfo.Wrap, StringComparison.CurrentCultureIgnoreCase)); } else if (ExcelStringUtil.NotEmpty(trInfo.Wrap)) { isTextWrap = ("true".Equals(trInfo.Wrap, StringComparison.CurrentCultureIgnoreCase)); } // 邊線位置 Border borderSide = styleInfo.BorderSide; if (tdInfo.BorderSide != null) { borderSide = tdInfo.BorderSide; } else if (trInfo.BorderSide != null) { borderSide = trInfo.BorderSide; } // 邊線樣式 BorderLineStyle borderStyle = styleInfo.BorderStyle; if (tdInfo.BorderStyle != null) { borderStyle = tdInfo.BorderStyle; } else if (trInfo.Valign != null) { borderStyle = trInfo.BorderStyle; } // 背景顏色 Colour background = styleInfo.Background; if (tdInfo.Background != null) { background = tdInfo.Background; } else if (trInfo.Background != null) { background = trInfo.Background; } // 產生字型設定 var writableFont = new WritableFont(font, size, (isBold) ? WritableFont.BOLD : WritableFont.NO_BOLD, isItalic, underlineStyle, color); // 資料列cell格式 var writableCellFormat = new WritableCellFormat(writableFont); // 水平置中 writableCellFormat.setAlignment(align); // 垂直置中 writableCellFormat.setVerticalAlignment(valign); // 換行 writableCellFormat.setWrap(isTextWrap); // 背景顏色 writableCellFormat.setBackground(background); // 邊線 writableCellFormat.setBorder(borderSide, borderStyle); return(writableCellFormat); }
/** * Sets the specified border for this format * * @param b the border * @param ls the border line style * @exception jxl.write.WriteException */ public void setBorder(Border b, BorderLineStyle ls) { base.setBorder(b, ls, Colour.BLACK); }
/// <summary> A public copy constructor which can be used for copy formats between /// different sheets. Unlike the the other copy constructor, this /// version does a deep copy /// /// </summary> /// <param name="cellFormat">the format to copy /// </param> protected internal XFRecord(CellFormat cellFormat) : base(NExcel.Biff.Type.XF) { Assert.verify(cellFormat is XFRecord); XFRecord fmt = (XFRecord)cellFormat; if (!fmt.formatInfoInitialized) { fmt.initializeFormatInformation(); } locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; parentFormat = fmt.parentFormat; shrinkToFit = fmt.shrinkToFit; backgroundColour = fmt.backgroundColour; // Deep copy of the font font = new FontRecord(fmt.Font); // Copy the format if (fmt.Format == null) { // format is writable if (fmt.format.isBuiltIn()) { format = fmt.format; } else { // Format is not built in, so do a deep copy format = new FormatRecord((FormatRecord)fmt.format); } } else if (fmt.Format is BuiltInFormat) { // read excel format is built in excelFormat = (BuiltInFormat)fmt.excelFormat; format = (BuiltInFormat)fmt.excelFormat; } else { // read excel format is user defined Assert.verify(fmt.formatInfoInitialized); // in this case FormattingRecords should initialize the excelFormat // field with an instance of FormatRecord Assert.verify(fmt.excelFormat is FormatRecord); // Format is not built in, so do a deep copy FormatRecord fr = new FormatRecord((FormatRecord)fmt.excelFormat); // Set both format fields to be the same object, since // FormatRecord implements all the necessary interfaces excelFormat = fr; format = fr; } biffType = biff8; // The format info should be all OK by virtue of the deep copy formatInfoInitialized = true; // This format was not read in read = false; // Treat this as a new cell record, so set the copied flag to false copied = false; // The font or format indexes need to be set, so set initialized to false initialized = false; }
/** * Copy constructor. Used for copying writable formats, typically * when duplicating formats to handle merged cells * * @param fmt XFRecord */ protected XFRecord(XFRecord fmt) : base(Type.XF) { initialized = false; locked = fmt.locked; hidden = fmt.hidden; align = fmt.align; valign = fmt.valign; orientation = fmt.orientation; wrap = fmt.wrap; leftBorder = fmt.leftBorder; rightBorder = fmt.rightBorder; topBorder = fmt.topBorder; bottomBorder = fmt.bottomBorder; leftBorderColour = fmt.leftBorderColour; rightBorderColour = fmt.rightBorderColour; topBorderColour = fmt.topBorderColour; bottomBorderColour = fmt.bottomBorderColour; pattern = fmt.pattern; xfFormatType = fmt.xfFormatType; indentation = fmt.indentation; shrinkToFit = fmt.shrinkToFit; parentFormat = fmt.parentFormat; backgroundColour = fmt.backgroundColour; // Shallow copy is sufficient for these purposes font = fmt.font; format = fmt.format; fontIndex = fmt.fontIndex; formatIndex = fmt.formatIndex; formatInfoInitialized = fmt.formatInfoInitialized; biffType = biff8; read = false; copied = true; }
public void FormatRange(string from, string to, Color?background, Align vertical, Align horizontal, BorderType borderType, BorderLineStyle borderStyle) { range = worksheet.get_Range(from, to); if (background != null) { range.Interior.Color = ColorTranslator.ToOle(background.Value); } if (!vertical.Equals(Align.None)) { range.VerticalAlignment = vertical; } if (!horizontal.Equals(Align.None)) { range.HorizontalAlignment = horizontal; } if (borderType == BorderType.None) { return; } if (borderType == BorderType.BorderOutside) { range.BorderAround(borderStyle, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexNone, missing); } else { range.Borders.LineStyle = borderStyle; } }
/** * Sets the specified border for this format * * @param b the border * @param ls the border line style * @param c the colour of the specified border * @exception jxl.write.WriteException */ public override void setBorder(Border b, BorderLineStyle ls, Colour c) { base.setBorder(b, ls, c); }
public void SelectBorderStyle(BorderLineStyle style) { foreach (var i in items) { i.IsSelected = (i.Style == style); } Invalidate(); if (BorderStyleSelectionChanged != null) BorderStyleSelectionChanged(this, null); }
/// <summary> /// Draw border at specified position. /// </summary> /// <param name="g">Instance for graphics object.</param> /// <param name="x">X coordinate of start point.</param> /// <param name="y">Y coordinate of start point.</param> /// <param name="x2">X coordinate of end point.</param> /// <param name="y2">Y coordinate of end point.</param> /// <param name="style">Style flag of border.</param> /// <param name="color">Color of border.</param> /// <param name="bgPen">Fill pen used when drawing double outline.</param> public void DrawLine(PlatformGraphics g, RGFloat x, RGFloat y, RGFloat x2, RGFloat y2, BorderLineStyle style, SolidColor color, RGPen bgPen = null) { if (style == BorderLineStyle.None) { return; } #if WINFORM || WPF || ANDROID #if WINFORM RGPen p = pens[(byte)style]; lock (p) { p.Color = color; p.StartCap = System.Drawing.Drawing2D.LineCap.Square; p.EndCap = System.Drawing.Drawing2D.LineCap.Square; g.DrawLine(p, new RGPointF(x, y), new RGPointF(x2, y2)); } #elif WPF // get template pen from cache list var tp = pens[(byte)style]; // create new WPF pen var p = new RGPen(new RGSolidBrush(color), tp.Thickness); // copy the pen style from template p.DashStyle = tp.DashStyle; p.StartLineCap = System.Windows.Media.PenLineCap.Square; p.EndLineCap = System.Windows.Media.PenLineCap.Square; System.Windows.Media.GuidelineSet gs = new System.Windows.Media.GuidelineSet(); double halfPenWidth = p.Thickness / 2; gs.GuidelinesX.Add(x + halfPenWidth); gs.GuidelinesY.Add(y + halfPenWidth); gs.GuidelinesX.Add(x2 + halfPenWidth); gs.GuidelinesY.Add(y2 + halfPenWidth); g.PushGuidelineSet(gs); g.DrawLine(p, new RGPointF(x, y), new RGPointF(x2, y2)); #elif ANDROID g.DrawLine(x, y, x2, y2, p); #endif if (style == BorderLineStyle.DoubleLine && bgPen != null) { lock (bgPen) { #if WINFORM || WPF g.DrawLine(bgPen, new RGPointF(x, y), new RGPointF(x2, y2)); #elif ANDROID g.DrawLine(x, y, x2, y2, bgPen); #endif // WPF } } #if WPF g.Pop(); #endif // WPF //#endif // WINFORM || WPF || ANDROID #elif iOS using (var path = new CGPath()) { path.AddLines(new CGPoint[] { new CGPoint(x, y), new CGPoint(x2, y2) }); switch (style) { default: case BorderLineStyle.Solid: g.AddPath(path); g.SetStrokeColor(color); g.DrawPath(CGPathDrawingMode.Stroke); break; } } #endif // iOS }
/** * Dummy override * @param line dummy * @param border dummy */ public void setBorder(Border border, BorderLineStyle line) { }