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); }
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); }