/// <summary> /// PctScaleToGraphScale /// </summary> /// <param name="pct"></param> /// <returns></returns> public static double PctScaleToGraphScale(int pct) { double zoom = GeometryMx.ConvertValueBetweenRanges( pct, 1, 100, NodeXLControl.MinimumGraphScale, NodeXLControl.MaximumGraphScale); return(zoom); }
/// <summary> /// GraphScaleToPctScale /// </summary> /// <param name="zoom"></param> /// <returns></returns> public static int GraphScaleToPctScale(double zoom) { double pct = GeometryMx.ConvertValueBetweenRanges( zoom, NodeXLControl.MinimumGraphScale, NodeXLControl.MaximumGraphScale, 1, 100); return((int)pct); }
/// <summary> /// Build a rule that provides the appropriate color for the supplied range limit values and colors (newer single-between-rule CF) /// </summary> /// <param name="v"></param> /// <param name="rule"></param> /// <returns></returns> public static CondFormatRule BuildColorRuleForColorScale(double v, CondFormatRule rule) { Color c = Color.Transparent; Color c0, c1, c2; double v1 = rule.ValueNumber; double v2 = rule.Value2Number; CondFormatRule r2 = new CondFormatRule(); Color[] colors = Bitmaps.GetColorSetByName(Bitmaps.ColorScaleImageColors, rule.ImageName); if (colors == null) { return(r2); } if (colors.Length == 2) // 2-Color gradient { if (v1 <= v2) // normal gradient { c = CalculateColorForGradientValue(v, v1, v2, colors[0], colors[1]); } else // reverse gradient { c = CalculateColorForGradientValue(v, v2, v1, colors[1], colors[0]); } } else if (colors.Length == 3) // 3-color gradient { double midpoint = GeometryMx.Midpoint(v1, v2); if (v1 <= v2) // normal gradient { if (v < midpoint) // get color between first two colors { c = CalculateColorForGradientValue(v, v1, midpoint, colors[0], colors[1]); } else // get color between second two colors { c = CalculateColorForGradientValue(v, midpoint, v2, colors[1], colors[2]); } } else // reverse gradient { if (v < midpoint) // get color between first two colors { c = CalculateColorForGradientValue(v, v2, midpoint, colors[2], colors[1]); } else // get color between second two colors { c = CalculateColorForGradientValue(v, midpoint, v1, colors[1], colors[0]); } } } else { return(r2); } r2.BackColor1 = c; return(r2); }