Example #1
0
        private int GetIdFont(eStyleProperty styleProperty, object value)
        {
            ExcelFontXml fnt = Font.Copy();

            switch (styleProperty)
            {
            case eStyleProperty.Name:
                fnt.Name = value.ToString();
                break;

            case eStyleProperty.Size:
                fnt.Size = (float)value;
                break;

            case eStyleProperty.Family:
                fnt.Family = (int)value;
                break;

            case eStyleProperty.Bold:
                fnt.Bold = (bool)value;
                break;

            case eStyleProperty.Italic:
                fnt.Italic = (bool)value;
                break;

            case eStyleProperty.Strike:
                fnt.Strike = (bool)value;
                break;

            case eStyleProperty.UnderlineType:
                fnt.UnderLineType = (ExcelUnderLineType)value;
                break;

            case eStyleProperty.Color:
                fnt.Color.Rgb = value.ToString();
                break;

            case eStyleProperty.VerticalAlign:
                fnt.VerticalAlign = ((ExcelVerticalAlignmentFont)value) == ExcelVerticalAlignmentFont.None ? "" : value.ToString().ToLower();
                break;

            default:
                throw (new Exception("Invalid property for class Font"));
            }
            int    subId;
            string id = fnt.Id;

            subId = _styles.Fonts.FindIndexByID(id);
            if (subId == int.MinValue)
            {
                return(_styles.Fonts.Add(id, fnt));
            }
            return(subId);
        }
Example #2
0
        internal ExcelFontXml Copy()
        {
            ExcelFontXml newFont = new ExcelFontXml(NameSpaceManager);

            newFont.Name          = Name;
            newFont.Size          = Size;
            newFont.Family        = Family;
            newFont.Scheme        = Scheme;
            newFont.Bold          = Bold;
            newFont.Italic        = Italic;
            newFont.UnderLineType = UnderLineType;
            newFont.Strike        = Strike;
            newFont.VerticalAlign = VerticalAlign;
            newFont.Color         = Color.Copy();
            return(newFont);
        }