Example #1
0
        internal void FromColorScale(ColorScale cs)
        {
            this.SetAllNull();

            SLConditionalFormatValueObject cfvo;
            SLColor clr;
            using (OpenXmlReader oxr = OpenXmlReader.Create(cs))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(ConditionalFormatValueObject))
                    {
                        cfvo = new SLConditionalFormatValueObject();
                        cfvo.FromConditionalFormatValueObject((ConditionalFormatValueObject)oxr.LoadCurrentElement());
                        this.Cfvos.Add(cfvo);
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        clr = new SLColor(new List<System.Drawing.Color>(), new List<System.Drawing.Color>());
                        clr.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Colors.Add(clr);
                    }
                }
            }
        }
        internal void FromColorScale(X14.ColorScale cs)
        {
            this.SetAllNull();

            SLConditionalFormattingValueObject2010 cfvo;
            SLColor clr;

            using (OpenXmlReader oxr = OpenXmlReader.Create(cs))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(X14.ConditionalFormattingValueObject))
                    {
                        cfvo = new SLConditionalFormattingValueObject2010();
                        cfvo.FromConditionalFormattingValueObject((X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement());
                        this.Cfvos.Add(cfvo);
                    }
                    else if (oxr.ElementType == typeof(X14.Color))
                    {
                        clr = new SLColor(new List <System.Drawing.Color>(), new List <System.Drawing.Color>());
                        clr.FromExcel2010Color((X14.Color)oxr.LoadCurrentElement());
                        this.Colors.Add(clr);
                    }
                }
            }
        }
Example #3
0
        internal SLColor Clone()
        {
            SLColor clr = new SLColor(this.listThemeColors, this.listIndexedColors);

            clr.clrDisplay = this.clrDisplay;
            clr.Auto       = this.Auto;
            clr.Indexed    = this.Indexed;
            clr.Rgb        = this.Rgb;
            clr.Theme      = this.Theme;
            clr.Tint       = this.Tint;

            return(clr);
        }
Example #4
0
 private void SetAllNull()
 {
     this.FontName           = null;
     this.CharacterSet       = null;
     this.FontFamily         = null;
     this.Bold               = null;
     this.Italic             = null;
     this.Strike             = null;
     this.Outline            = null;
     this.Shadow             = null;
     this.Condense           = null;
     this.Extend             = null;
     this.clrFontColor       = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasFontColor            = false;
     this.FontSize           = null;
     this.vUnderline         = UnderlineValues.None;
     HasUnderline            = false;
     this.vVerticalAlignment = VerticalAlignmentRunValues.Baseline;
     HasVerticalAlignment    = false;
     this.vFontScheme        = FontSchemeValues.None;
     HasFontScheme           = false;
 }
Example #5
0
        internal void FromBorderPropertiesType(HorizontalBorder border)
        {
            if (border.Color != null)
            {
                this.clrReal = new SLColor(this.listThemeColors, this.listIndexedColors);
                this.clrReal.FromSpreadsheetColor(border.Color);
                HasColor = !this.clrReal.IsEmpty();
            }
            else
            {
                RemoveColor();
            }

            if (border.Style != null)
            {
                this.BorderStyle = border.Style.Value;
            }
            else
            {
                RemoveBorderStyle();
            }
        }
Example #6
0
        private void SetAllNull()
        {
            this.clrTabColor = new SLColor(this.listThemeColors, this.listIndexedColors);
            this.HasTabColor = false;

            this.ApplyStyles        = false;
            this.SummaryBelow       = true;
            this.SummaryRight       = true;
            this.ShowOutlineSymbols = true;

            this.AutoPageBreaks = true;
            this.FitToPage      = false;

            this.SyncHorizontal       = false;
            this.SyncVertical         = false;
            this.SyncReference        = string.Empty;
            this.TransitionEvaluation = false;
            this.TransitionEntry      = false;
            this.Published            = true;
            this.CodeName             = string.Empty;
            this.FilterMode           = false;
            this.EnableFormatConditionsCalculation = true;
        }
Example #7
0
        private void SetAllNull()
        {
            this.clrTabColor = new SLColor(this.listThemeColors, this.listIndexedColors);
            this.HasTabColor = false;

            this.ApplyStyles = false;
            this.SummaryBelow = true;
            this.SummaryRight = true;
            this.ShowOutlineSymbols = true;

            this.AutoPageBreaks = true;
            this.FitToPage = false;

            this.SyncHorizontal = false;
            this.SyncVertical = false;
            this.SyncReference = string.Empty;
            this.TransitionEvaluation = false;
            this.TransitionEntry = false;
            this.Published = true;
            this.CodeName = string.Empty;
            this.FilterMode = false;
            this.EnableFormatConditionsCalculation = true;
        }
Example #8
0
 private void SetAllNull()
 {
     this.FontName = null;
     this.CharacterSet = null;
     this.FontFamily = null;
     this.Bold = null;
     this.Italic = null;
     this.Strike = null;
     this.Outline = null;
     this.Shadow = null;
     this.Condense = null;
     this.Extend = null;
     this.clrFontColor = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasFontColor = false;
     this.FontSize = null;
     this.vUnderline = UnderlineValues.None;
     HasUnderline = false;
     this.vVerticalAlignment = VerticalAlignmentRunValues.Baseline;
     HasVerticalAlignment = false;
     this.vFontScheme = FontSchemeValues.None;
     HasFontScheme = false;
 }
        private void SetCustomColorScale(SLConditionalFormatMinMaxValues MinType, string MinValue, SLColor MinColor,
            bool HasMidPoint, SLConditionalFormatRangeValues MidPointType, string MidPointValue, SLColor MidPointColor,
            SLConditionalFormatMinMaxValues MaxType, string MaxValue, SLColor MaxColor)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.ColorScale;

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            switch (MinType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Min;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfvo.Val = MinValue;
            cfr.ColorScale.Cfvos.Add(cfvo);
            cfr.ColorScale.Colors.Add(MinColor.Clone());

            if (HasMidPoint)
            {
                cfvo = new SLConditionalFormatValueObject();
                switch (MidPointType)
                {
                    case SLConditionalFormatRangeValues.Number:
                        cfvo.Type = ConditionalFormatValueObjectValues.Number;
                        break;
                    case SLConditionalFormatRangeValues.Percent:
                        cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                        break;
                    case SLConditionalFormatRangeValues.Formula:
                        cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                        break;
                    case SLConditionalFormatRangeValues.Percentile:
                        cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                        break;
                }
                cfvo.Val = MidPointValue;
                cfr.ColorScale.Cfvos.Add(cfvo);
                cfr.ColorScale.Colors.Add(MidPointColor.Clone());
            }

            cfvo = new SLConditionalFormatValueObject();
            switch (MaxType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Max;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfvo.Val = MaxValue;
            cfr.ColorScale.Cfvos.Add(cfvo);
            cfr.ColorScale.Colors.Add(MaxColor.Clone());

            cfr.HasColorScale = true;

            this.AppendRule(cfr);
        }
        /// <summary>
        /// Set a custom 3-color scale.
        /// </summary>
        /// <param name="MinType">The conditional format type for the minimum.</param>
        /// <param name="MinValue">The value for the minimum. If <paramref name="MinType"/> is Value, you can just set this to "0".</param>
        /// <param name="MinColor">The theme color for the minimum.</param>
        /// <param name="MinColorTint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        /// <param name="MidPointType">The conditional format type for the midpoint.</param>
        /// <param name="MidPointValue">The value for the midpoint.</param>
        /// <param name="MidPointColor">The theme color for the midpoint.</param>
        /// <param name="MidPointColorTint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        /// <param name="MaxType">The conditional format type for the maximum.</param>
        /// <param name="MaxValue">The value for the maximum. If <paramref name="MaxType"/> is Value, you can just set this to "0".</param>
        /// <param name="MaxColor">The theme color for the maximum.</param>
        /// <param name="MaxColorTint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        public void SetCustom3ColorScale(SLConditionalFormatMinMaxValues MinType, string MinValue, SLThemeColorIndexValues MinColor, double MinColorTint,
            SLConditionalFormatRangeValues MidPointType, string MidPointValue, SLThemeColorIndexValues MidPointColor, double MidPointColorTint,
            SLConditionalFormatMinMaxValues MaxType, string MaxValue, SLThemeColorIndexValues MaxColor, double MaxColorTint)
        {
            List<System.Drawing.Color> listempty = new List<System.Drawing.Color>();
            SLColor minclr = new SLColor(listempty, listempty);
            if (MinColorTint == 0) minclr.SetThemeColor(MinColor);
            else minclr.SetThemeColor(MinColor, MinColorTint);
            SLColor maxclr = new SLColor(listempty, listempty);
            if (MaxColorTint == 0) maxclr.SetThemeColor(MaxColor);
            else maxclr.SetThemeColor(MaxColor, MaxColorTint);

            SLColor midclr = new SLColor(listempty, listempty);
            if (MidPointColorTint == 0) midclr.SetThemeColor(MidPointColor);
            else midclr.SetThemeColor(MidPointColor, MidPointColorTint);
            this.SetCustomColorScale(MinType, MinValue, minclr, true, MidPointType, MidPointValue, midclr, MaxType, MaxValue, maxclr);
        }
        /// <summary>
        /// Set a custom 3-color scale.
        /// </summary>
        /// <param name="MinType">The conditional format type for the minimum.</param>
        /// <param name="MinValue">The value for the minimum. If <paramref name="MinType"/> is Value, you can just set this to "0".</param>
        /// <param name="MinColor">The color for the minimum.</param>
        /// <param name="MidPointType">The conditional format type for the midpoint.</param>
        /// <param name="MidPointValue">The value for the midpoint.</param>
        /// <param name="MidPointColor">The color for the midpoint.</param>
        /// <param name="MaxType">The conditional format type for the maximum.</param>
        /// <param name="MaxValue">The value for the maximum. If <paramref name="MaxType"/> is Value, you can just set this to "0".</param>
        /// <param name="MaxColor">The color for the maximum.</param>
        public void SetCustom3ColorScale(SLConditionalFormatMinMaxValues MinType, string MinValue, System.Drawing.Color MinColor,
            SLConditionalFormatRangeValues MidPointType, string MidPointValue, System.Drawing.Color MidPointColor,
            SLConditionalFormatMinMaxValues MaxType, string MaxValue, System.Drawing.Color MaxColor)
        {
            List<System.Drawing.Color> listempty = new List<System.Drawing.Color>();
            SLColor minclr = new SLColor(listempty, listempty);
            minclr.Color = MinColor;
            SLColor maxclr = new SLColor(listempty, listempty);
            maxclr.Color = MaxColor;

            SLColor midclr = new SLColor(listempty, listempty);
            midclr.Color = MidPointColor;
            this.SetCustomColorScale(MinType, MinValue, minclr, true, MidPointType, MidPointValue, midclr, MaxType, MaxValue, maxclr);
        }
        private void SetCustomDataBar(bool ShowBarOnly, uint MinLength, uint MaxLength, SLConditionalFormatMinMaxValues ShortestBarType, string ShortestBarValue, SLConditionalFormatMinMaxValues LongestBarType, string LongestBarValue, SLColor BarColor)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.DataBar;
            cfr.DataBar.ShowValue = !ShowBarOnly;
            cfr.DataBar.MinLength = MinLength;
            cfr.DataBar.MaxLength = MaxLength;

            switch (ShortestBarType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Min;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfr.DataBar.Cfvo1.Val = ShortestBarValue;
            switch (LongestBarType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Max;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfr.DataBar.Cfvo2.Val = LongestBarValue;

            cfr.DataBar.Color = BarColor.Clone();

            cfr.HasDataBar = true;

            this.AppendRule(cfr);
        }
Example #13
0
 /// <summary>
 /// Set a gradient stop given a position and a color. Used in conjunction with SetCustomGradient().
 /// </summary>
 /// <param name="Position">Specifies position of the color, ranging from 0.0 to 1.0.</param>
 /// <param name="ColorTheme">The theme color to be used.</param>
 /// <param name="ColorTint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
 public void AppendGradientStop(double Position, SLThemeColorIndexValues ColorTheme, double ColorTint)
 {
     SLColor clr = new SLColor(this.listThemeColors, this.listIndexedColors);
     clr.SetThemeColor(ColorTheme, ColorTint);
     GradientStop gs = new GradientStop();
     gs.Position = Position;
     gs.Color = clr.ToSpreadsheetColor();
     listGradientStops.Add(gs);
 }
Example #14
0
        private void SetGradientFill(SLGradientShadingStyleValues ShadingStyle, SLColor Color1, SLColor Color2)
        {
            GradientStop gs;

            switch (ShadingStyle)
            {
                case SLGradientShadingStyleValues.Horizontal1:
                    this.Degree = 90;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Horizontal2:
                    this.Degree = 270;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Horizontal3:
                    this.Degree = 90;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical1:
                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical2:
                    this.Degree = 180;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Vertical3:
                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp1:
                    this.Degree = 45;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp2:
                    this.Degree = 225;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalUp3:
                    this.Degree = 45;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown1:
                    this.Degree = 135;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown2:
                    this.Degree = 315;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.DiagonalDown3:
                    this.Degree = 135;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 0.5;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner1:
                    this.Type = GradientValues.Path;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner2:
                    this.Type = GradientValues.Path;
                    this.Left = 1;
                    this.Right = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner3:
                    this.Type = GradientValues.Path;
                    this.Top = 1;
                    this.Bottom = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.Corner4:
                    this.Type = GradientValues.Path;
                    this.Left = 1;
                    this.Right = 1;
                    this.Top = 1;
                    this.Bottom = 1;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
                case SLGradientShadingStyleValues.FromCenter:
                    this.Type = GradientValues.Path;
                    this.Left = 0.5;
                    this.Right = 0.5;
                    this.Top = 0.5;
                    this.Bottom = 0.5;

                    gs = new GradientStop();
                    gs.Position = 0;
                    gs.Color = Color1.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);

                    gs = new GradientStop();
                    gs.Position = 1;
                    gs.Color = Color2.ToSpreadsheetColor();
                    this.listGradientStops.Add(gs);
                    break;
            }
        }
Example #15
0
        internal void FromFont(Font f)
        {
            this.SetAllNull();

            if (f.FontName != null && f.FontName.Val != null)
            {
                this.FontName = f.FontName.Val.Value;
            }

            if (f.FontCharSet != null && f.FontCharSet.Val != null)
            {
                this.CharacterSet = f.FontCharSet.Val.Value;
            }

            if (f.FontFamilyNumbering != null && f.FontFamilyNumbering.Val != null)
            {
                this.FontFamily = f.FontFamilyNumbering.Val.Value;
            }

            if (f.Bold != null)
            {
                if (f.Bold.Val == null)
                {
                    this.Bold = true;
                }
                else if (f.Bold.Val.Value)
                {
                    this.Bold = true;
                }
            }

            if (f.Italic != null)
            {
                if (f.Italic.Val == null)
                {
                    this.Italic = true;
                }
                else if (f.Italic.Val.Value)
                {
                    this.Italic = true;
                }
            }

            if (f.Strike != null)
            {
                if (f.Strike.Val == null)
                {
                    this.Strike = true;
                }
                else if (f.Strike.Val.Value)
                {
                    this.Strike = true;
                }
            }

            if (f.Outline != null)
            {
                if (f.Outline.Val == null)
                {
                    this.Outline = true;
                }
                else if (f.Outline.Val.Value)
                {
                    this.Outline = true;
                }
            }

            if (f.Shadow != null)
            {
                if (f.Shadow.Val == null)
                {
                    this.Shadow = true;
                }
                else if (f.Shadow.Val.Value)
                {
                    this.Shadow = true;
                }
            }

            if (f.Condense != null)
            {
                if (f.Condense.Val == null)
                {
                    this.Condense = true;
                }
                else if (f.Condense.Val.Value)
                {
                    this.Condense = true;
                }
            }

            if (f.Extend != null)
            {
                if (f.Extend.Val == null)
                {
                    this.Extend = true;
                }
                else if (f.Extend.Val.Value)
                {
                    this.Extend = true;
                }
            }

            if (f.Color != null)
            {
                this.clrFontColor = new SLColor(this.listThemeColors, this.listIndexedColors);
                this.clrFontColor.FromSpreadsheetColor(f.Color);
                HasFontColor = !this.clrFontColor.IsEmpty();
            }

            if (f.FontSize != null && f.FontSize.Val != null)
            {
                this.FontSize = f.FontSize.Val.Value;
            }

            if (f.Underline != null)
            {
                if (f.Underline.Val != null)
                {
                    this.Underline = f.Underline.Val.Value;
                }
                else
                {
                    this.Underline = UnderlineValues.Single;
                }
            }

            if (f.VerticalTextAlignment != null && f.VerticalTextAlignment.Val != null)
            {
                this.VerticalAlignment = f.VerticalTextAlignment.Val.Value;
            }

            if (f.FontScheme != null && f.FontScheme.Val != null)
            {
                this.FontScheme = f.FontScheme.Val.Value;
            }
        }
Example #16
0
 /// <summary>
 /// Remove any existing color.
 /// </summary>
 public void RemoveColor()
 {
     this.clrReal = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasColor     = false;
 }
Example #17
0
        internal void FromFont(Font f)
        {
            this.SetAllNull();

            if (f.FontName != null && f.FontName.Val != null)
            {
                this.FontName = f.FontName.Val.Value;
            }

            if (f.FontCharSet != null && f.FontCharSet.Val != null)
            {
                this.CharacterSet = f.FontCharSet.Val.Value;
            }

            if (f.FontFamilyNumbering != null && f.FontFamilyNumbering.Val != null)
            {
                this.FontFamily = f.FontFamilyNumbering.Val.Value;
            }

            if (f.Bold != null)
            {
                if (f.Bold.Val == null)
                {
                    this.Bold = true;
                }
                else if (f.Bold.Val.Value) this.Bold = true;
            }

            if (f.Italic != null)
            {
                if (f.Italic.Val == null)
                {
                    this.Italic = true;
                }
                else if (f.Italic.Val.Value) this.Italic = true;
            }

            if (f.Strike != null)
            {
                if (f.Strike.Val == null)
                {
                    this.Strike = true;
                }
                else if (f.Strike.Val.Value) this.Strike = true;
            }

            if (f.Outline != null)
            {
                if (f.Outline.Val == null)
                {
                    this.Outline = true;
                }
                else if (f.Outline.Val.Value) this.Outline = true;
            }

            if (f.Shadow != null)
            {
                if (f.Shadow.Val == null)
                {
                    this.Shadow = true;
                }
                else if (f.Shadow.Val.Value) this.Shadow = true;
            }

            if (f.Condense != null)
            {
                if (f.Condense.Val == null)
                {
                    this.Condense = true;
                }
                else if (f.Condense.Val.Value) this.Condense = true;
            }

            if (f.Extend != null)
            {
                if (f.Extend.Val == null)
                {
                    this.Extend = true;
                }
                else if (f.Extend.Val.Value) this.Extend = true;
            }

            if (f.Color != null)
            {
                this.clrFontColor = new SLColor(this.listThemeColors, this.listIndexedColors);
                this.clrFontColor.FromSpreadsheetColor(f.Color);
                HasFontColor = !this.clrFontColor.IsEmpty();
            }

            if (f.FontSize != null && f.FontSize.Val != null)
            {
                this.FontSize = f.FontSize.Val.Value;
            }

            if (f.Underline != null)
            {
                if (f.Underline.Val != null)
                {
                    this.Underline = f.Underline.Val.Value;
                }
                else
                {
                    this.Underline = UnderlineValues.Single;
                }
            }

            if (f.VerticalTextAlignment != null && f.VerticalTextAlignment.Val != null)
            {
                this.VerticalAlignment = f.VerticalTextAlignment.Val.Value;
            }

            if (f.FontScheme != null && f.FontScheme.Val != null)
            {
                this.FontScheme = f.FontScheme.Val.Value;
            }
        }
Example #18
0
        internal void FromBorderPropertiesType(HorizontalBorder border)
        {
            if (border.Color != null)
            {
                this.clrReal = new SLColor(this.listThemeColors, this.listIndexedColors);
                this.clrReal.FromSpreadsheetColor(border.Color);
                HasColor = !this.clrReal.IsEmpty();
            }
            else
            {
                RemoveColor();
            }

            if (border.Style != null) this.BorderStyle = border.Style.Value;
            else RemoveBorderStyle();
        }
Example #19
0
 /// <summary>
 /// Remove any existing color.
 /// </summary>
 public void RemoveColor()
 {
     this.clrReal = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasColor = false;
 }
Example #20
0
        /// <summary>
        /// Set a gradient fill given the shading style and 2 colors.
        /// </summary>
        /// <param name="ShadingStyle">The gradient shading style.</param>
        /// <param name="Color1Theme">The first color as one of the theme colors.</param>
        /// <param name="Color1Tint">The tint applied to the first theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        /// <param name="Color2">The second color.</param>
        public void SetGradientFill(SLGradientShadingStyleValues ShadingStyle, SLThemeColorIndexValues Color1Theme, double Color1Tint, System.Drawing.Color Color2)
        {
            SLColor clr1 = new SLColor(this.listThemeColors, this.listIndexedColors);
            SLColor clr2 = new SLColor(this.listThemeColors, this.listIndexedColors);

            clr1.SetThemeColor(Color1Theme, Color1Tint);
            clr2.Rgb = string.Format("{0}{1}{2}", Color2.R.ToString("x2"), Color2.G.ToString("x2"), Color2.B.ToString("x2"));

            SetGradientFill(ShadingStyle, clr1, clr2);
        }
Example #21
0
        private string FontColorToAppend(SLColor clr)
        {
            string result = "&K01+000";

            if (clr.Theme != null)
            {
                double fTint = 0.0;
                bool bPositive = true;
                string sTint = string.Empty;
                if (clr.Tint != null)
                {
                    fTint = clr.Tint.Value;
                }

                if (fTint < 0)
                {
                    fTint = -fTint;
                    bPositive = false;
                }
                sTint = fTint.ToString(CultureInfo.InvariantCulture).Replace(".", "").PadRight(3, '0').Substring(0, 3);

                result = string.Format("&K{0}{1}{2}", clr.Theme.Value.ToString("d2"), bPositive ? "+" : "-", sTint);
            }
            else
            {
                result = string.Format("&K{0}{1}{2}", clr.Color.R.ToString("X2"), clr.Color.G.ToString("X2"), clr.Color.B.ToString("X2"));
            }

            return result;
        }
Example #22
0
        /// <summary>
        /// Set a gradient fill given the shading style and 2 colors.
        /// </summary>
        /// <param name="ShadingStyle">The gradient shading style.</param>
        /// <param name="Color1Theme">The first color as one of the theme colors.</param>
        /// <param name="Color1Tint">The tint applied to the first theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        /// <param name="Color2Theme">The second color as one of the theme colors.</param>
        /// <param name="Color2Tint">The tint applied to the second theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        public void SetGradientFill(SLGradientShadingStyleValues ShadingStyle, SLThemeColorIndexValues Color1Theme, double Color1Tint, SLThemeColorIndexValues Color2Theme, double Color2Tint)
        {
            SLColor clr1 = new SLColor(this.listThemeColors, this.listIndexedColors);
            SLColor clr2 = new SLColor(this.listThemeColors, this.listIndexedColors);

            clr1.SetThemeColor(Color1Theme, Color1Tint);
            clr2.SetThemeColor(Color2Theme, Color2Tint);

            SetGradientFill(ShadingStyle, clr1, clr2);
        }
Example #23
0
        internal SLColor Clone()
        {
            SLColor clr = new SLColor(this.listThemeColors, this.listIndexedColors);
            clr.clrDisplay = this.clrDisplay;
            clr.Auto = this.Auto;
            clr.Indexed = this.Indexed;
            clr.Rgb = this.Rgb;
            clr.Theme = this.Theme;
            clr.Tint = this.Tint;

            return clr;
        }
Example #24
0
 /// <summary>
 /// Set a gradient stop given a position and a color. Used in conjunction with SetCustomGradient().
 /// </summary>
 /// <param name="Position">Specifies position of the color, ranging from 0.0 to 1.0.</param>
 /// <param name="Color">The color to be used.</param>
 public void AppendGradientStop(double Position, System.Drawing.Color Color)
 {
     SLColor clr = new SLColor(this.listThemeColors, this.listIndexedColors);
     clr.Rgb = string.Format("{0}{1}{2}", Color.R.ToString("x2"), Color.G.ToString("x2"), Color.B.ToString("x2"));
     GradientStop gs = new GradientStop();
     gs.Position = Position;
     gs.Color = clr.ToSpreadsheetColor();
     listGradientStops.Add(gs);
 }
        /// <summary>
        /// Set a custom 2-color scale.
        /// </summary>
        /// <param name="MinType">The conditional format type for the minimum.</param>
        /// <param name="MinValue">The value for the minimum. If <paramref name="MinType"/> is Value, you can just set this to "0".</param>
        /// <param name="MinColor">The theme color for the minimum.</param>
        /// <param name="MinColorTint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
        /// <param name="MaxType">The conditional format type for the maximum.</param>
        /// <param name="MaxValue">The value for the maximum. If <paramref name="MaxType"/> is Value, you can just set this to "0".</param>
        /// <param name="MaxColor">The color for the maximum.</param>
        public void SetCustom2ColorScale(SLConditionalFormatMinMaxValues MinType, string MinValue, SLThemeColorIndexValues MinColor, double MinColorTint,
            SLConditionalFormatMinMaxValues MaxType, string MaxValue, System.Drawing.Color MaxColor)
        {
            List<System.Drawing.Color> listempty = new List<System.Drawing.Color>();
            SLColor minclr = new SLColor(listempty, listempty);
            if (MinColorTint == 0) minclr.SetThemeColor(MinColor);
            else minclr.SetThemeColor(MinColor, MinColorTint);
            SLColor maxclr = new SLColor(listempty, listempty);
            maxclr.Color = MaxColor;

            SLColor midclr = new SLColor(listempty, listempty);
            this.SetCustomColorScale(MinType, MinValue, minclr, false, SLConditionalFormatRangeValues.Percentile, "", midclr, MaxType, MaxValue, maxclr);
        }
Example #26
0
 private void SetAllNull()
 {
     this.clrForegroundColor = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasForegroundColor = false;
     this.clrBackgroundColor = new SLColor(this.listThemeColors, this.listIndexedColors);
     HasBackgroundColor = false;
     this.vPatternType = PatternValues.None;
     HasPatternType = false;
 }
 /// <summary>
 /// Set a custom data bar formatting.
 /// </summary>
 /// <param name="ShowBarOnly">True to show only the data bar. False to show both data bar and value.</param>
 /// <param name="MinLength">The minimum length of the data bar as a percentage of the cell width. The default value is 10.</param>
 /// <param name="MaxLength">The maximum length of the data bar as a percentage of the cell width. The default value is 90.</param>
 /// <param name="ShortestBarType">The conditional format type for the shortest bar.</param>
 /// <param name="ShortestBarValue">The value for the shortest bar. If <paramref name="ShortestBarType"/> is Value, you can just set this to "0".</param>
 /// <param name="LongestBarType">The conditional format type for the longest bar.</param>
 /// <param name="LongestBarValue">The value for the longest bar. If <paramref name="LongestBarType"/> is Value, you can just set this to "0".</param>
 /// <param name="BarColor">The theme color to be used for the data bar.</param>
 /// <param name="Tint">The tint applied to the theme color, ranging from -1.0 to 1.0. Negative tints darken the theme color and positive tints lighten the theme color.</param>
 public void SetCustomDataBar(bool ShowBarOnly, uint MinLength, uint MaxLength, SLConditionalFormatMinMaxValues ShortestBarType, string ShortestBarValue, SLConditionalFormatMinMaxValues LongestBarType, string LongestBarValue, SLThemeColorIndexValues BarColor, double Tint)
 {
     List<System.Drawing.Color> listempty = new List<System.Drawing.Color>();
     SLColor clr = new SLColor(listempty, listempty);
     clr.SetThemeColor(BarColor, Tint);
     this.SetCustomDataBar(ShowBarOnly, MinLength, MaxLength, ShortestBarType, ShortestBarValue, LongestBarType, LongestBarValue, clr);
 }