public Boolean Equals(IXLFont other) { var otherF = other as XLFont; if (otherF == null) { return(false); } return(Key == otherF.Key); }
public void AplicarEstilo(IXLFont style) { style.Bold = Negrita; style.Italic = Italica; style.Underline = Subrayado; style.Strikethrough = Tachado; style.VerticalAlignment = AlineacionVertical; style.Shadow = Sombra; style.FontSize = TamanyoFuente; style.FontColor = Color; style.FontName = NombreFuente; style.FontCharSet = FontCharSet; }
/// <summary> /// Pixels to point. /// </summary> /// <param name="pixels">The pixels.</param> /// <param name="xlFont">The font.</param> /// <returns> /// The value in points. /// </returns> /// <remarks> /// The formula is documented there: http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column.aspx /// </remarks> public static double PixelsToUnits(this int pixels, IXLFont xlFont) { if (pixels < 5) { pixels = 5; } var fontSize = (float)xlFont.FontSize; var font = new Font(xlFont.FontName, fontSize, FontStyle.Regular); int underscoreWidth = TextRenderer.MeasureText("__", font).Width; double maxDigitWidth = Digits.Select(d => TextRenderer.MeasureText("_" + d + "_", font).Width - underscoreWidth).Max(); return(Math.Truncate((pixels - 5) / maxDigitWidth * 100 + 0.5) / 100); }
public Boolean Equals(IXLFont other) { var otherF = other as XLFont; if (otherF == null) { return(false); } return (_bold == otherF._bold && _italic == otherF._italic && _underline == otherF._underline && _strikethrough == otherF._strikethrough && _verticalAlignment == otherF._verticalAlignment && _shadow == otherF._shadow && _fontSize == otherF._fontSize && _fontColor.Equals(otherF._fontColor) && _fontName == otherF._fontName && _fontFamilyNumbering == otherF._fontFamilyNumbering ); }
private bool FontsAreEqual(Font f, IXLFont xlFont) { var nf = new XLFont {Bold = f.Bold != null, Italic = f.Italic != null}; if (f.Underline != null) { nf.Underline = f.Underline.Val != null ? f.Underline.Val.Value.ToClosedXml() : XLFontUnderlineValues.Single; } nf.Strikethrough = f.Strike != null; if (f.VerticalTextAlignment != null) { nf.VerticalAlignment = f.VerticalTextAlignment.Val != null ? f.VerticalTextAlignment.Val.Value.ToClosedXml() : XLFontVerticalTextAlignmentValues.Baseline; } nf.Shadow = f.Shadow != null; if (f.FontSize != null) nf.FontSize = f.FontSize.Val; var fColor = GetColor(f.Color); if (fColor.HasValue) nf.FontColor = fColor; if (f.FontName != null) nf.FontName = f.FontName.Val; if (f.FontFamilyNumbering != null) nf.FontFamilyNumbering = (XLFontFamilyNumberingValues)f.FontFamilyNumbering.Val.Value; return nf.Equals(xlFont); }
public XLFont(XLStyle style = null, IXLFont d = null) : this(style, GenerateKey(d)) { }
public Boolean Equals(IXLFont other) { var otherF = other as XLFont; if (otherF == null) return false; return _bold == otherF._bold && _italic == otherF._italic && _underline == otherF._underline && _strikethrough == otherF._strikethrough && _verticalAlignment == otherF._verticalAlignment && _shadow == otherF._shadow && _fontSize == otherF._fontSize && _fontColor.Equals(otherF._fontColor) && _fontName == otherF._fontName && _fontFamilyNumbering == otherF._fontFamilyNumbering ; }