Beispiel #1
0
        /// <summary>
        /// Updates the <see cref="ChartSeries3D"/> when the segment is reset.
        /// </summary>
        /// <param name="index">The Index</param>
        internal override void OnResetSegment(int index)
        {
            if (index < Segments.Count && index >= 0)
            {
                ChartSegment3D segment = Segments[index] as ChartSegment3D;

                segment.BindProperties();

                foreach (var item in segment.Polygons)
                {
                    item.Fill = segment.Interior;
                    item.ReDraw();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the chart when the selected segment index collection changed.
        /// </summary>
        /// <param name="sender">The Sender</param>
        /// <param name="e">The Event Argument</param>
        internal override void SelectedSegmentsIndexes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewItems != null && !((ActualArea as SfChart3D).SelectionStyle == SelectionStyle3D.Single))
                {
                    int oldIndex = PreviousSelectedIndex;

                    int newIndex = (int)e.NewItems[0];

                    if (newIndex >= 0 && (ActualArea as SfChart3D).EnableSegmentSelection)
                    {
                        // Set the SegmentSelectionBrush to newIndex segment Interior
                        if (newIndex < Segments.Count && this.SegmentSelectionBrush != null)
                        {
                            ChartSegment3D segment = Segments[newIndex] as ChartSegment3D;
                            segment.BindProperties();

                            foreach (var item in segment.Polygons)
                            {
                                item.Fill = this.SegmentSelectionBrush;
                                item.ReDraw();
                            }
                        }

                        if (newIndex < Segments.Count)
                        {
                            chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                            {
                                SelectedSegment         = this.SelectedSegment,
                                SelectedSegments        = this.Area.SelectedSegments,
                                SelectedSeries          = this,
                                SelectedIndex           = newIndex,
                                PreviousSelectedIndex   = oldIndex,
                                NewPointInfo            = Segments[newIndex].Item,
                                PreviousSelectedSegment = null,
                                PreviousSelectedSeries  = null,
                                IsSelected = true
                            };

                            chartSelectionChangedEventArgs.PreviousSelectedSeries = this.Area.PreviousSelectedSeries;

                            if (oldIndex != -1 && oldIndex < Segments.Count)
                            {
                                chartSelectionChangedEventArgs.PreviousSelectedSegment = this.Segments[oldIndex];
                                chartSelectionChangedEventArgs.OldPointInfo            = Segments[oldIndex].Item;
                            }

                            (ActualArea as SfChart3D).OnSelectionChanged(chartSelectionChangedEventArgs);
                            this.PreviousSelectedIndex = newIndex;
                        }
                        else if (Segments.Count == 0)
                        {
                            this.triggerSelectionChangedEventOnLoad = true;
                        }
                    }
                }

                break;

            case NotifyCollectionChangedAction.Remove:

                if (e.OldItems != null && !((ActualArea as SfChart3D).SelectionStyle == SelectionStyle3D.Single))
                {
                    int newIndex = (int)e.OldItems[0];

                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSegments        = this.Area.SelectedSegments,
                        SelectedSeries          = null,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = PreviousSelectedIndex,
                        PreviousSelectedSegment = null,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };

                    if (this.PreviousSelectedIndex != -1 && this.PreviousSelectedIndex < Segments.Count)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = this.Segments[this.PreviousSelectedIndex];
                        chartSelectionChangedEventArgs.OldPointInfo            = Segments[PreviousSelectedIndex].Item;
                    }

                    (ActualArea as SfChart3D).OnSelectionChanged(chartSelectionChangedEventArgs);
                    this.PreviousSelectedIndex = newIndex;
                }

                break;
            }
        }