public ChartColumn(ChartValue cv, NumberFormatInfo nfi, Color c1, double colWidth, double availableHeight, double range) { this.availableHeight = availableHeight; if (range == 0) { range = availableHeight; } this.range = range; vtext = new TextBlock(); Binding binding = new Binding(); binding.Source = this; binding.Path = new PropertyPath("ColumnValue"); binding.Converter = new NumberConverter(nfi); vtext.SetBinding(TextBlock.TextProperty, binding); vtext.HorizontalAlignment = HorizontalAlignment.Center; r = new Rectangle(); r.Width = colWidth; r.Height = 0; r.RadiusX = r.RadiusY = 2; HlsColor hls = new HlsColor(c1); hls.Lighten(.3f); Color c2 = hls.Color; hls = new HlsColor(c1); hls.Darken(.3f); Color stroke = hls.Color; r.Stroke = new SolidColorBrush(stroke); r.StrokeThickness = 1; r.Fill = new LinearGradientBrush(c1, c2, new Point(0, 0), new Point(0, 1)); TextBlock label = new TextBlock(); label.Text = cv.Label; label.HorizontalAlignment = HorizontalAlignment.Center; this.Children.Add(vtext); this.Children.Add(r); this.Children.Add(label); this.value = cv; this.SetValue(ColumnValueProperty, cv.Value); }
Brush GetPressedBrush() { if (_normal == null) { this._normal = this.Background; } if (_pressed == null) { SolidColorBrush temp = this._normal as SolidColorBrush; if (temp != null) { var hls = new HlsColor(temp.Color); hls.Darken(0.25f); _pressed = new SolidColorBrush(hls.Color); } else { _pressed = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x7A, 0xCC)); } } return(_highlight); }
void PopulateTheChart(StackPanel legend) { selectedSeries = null; foreach (ChartSeries s in data.AllSeries) { if (s.Values.Count > 0) { PathGeometry path = new PathGeometry(); PathFigure figure = new PathFigure(); path.Figures.Add(figure); figure.IsClosed = true; double x = 0; double min = s.Minimum; double max = s.Maximum; bool flip = false; if (s.Flipped) { double temp = max; max = -min; min = -temp; flip = true; } graphMin = Math.Min(graphMin, min); graphMax = Math.Max(graphMax, max); figure.StartPoint = new Point(0, 0); // Add the grid column labels along the bottom row. foreach (ChartValue cv in s.Values) { double v = cv.Value; if (flip) { v = -v; } figure.Segments.Add(new LineSegment(new Point(x, v), true)); x++; } if (x > 0) { x--; } figure.Segments.Add(new LineSegment(new Point(x, 0), true)); Path shape = new Path(); shape.Data = path; geometries.Add(path); Color c = (Color)s.Category.WpfColor; HlsColor hls = new HlsColor(c); hls.Darken(.25f); shape.Fill = new SolidColorBrush(Color.FromArgb(0xA0, c.R, c.G, c.B)); shape.Stroke = new SolidColorBrush(hls.Color); shape.StrokeThickness = 1; this.Children.Add(shape); graphWidth = Math.Max(graphWidth, x); AddLengenEntry(legend, s, shape); } } }