internal SLConditionalFormatAutoMinMaxValues TranslateMinMaxValues(SLConditionalFormatMinMaxValues MinMaxValue)
        {
            SLConditionalFormatAutoMinMaxValues result = SLConditionalFormatAutoMinMaxValues.Value;
            switch (MinMaxValue)
            {
                case SLConditionalFormatMinMaxValues.Formula:
                    result = SLConditionalFormatAutoMinMaxValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    result = SLConditionalFormatAutoMinMaxValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    result = SLConditionalFormatAutoMinMaxValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    result = SLConditionalFormatAutoMinMaxValues.Percentile;
                    break;
                case SLConditionalFormatMinMaxValues.Value:
                    result = SLConditionalFormatAutoMinMaxValues.Value;
                    break;
            }

            return result;
        }
        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 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 color of the data bar.</param>
        public void SetCustomDataBar(bool ShowBarOnly, uint MinLength, uint MaxLength, SLConditionalFormatMinMaxValues ShortestBarType, string ShortestBarValue, SLConditionalFormatMinMaxValues LongestBarType, string LongestBarValue, System.Drawing.Color BarColor)
        {
            SLDataBarOptions dbo = new SLDataBarOptions(false);
            dbo.ShowBarOnly = ShowBarOnly;
            dbo.MinLength = MinLength;
            dbo.MaxLength = MaxLength;
            dbo.MinimumType = this.TranslateMinMaxValues(ShortestBarType);
            dbo.MinimumValue = ShortestBarValue;
            dbo.MaximumType = this.TranslateMinMaxValues(LongestBarType);
            dbo.MaximumValue = LongestBarValue;
            dbo.FillColor.Color = BarColor;

            this.SetCustomDataBar(dbo);
        }
        /// <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)
        {
            SLDataBarOptions dbo = new SLDataBarOptions(false);
            dbo.ShowBarOnly = ShowBarOnly;
            dbo.MinLength = MinLength;
            dbo.MaxLength = MaxLength;
            dbo.MinimumType = this.TranslateMinMaxValues(ShortestBarType);
            dbo.MinimumValue = ShortestBarValue;
            dbo.MaximumType = this.TranslateMinMaxValues(LongestBarType);
            dbo.MaximumValue = LongestBarValue;
            dbo.FillColor.SetThemeColor(BarColor, Tint);

            this.SetCustomDataBar(dbo);
        }
        /// <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);
        }
        /// <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);
        }
        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);
        }
 /// <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);
 }