List <ColorCodingItemMsx> ConvertCondFormatRulesToColorCodingItems( CondFormatRules rules) { List <ColorCodingItemMsx> ccl = new List <ColorCodingItemMsx>(); double v1, v2; foreach (CondFormatRule r in rules) { ColorCodingItemMsx i = new ColorCodingItemMsx(); i.ColumnName = r.Name; if (rules.ColoringStyle == CondFormatStyle.ColorSet) { i.BackColor = r.BackColor1; } else // Gradient { //i.ImageName = r.ImageName; Color[] colors = Bitmaps.GetColorSetByName(Bitmaps.ColorScaleImageColors, r.ImageName); if (colors == null) { Bitmaps.GetColorSetByName(Bitmaps.ColorScaleImageColors, CondFormat.DefaultColorScale); } if (colors == null) { colors = new Color[] { Color.LightGray, Color.DarkGray } } ; int cl = colors.Length; if (cl > 0) { i.SubRules.Add(BuildSubrule(r.Value, colors[0])); } if (cl == 3) { i.SubRules.Add(BuildSubrule("Average", colors[1])); i.SubRules.Add(BuildSubrule(r.Value2, colors[2])); } else if (cl == 2) { i.SubRules.Add(BuildSubrule(r.Value2, colors[1])); } } ccl.Add(i); } return(ccl); } ColorCodingSubRuleMsx BuildSubrule( string value, Color color) { ColorCodingSubRuleMsx sr = new ColorCodingSubRuleMsx(); if (Lex.Contains(value, "min")) { sr.CalcType = ValueCalcTypeEnumMsx.Min; } else if (Lex.Contains(value, "avg")) { sr.CalcType = ValueCalcTypeEnumMsx.Average; } else if (Lex.Contains(value, "max")) { sr.CalcType = ValueCalcTypeEnumMsx.Max; } else { sr.CalcType = ValueCalcTypeEnumMsx.Value; sr.Value = value; } sr.Color = color; return(sr); } }
private void ShowColumnSelectorMenu() { throw new NotImplementedException(); // todo... #if false QueryColumn qc; DataRow dr; ColumnMapMsx colMap; int ri, ci; MouseEventArgs e = LastMouseDownEventArgs; Point p = new Point(e.X, e.Y); BandedGridHitInfo ghi = V.CalcHitInfo(p); ri = ghi.RowHandle; //if (ri < 0) return; BandedGridColumn col = ghi.Column; if (col == null) { return; } ci = col.AbsoluteIndex; if (ci != LabelCol) { return; } qc = null; // existing assignment if (ri != GridControl.NewItemRowHandle) { dr = DataTable.Rows[ri]; string spotfireName = dr[LabelCol] as string; qc = CurrentMap.ColumnMapCollection.GetQueryColumnForSpotfireColumnName(spotfireName); } ColumnSelectorFromQueryMsx csc = new ColumnSelectorFromQueryMsx(); csc.Setup(SVP, qc); csc.Flags.ExcludeNonNumericTypes = true; Point screenLoc = this.PointToScreen(p); QueryColumn qc2 = csc.ShowMenu(screenLoc); if (qc2 == null) { return; } if (ri == GridControl.NewItemRowHandle) // adding row { dr = DataTable.NewRow(); DataTable.Rows.Add(dr); if (IconImage.Visible) { dr[ValCol] = "(Min)"; dr[ValCol2] = "(Max)"; dr[IconImageCol] = Bitmaps.GetImageIndexFromName(ColumnImageCollection, CondFormat.DefaultColorScale); } else { Color[] ca = Bitmaps.GetColorSetByName(Bitmaps.ColorSetImageColors, CondFormat.DefaultColorSet); if (ca != null && ca.Length > 0) { dr[BackColorCol1] = ca[DataTable.Rows.Count % ca.Length]; } } } else { dr = DataTable.Rows[ri]; } colMap = CurrentMap.UpdateColumnMapList(qc2); dr[LabelCol] = colMap.SpotfireColumnName; return; #endif }