Ejemplo n.º 1
0
        private void UpdateSegmentStyle(PieDataPoint point, PieSegment segment, int index)
        {
            segment.isDefaultStyle     = false;
            segment.HighlightPath.Fill = this.HighlightBrush;

            if (this.segmentStyleSelectorCache != null)
            {
                Style style = this.segmentStyleSelectorCache.SelectStyle(point, this);
                if (style != null)
                {
                    segment.Path.Style = style;
                    return;
                }
            }

            if (this.segmentStyles.Count > 0)
            {
                Style style = this.segmentStyles[index % this.segmentStyles.Count];
                if (style != null)
                {
                    segment.Path.Style = style;
                    return;
                }
            }

            segment.Path.Style     = this.defaultSegmentStyleCache;
            segment.isDefaultStyle = true;
        }
Ejemplo n.º 2
0
        private void UpdateSegments()
        {
            int index         = 0;
            int realizedIndex = 0;

            foreach (PieDataPoint point in this.model.DataPoints)
            {
                if (point.isEmpty)
                {
                    index++;
                    continue;
                }

                if (point.isSelected && point.OffsetFromCenter == 0d)
                {
                    // the point is selected before the ElementTree is loaded, set the property silently (no invalidate)
                    point.SetPropertySilently(PieDataPoint.OffsetFromCenterPropertyKey, this.selectedPointOffsetCache);
                }

                PieSegment segment = this.GetSegment(realizedIndex);
                segment.Update(point, this.updateContext);

                this.UpdateSegmentStyle(point, segment, index);

                if (!this.LegendInfos.Contains(segment.LegendItem))
                {
                    this.LegendInfos.Add(segment.LegendItem);
                }

                if (!DesignMode.DesignModeEnabled)
                {
                    segment.UpdateLegendTitle(this.LegendTitleBinding);
                    segment.UpdateVisibleInLegend(this.IsVisibleInLegendBinding);
                }

                index++;
                realizedIndex++;

                if (point.SweepAngle > PieSegment.ArcSegmentMaxAngle)
                {
                    break;
                }
            }

            // hide extra segments
            while (realizedIndex < this.segments.Count)
            {
                this.segments[realizedIndex].point    = null;
                this.segments[realizedIndex].Path.Tag = null;

                this.segments[realizedIndex].Path.Visibility          = Visibility.Collapsed;
                this.segments[realizedIndex].HighlightPath.Visibility = Visibility.Collapsed;

                this.LegendInfos.Remove(this.segments[realizedIndex].LegendItem);

                realizedIndex++;
            }
        }
Ejemplo n.º 3
0
        internal override void ApplyPaletteCore()
        {
            base.ApplyPaletteCore();

            for (int i = 0; i < this.segments.Count; i++)
            {
                PieSegment segment = this.segments[i];

                if (segment.Path.Visibility == Visibility.Collapsed)
                {
                    continue;
                }

                Brush fill   = null;
                Brush stroke = null;

                // segment style has higher priority as it comes from our SliceStyles property
                // so it should be null in order to apply a palette entry values
                if (segment.isDefaultStyle)
                {
                    fill   = this.chart.GetPaletteBrush(segment.point.CollectionIndex, PaletteVisualPart.Fill, this.Family, segment.point.isSelected);
                    stroke = this.chart.GetPaletteBrush(segment.point.CollectionIndex, PaletteVisualPart.Stroke, this.Family, segment.point.isSelected);
                }

                if (fill != null)
                {
                    segment.Path.Fill = fill;
                }
                else
                {
                    segment.Path.ClearValue(Shape.FillProperty);
                }

                if (stroke != null)
                {
                    segment.Path.Stroke = stroke;
                }
                else
                {
                    segment.Path.ClearValue(Shape.StrokeProperty);
                }

                segment.UpdateLegendItem();
            }
        }