예제 #1
0
        //internal Fill Copy()
        //{
        //    Fill newFill = new Fill(NameSpaceManager, TopNode.Clone());
        //    return newFill;
        //}

        internal virtual ExcelFillXml Copy()
        {
            ExcelFillXml newFill = new ExcelFillXml(NameSpaceManager);

            newFill.PatternType     = _fillPatternType;
            newFill.BackgroundColor = _backgroundColor.Copy();
            newFill.PatternColor    = _patternColor.Copy();
            return(newFill);
        }
예제 #2
0
        private int GetIdFill(eStyleClass styleClass, eStyleProperty styleProperty, object value)
        {
            ExcelFillXml fill = Fill.Copy();

            switch (styleProperty)
            {
            case eStyleProperty.PatternType:
                if (fill is ExcelGradientFillXml)
                {
                    fill = new ExcelFillXml(NameSpaceManager);
                }
                fill.PatternType = (ExcelFillStyle)value;
                break;

            case eStyleProperty.Color:
            case eStyleProperty.Tint:
            case eStyleProperty.IndexedColor:
            case eStyleProperty.AutoColor:
                if (fill is ExcelGradientFillXml)
                {
                    fill = new ExcelFillXml(NameSpaceManager);
                }
                if (fill.PatternType == ExcelFillStyle.None)
                {
                    throw (new ArgumentException("Can't set color when patterntype is not set."));
                }
                ExcelColorXml destColor;
                if (styleClass == eStyleClass.FillPatternColor)
                {
                    destColor = fill.PatternColor;
                }
                else
                {
                    destColor = fill.BackgroundColor;
                }

                if (styleProperty == eStyleProperty.Color)
                {
                    destColor.Rgb = value.ToString();
                }
                else if (styleProperty == eStyleProperty.Tint)
                {
                    destColor.Tint = (decimal)value;
                }
                else if (styleProperty == eStyleProperty.IndexedColor)
                {
                    destColor.Indexed = (int)value;
                }
                else
                {
                    destColor.Auto = (bool)value;
                }

                break;

            default:
                throw (new ArgumentException("Invalid class/property for class Fill."));
            }
            int    subId;
            string id = fill.Id;

            subId = _styles.Fills.FindIndexByID(id);
            if (subId == int.MinValue)
            {
                return(_styles.Fills.Add(id, fill));
            }
            return(subId);
        }