コード例 #1
0
        public Boolean Equals(IXLFont other)
        {
            var otherF = other as XLFont;

            if (otherF == null)
            {
                return(false);
            }

            return(Key == otherF.Key);
        }
コード例 #2
0
ファイル: Estilo.cs プロジェクト: JosebaGOB/ExcelDesarrollo
 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;
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
ファイル: XLFont.cs プロジェクト: zamabraga/ClosedXML
        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
                );
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public XLFont(XLStyle style = null, IXLFont d = null) : this(style, GenerateKey(d))
 {
 }
コード例 #7
0
ファイル: XLFont.cs プロジェクト: hal1932/ClosedXML
        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
                ;
        }