private void Chart_SelectionChanged(object sender, Syncfusion.UI.Xaml.Charts.ChartSelectionChangedEventArgs e)
        {
            if (e.SelectedSegment == null)
            {
                return;
            }

            ViewModel viewModel = (sender as SfChart).Series[0].DataContext as ViewModel;
            string    Category  = (e.SelectedSegment.Item as CompanyExpense).Category;

            if (Category == "Home")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).Home;
                viewModel.PieConverter = viewModel.Home;
            }
            else if (Category == "Daily Living")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).DailyLiving;
                viewModel.PieConverter = viewModel.DailyLiving;
            }
            else if (Category == "Entertainment")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).Entertainment;
                viewModel.PieConverter = viewModel.Entertainment;
            }
            else if (Category == "Health")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).Health;
                viewModel.PieConverter = viewModel.Health;
            }
            else if (Category == "Transportation")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).Transportation;
                viewModel.PieConverter = viewModel.Transportation;
            }
            else if (Category == "Personal")
            {
                (sender as SfChart).Series[0].ItemsSource = (e.SelectedSeries.DataContext as ViewModel).Personal;
                viewModel.PieConverter = viewModel.Personal;
            }
            (this.AssociatedObject.DataContext as ViewModel).BackButtonVisibility = Visibility.Visible;
        }
        /// <summary>
        /// Method used to set SegmentSelectionBrush to SelectedIndex segment
        /// </summary>
        /// <param name="newIndex"></param>
        /// <param name="oldIndex"></param>
        protected internal override void SelectedIndexChanged(int newIndex, int oldIndex)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            if (ActualArea != null && ActualArea.SelectionBehaviour != null)
            {
                // Resets the adornment selection when the mouse pointer moved away from the adornment or clicked the same adornment.
                if (ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single)
                {
                    if (SelectedSegmentsIndexes.Contains(oldIndex))
                    {
                        SelectedSegmentsIndexes.Remove(oldIndex);
                    }

                    OnResetSegment(oldIndex);
                }

                if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                {
                    if (!SelectedSegmentsIndexes.Contains(newIndex))
                    {
                        SelectedSegmentsIndexes.Add(newIndex);
                    }

                    // Selects the adornment when the mouse is over or clicked on adornments(adornment selection).
                    if (adornmentInfo != null && adornmentInfo.HighlightOnSelection)
                    {
                        UpdateAdornmentSelection(newIndex);
                    }

                    if (ActualArea != null && Segments.Count > 0)
                    {
                        chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                        {
                            SelectedSegment         = Segments[0],
                            SelectedSegments        = Area.SelectedSegments,
                            SelectedSeries          = this,
                            SelectedIndex           = newIndex,
                            PreviousSelectedIndex   = oldIndex,
                            NewPointInfo            = GetDataPoint(newIndex),
                            PreviousSelectedSeries  = null,
                            PreviousSelectedSegment = null,
                            IsSelected = true
                        };

                        chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;

                        if (oldIndex != -1)
                        {
                            chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                            chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                        }

                        (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                        PreviousSelectedIndex = newIndex;
                    }
                    else if (Segments.Count == 0)
                    {
                        triggerSelectionChangedEventOnLoad = true;
                    }
                }
                else if (newIndex == -1 && ActualArea != null)
                {
                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSegments        = Area.SelectedSegments,
                        SelectedSeries          = null,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = oldIndex,
                        PreviousSelectedSegment = null,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };

                    if (oldIndex != -1)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                        chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                    }

                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    PreviousSelectedIndex = newIndex;
                }
            }
            else if (newIndex >= 0 && Segments.Count == 0)
            {
                triggerSelectionChangedEventOnLoad = true;
            }
        }
        internal override void SelectedSegmentsIndexes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

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

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

                    if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                    {
                        // Selects the adornment when the mouse is over or clicked on adornments(adornment selection).
                        if (adornmentInfo != null && adornmentInfo.HighlightOnSelection)
                        {
                            UpdateAdornmentSelection(newIndex);
                        }

                        if (ActualArea != null && Segments.Count > 0)
                        {
                            chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                            {
                                SelectedSegment         = Segments[0],
                                SelectedSegments        = Area.SelectedSegments,
                                SelectedSeries          = this,
                                SelectedIndex           = newIndex,
                                PreviousSelectedIndex   = oldIndex,
                                NewPointInfo            = GetDataPoint(newIndex),
                                PreviousSelectedSeries  = null,
                                PreviousSelectedSegment = null,
                                IsSelected = true
                            };

                            chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;

                            if (oldIndex != -1)
                            {
                                chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                                chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                            }

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

                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldItems != null && !(ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single))
                {
                    int newIndex = (int)e.OldItems[0];

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

                    if (PreviousSelectedIndex != -1)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                        chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(PreviousSelectedIndex);
                    }

                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    OnResetSegment(newIndex);
                    PreviousSelectedIndex = newIndex;
                }

                break;
            }
        }
Example #4
0
        /// <summary>
        /// Method used to set SegmentSelectionBrush to <see cref="SelectedIndex"/> <see cref="ChartSegment3D"/>
        /// and trigger chart selection event.
        /// </summary>
        /// <param name="newIndex">The New Index</param>
        /// <param name="oldIndex">The Old Index</param>
        protected internal override void SelectedIndexChanged(int newIndex, int oldIndex)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            if (this.ActualArea != null)
            {
                ChartSegment3D segment;

                // Reset the oldIndex segment Interior
                if (this.Area.SelectionStyle == SelectionStyle3D.Single)
                {
                    if (SelectedSegmentsIndexes.Contains(oldIndex))
                    {
                        SelectedSegmentsIndexes.Remove(oldIndex);
                    }

                    this.OnResetSegment(oldIndex);
                }

                if (newIndex >= 0 && (ActualArea as SfChart3D).EnableSegmentSelection)
                {
                    if (!SelectedSegmentsIndexes.Contains(newIndex))
                    {
                        SelectedSegmentsIndexes.Add(newIndex);
                    }

                    // Set the SegmentSelectionBrush to newIndex segment Interior
                    if (newIndex < Segments.Count && this.SegmentSelectionBrush != null)
                    {
                        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 >= 0 && 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;
                    }
                }
                else if (newIndex == -1 && this.ActualArea != null)
                {
                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSegments        = this.Area.SelectedSegments,
                        SelectedSeries          = null,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = oldIndex,
                        PreviousSelectedSegment = null,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };

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

                    (ActualArea as SfChart3D).OnSelectionChanged(chartSelectionChangedEventArgs);
                    this.PreviousSelectedIndex = newIndex;
                }
            }
        }
Example #5
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;
            }
        }
        /// <summary>
        /// Method used to set SegmentSelectionBrush to SelectedIndex segment
        /// </summary>
        /// <param name="newIndex"></param>
        /// <param name="oldIndex"></param>
        protected internal override void SelectedIndexChanged(int newIndex, int oldIndex)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            if (ActualArea != null && ActualArea.SelectionBehaviour != null && !ActualArea.GetEnableSeriesSelection())
            {
                // Reset the old segment
                if (ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single)
                {
                    if (SelectedSegmentsIndexes.Contains(oldIndex))
                    {
                        SelectedSegmentsIndexes.Remove(oldIndex);
                    }

                    OnResetSegment(oldIndex);
                }

                if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                {
                    if (!SelectedSegmentsIndexes.Contains(newIndex))
                    {
                        SelectedSegmentsIndexes.Add(newIndex);
                    }

                    dataPoint = GetDataPoint(newIndex);

                    if (dataPoint != null && SegmentSelectionBrush != null)
                    {
                        // Selects the adornment when the mouse is over or clicked on adornments(adornment selection).
                        if (adornmentInfo != null && adornmentInfo.HighlightOnSelection)
                        {
                            UpdateAdornmentSelection(newIndex);
                        }

                        // Generate pixels for the particular data point
                        if (Segments.Count > 0)
                        {
                            if (Segments.Count > 0)
                            {
                                GeneratePixels();
                            }
                        }

                        // Set the SegmentSelectionBrush to the selected segment pixels
                        OnBitmapSelection(selectedSegmentPixels, SegmentSelectionBrush, true);
                    }

                    // trigger the SelectionChanged event.
                    if (ActualArea != null && Segments.Count > 0)
                    {
                        chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                        {
                            SelectedSegment       = Segments[0],
                            SelectedSegments      = Area.SelectedSegments,
                            SelectedSeries        = this,
                            SelectedIndex         = newIndex,
                            PreviousSelectedIndex = oldIndex,
                            NewPointInfo          = GetDataPoint(newIndex),
                            IsSelected            = true
                        };

                        chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;

                        if (oldIndex != -1)
                        {
                            chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                            chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                        }

                        (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                        PreviousSelectedIndex = newIndex;
                    }
                    else if (Segments.Count == 0)
                    {
                        triggerSelectionChangedEventOnLoad = true;
                    }
                }
                else if (newIndex == -1 && ActualArea != null)
                {
                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSegments        = Area.SelectedSegments,
                        SelectedSeries          = null,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = oldIndex,
                        PreviousSelectedSeries  = this,
                        PreviousSelectedSegment = null,
                        IsSelected = false
                    };

                    if (oldIndex != -1)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = GetDataPoint(oldIndex);
                        chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                    }

                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    PreviousSelectedIndex = newIndex;
                }
            }
            else if (newIndex >= 0 && Segments.Count == 0)
            {
                triggerSelectionChangedEventOnLoad = true;
            }
        }
Example #7
0
        /// <summary>
        /// Method used to set segment selection brush to selected index chart segment and trigger chart selection event
        /// </summary>
        /// <param name="newIndex">The New Index</param>
        /// <param name="oldIndex">The Old Index</param>
        protected internal override void SelectedIndexChanged(int newIndex, int oldIndex)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            if (this.ActualArea != null)
            {
                if (newIndex >= 0 && (ActualArea as SfChart3D).EnableSegmentSelection)
                {
                    if (Segments.Count > 0)
                    {
                        chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                        {
                            SelectedSegment       = this.SelectedSegment,
                            SelectedSegments      = Area.SelectedSegments,
                            SelectedSeries        = this,
                            SelectedIndex         = newIndex,
                            PreviousSelectedIndex = oldIndex,
                            IsSelected            = true
                        };

                        chartSelectionChangedEventArgs.PreviousSelectedSeries = Area.PreviousSelectedSeries;

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

                        (ActualArea as SfChart3D).OnSelectionChanged(chartSelectionChangedEventArgs);
                        this.PreviousSelectedIndex = newIndex;
                    }
                    else if (Segments.Count == 0)
                    {
                        this.triggerSelectionChangedEventOnLoad = true;
                    }
                }
                else if (newIndex == -1 && this.ActualArea != null)
                {
                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSeries          = null,
                        SelectedSegments        = Area.SelectedSegments,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = oldIndex,
                        PreviousSelectedSegment = null,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };

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

                    (ActualArea as SfChart3D).OnSelectionChanged(chartSelectionChangedEventArgs);
                    this.PreviousSelectedIndex = newIndex;
                }
            }
        }
Example #8
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)
                    {
                        if (Segments.Count > 0)
                        {
                            chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                            {
                                SelectedSegment       = this.SelectedSegment,
                                SelectedSegments      = Area.SelectedSegments,
                                SelectedSeries        = this,
                                SelectedIndex         = newIndex,
                                PreviousSelectedIndex = oldIndex,
                                IsSelected            = true
                            };

                            chartSelectionChangedEventArgs.PreviousSelectedSeries = Area.PreviousSelectedSeries;

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

                            (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,
                        SelectedSeries          = null,
                        SelectedSegments        = Area.SelectedSegments,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = PreviousSelectedIndex,
                        PreviousSelectedSegment = null,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };

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

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

                break;
            }
        }
        internal override void SelectedSegmentsIndexes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

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

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

                    // For adornment selection implementation
                    if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                    {
                        dataPoint = GetDataPoint(newIndex);

                        if (dataPoint != null && SegmentSelectionBrush != null)
                        {
                            // Selects the adornment when the mouse is over or clicked on adornments(adornment selection).
                            if (adornmentInfo != null && adornmentInfo.HighlightOnSelection)
                            {
                                UpdateAdornmentSelection(newIndex);
                            }

                            // Generate pixels for the particular data point
                            if (Segments.Count > 0)
                            {
                                GeneratePixels();
                            }

                            // Set the SegmentSelectionBrush to the selected segment pixels
                            OnBitmapSelection(selectedSegmentPixels, SegmentSelectionBrush, true);
                        }

                        // trigger the SelectionChanged event
                        if (ActualArea != null && Segments.Count > 0)
                        {
                            chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                            {
                                SelectedSegment       = Segments[0],
                                SelectedSegments      = Area.SelectedSegments,
                                SelectedSeries        = this,
                                SelectedIndex         = newIndex,
                                PreviousSelectedIndex = oldIndex,
                                NewPointInfo          = GetDataPoint(newIndex),
                                IsSelected            = true
                            };

                            chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;

                            if (oldIndex != -1)
                            {
                                chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                                chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                            }

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

                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldItems != null && ActualArea.SelectionBehaviour.SelectionStyle != SelectionStyle.Single)
                {
                    int newIndex = (int)e.OldItems[0];

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

                    if (PreviousSelectedIndex != -1)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = Segments[0];
                        chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(PreviousSelectedIndex);
                    }

                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    OnResetSegment(newIndex);
                    PreviousSelectedIndex = newIndex;
                }

                break;
            }
        }
Example #10
0
        internal override void SelectedSegmentsIndexes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;
            ChartSegment prevSelectedSegment = null;

            if (prevDataPoint != null && Segments.Count > 0)
            {
                prevSelectedSegment = (from segment in Segments
                                       where segment is FastLineSegment &&
                                       (segment as FastLineSegment).xChartVals.Contains(prevDataPoint.XData)
                                       select segment).FirstOrDefault() as ChartSegment;
            }

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

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

                    // For adornment selection implementation
                    if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                    {
                        // Selects the adornment when the mouse is over or clicked on adornments(adornment selection).
                        if (adornmentInfo != null && adornmentInfo.HighlightOnSelection)
                        {
                            UpdateAdornmentSelection(newIndex);
                        }

                        if (ActualArea != null && Segments.Count > 0)
                        {
                            var selectedSegment = (from segment in Segments
                                                   where segment is FastLineSegment &&
                                                   (segment as FastLineSegment).xChartVals.Contains(dataPoint.XData)
                                                   select segment).FirstOrDefault();

                            if (selectedSegment != null)
                            {
                                chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                                {
                                    SelectedSegment       = selectedSegment,
                                    SelectedSegments      = Area.SelectedSegments,
                                    SelectedSeries        = this,
                                    SelectedIndex         = newIndex,
                                    PreviousSelectedIndex = oldIndex,
                                    NewPointInfo          = GetDataPoint(newIndex),
                                    IsSelected            = true
                                };

                                chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;

                                if (oldIndex != -1)
                                {
                                    chartSelectionChangedEventArgs.PreviousSelectedSegment = prevSelectedSegment;
                                    chartSelectionChangedEventArgs.OldPointInfo            = GetDataPoint(oldIndex);
                                }

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

                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldItems != null && !(ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single))
                {
                    int newIndex = (int)e.OldItems[0];

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

                    if (PreviousSelectedIndex != -1)
                    {
                        chartSelectionChangedEventArgs.PreviousSelectedSegment = prevSelectedSegment;
                    }

                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    OnResetSegment(newIndex);
                    PreviousSelectedIndex = newIndex;
                }

                break;
            }
        }
Example #11
0
 /// <summary>
 /// Invoked whenever the SelectionChanged event have raised.
 /// </summary>
 /// <param name="args"></param>
 protected internal virtual void OnSelectionChanged(ChartSelectionChangedEventArgs eventArgs)
 {
 }
        /// <summary>
        /// Method used to set SegmentSelectionBrush to selectedindex chartsegment
        /// </summary>
        /// <param name="newIndex"/>
        /// <param name="oldIndex"/>
        protected internal override void SelectedIndexChanged(int newIndex, int oldIndex)
        {
            CircularSeriesBase circularseries = this as CircularSeriesBase;
            bool isGroupTo = circularseries != null && !double.IsNaN(circularseries.GroupTo);
            ChartSelectionChangedEventArgs chartSelectionChangedEventArgs;

            if (ActualArea != null && ActualArea.SelectionBehaviour != null)
            {
                ChartSegment selectedSegment = null, oldSegment = null;

                // Reset the oldIndex segment Interior
                if (ActualArea.SelectionBehaviour.SelectionStyle == SelectionStyle.Single)
                {
                    if (SelectedSegmentsIndexes.Contains(oldIndex))
                    {
                        SelectedSegmentsIndexes.Remove(oldIndex);
                    }

                    OnResetSegment(oldIndex);
                }

                if (oldIndex != -1 && oldIndex < ActualData.Count)
                {
                    object oldItem = isGroupTo ? Segments[oldIndex].Item : ActualData[oldIndex];
                    oldSegment = Segments.Where(segment => segment.Item == oldItem).FirstOrDefault();
                }

                if (newIndex >= 0 && ActualArea.GetEnableSegmentSelection())
                {
                    if (!SelectedSegmentsIndexes.Contains(newIndex))
                    {
                        SelectedSegmentsIndexes.Add(newIndex);
                    }
                    if (Segments.Count == 0)
                    {
                        triggerSelectionChangedEventOnLoad = true;
                        return;
                    }

                    if (newIndex < Segments.Count || newIndex < ActualData.Count)
                    {
                        // For adornment selection implementation
                        if (adornmentInfo is ChartAdornmentInfo && adornmentInfo.HighlightOnSelection)
                        {
                            UpdateAdornmentSelection(newIndex);
                        }

                        // Set the SegmentSelectionBrush to newIndex segment Interior
                        if (this is ISegmentSelectable)
                        {
                            object newItem = isGroupTo ? Segments[newIndex].Item : ActualData[newIndex];
                            selectedSegment = Segments.Where(segment => segment.Item == newItem).FirstOrDefault();
                            if (selectedSegment != null)
                            {
                                if (this.SegmentSelectionBrush != null)
                                {
                                    selectedSegment.BindProperties();
                                }
                                selectedSegment.IsSelectedSegment = true;
                            }
                        }
                    }

                    if (newIndex < Segments.Count || newIndex < ActualData.Count)
                    {
                        chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                        {
                            SelectedSegment         = selectedSegment,
                            SelectedSegments        = Area.SelectedSegments,
                            SelectedSeries          = this,
                            SelectedIndex           = newIndex,
                            PreviousSelectedIndex   = oldIndex,
                            PreviousSelectedSegment = oldSegment,
                            NewPointInfo            = selectedSegment != null ? selectedSegment.Item : null,
                            OldPointInfo            = oldSegment != null ? oldSegment.Item : null,
                            PreviousSelectedSeries  = null,
                            IsSelected = true
                        };

                        if (this.ActualArea.PreviousSelectedSeries != null && oldIndex != -1)
                        {
                            chartSelectionChangedEventArgs.PreviousSelectedSeries = this.ActualArea.PreviousSelectedSeries;
                        }

                        (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                        PreviousSelectedIndex = newIndex;
                    }
                }
                else if (newIndex == -1)
                {
                    chartSelectionChangedEventArgs = new ChartSelectionChangedEventArgs()
                    {
                        SelectedSegment         = null,
                        SelectedSegments        = Area.SelectedSegments,
                        SelectedSeries          = null,
                        SelectedIndex           = newIndex,
                        PreviousSelectedIndex   = oldIndex,
                        PreviousSelectedSegment = oldSegment,
                        NewPointInfo            = null,
                        OldPointInfo            = oldSegment.Item,
                        PreviousSelectedSeries  = this,
                        IsSelected = false
                    };
                    (ActualArea as SfChart).OnSelectionChanged(chartSelectionChangedEventArgs);
                    PreviousSelectedIndex = newIndex;
                }
            }
        }