public void InitHighLow() { for (int i = 0; i < 7; i++) { string tag = this.GetTag(i); int code = CellColor.GetCellColorCode(tag); RefreshBrush(tag, i); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { DataRecord dr = value as DataRecord; double val = 0; switch (parameter.ToString()) { case "DateFore": return(BrushZero); case "OpenFore": val = System.Convert.ToDouble(dr.Open) - dr.BeforeClose; break; case "HighFore": val = dr.HighRaw - dr.BeforeClose; break; case "LowFore": val = dr.LowRaw - dr.BeforeClose; break; case "CloseFore": case "ChangeFore": int diff = dr.GetChange(); switch (diff) { case 1: return(BrushUp); case -1: return(BrushDown); default: return(BrushZero); } case "DiffFore": val = System.Convert.ToDouble(dr.Diff); break; case "DateBack": return(CellColor.GetCellColorCode(dr.GetTag(0))); break; case "OpenBack": return(BrushNone); break; case "HighBack": return(BrushNone); break; case "LowBack": return(BrushNone); break; case "CloseBack": return(BrushNone); break; case "ChangeBack": return(BrushNone); break; case "DiffBack": return(BrushNone); break; /* * case 7: * SolidColorBrush salmon = new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.6 }; * return dr.IsHigh ? salmon : Brushes.Transparent; * case 8: * SolidColorBrush skyblue = new SolidColorBrush(Colors.LightSkyBlue) { Opacity = 0.4 }; * return dr.IsLow ? skyblue : Brushes.Transparent; */ } if (val > 0) { return(BrushUp); } else if (val < 0) { return(BrushDown); } else { return(BrushZero); } } catch { return(BrushError); } }
private void RefreshBrush(string tag, int index) { int code = CellColor.GetCellColorCode(tag); Brush brush = Brushes.Transparent; if (code == 0) { if (index == 2 && this.IsHigh) { brush = new SolidColorBrush(Colors.LightSalmon) { Opacity = 0.8 }; } else if (index == 3 && this.IsLow) { brush = new SolidColorBrush(Colors.LightSkyBlue) { Opacity = 0.8 }; } } else { brush = CellColor.GetCellBrush(code); } switch (index) { case 0: DateBrush = brush; break; case 1: OpenBrush = brush; break; case 2: HighBrush = brush; break; case 3: LowBrush = brush; break; case 4: CloseBrush = brush; break; case 5: ChangeBrush = brush; break; case 6: DiffBrush = brush; break; default: return; } OnPropertyChanged(String.Format("{0}Brush", FieldArray[index])); }