Exemple #1
0
        internal void Dispose()
        {
            m_symbolPresenter.SetValue(ContentPresenter.ContentTemplateProperty, null);
            m_symbolPresenter.SetValue(ContentPresenter.ContentProperty, null);

            this.adornment         = null;
            this.PredefinedSymbol  = null;
            this.m_symbolPresenter = null;
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartAdornmentContainer"/> class.
 /// </summary>
 public ChartAdornmentContainer()
 {
     PredefinedSymbol = new SymbolControl();
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartAdornmentContainer"/> class.
 /// </summary>
 /// <param name="adornment"></param>
 public ChartAdornmentContainer(ChartAdornment adornment)
 {
     PredefinedSymbol = new SymbolControl();
     Adornment        = adornment;
 }
        /// <summary>
        /// Method is used to reset the adornment.
        /// </summary>
        internal void ResetAdornmentSelection(int?selectedIndex, bool isResetAll)
        {
            if (!isResetAll && selectedIndex != null &&
                Series.ActualArea.SelectedSeriesCollection.Contains(Series) &&
                Series.ActualArea.GetEnableSeriesSelection())
            {
                List <int> indexes = (from adorment in Series.Adornments
                                      where Series.ActualData[selectedIndex.Value] == adorment.Item
                                      select Series.Adornments.IndexOf(adorment)).ToList();

                UpdateAdornmentSelection(indexes, false);
            }
            else if (selectedIndex < Series.DataCount)
            {
                resetIndexes.Clear();

                if (selectedIndex != null && !isResetAll)
                {
                    if (Series is CircularSeriesBase && !double.IsNaN(((CircularSeriesBase)Series).GroupTo))
                    {
                        resetIndexes = (from adorment in Series.Adornments
                                        where Series.Segments[selectedIndex.Value].Item == adorment.Item
                                        select Series.Adornments.IndexOf(adorment)).ToList();
                    }
                    else if (Series.ActualXAxis is CategoryAxis && !(Series.ActualXAxis as CategoryAxis).IsIndexed &&
                             (Series.IsSideBySide && (!(Series is RangeSeriesBase)) &&
                              (!(Series is FinancialSeriesBase)) && !(Series is WaterfallSeries)))
                    {
                        resetIndexes = (from adorment in Series.Adornments
                                        where Series.GroupedActualData[selectedIndex.Value] == adorment.Item
                                        select Series.Adornments.IndexOf(adorment)).ToList();
                    }
                    else
                    {
                        resetIndexes = (from adorment in Series.Adornments
                                        where Series.ActualData[selectedIndex.Value] == adorment.Item
                                        select Series.Adornments.IndexOf(adorment)).ToList();
                    }
                }
                else if (isResetAll)
                {
                    resetIndexes = (from adorment in Series.Adornments
                                    select Series.Adornments.IndexOf(adorment)).ToList();
                }

                foreach (var index in resetIndexes)
                {
                    // Reset the adornment label
                    if (Series.adornmentInfo.LabelPresenters.Count > index && Series.adornmentInfo.ShowLabel &&
                        (Series.adornmentInfo.UseSeriesPalette || Series.adornmentInfo.Background != null || Series.adornmentInfo.BorderBrush != null))
                    {
                        Border border = null;
                        if (VisualTreeHelper.GetChildrenCount(Series.adornmentInfo.LabelPresenters[index]) > 0)
                        {
                            ContentPresenter contentPresenter = VisualTreeHelper.GetChild(Series.adornmentInfo.LabelPresenters[index], 0) as ContentPresenter;;

                            if (VisualTreeHelper.GetChildrenCount(contentPresenter) > 0)
                            {
                                border = VisualTreeHelper.GetChild(contentPresenter as ContentPresenter, 0) as Border;
                            }
                        }

                        if (border != null)
                        {
                            if (Series.Adornments[index].Background != null)
                            {
                                border.Background = Series.Adornments[index].Background;
                            }
                            else if (Series.adornmentInfo.UseSeriesPalette)
                            {
                                border.Background = Series.Adornments[index].Interior;
                            }

                            if (Series.adornmentInfo.BorderBrush != null)
                            {
                                border.BorderBrush = Series.Adornments[index].BorderBrush;
                            }
                            else if (Series.adornmentInfo.UseSeriesPalette)
                            {
                                border.BorderBrush = Series.Adornments[index].Interior;
                            }
                        }
                    }

                    // Reset the adornment connector line
                    if (Series.adornmentInfo.ConnectorLines.Count > index && Series.adornmentInfo.ShowConnectorLine)
                    {
                        Path path = Series.adornmentInfo.ConnectorLines[index];

                        if (Series.adornmentInfo.UseSeriesPalette && Series.adornmentInfo.ConnectorLineStyle == null)
                        {
                            path.Stroke = Series.Adornments[index].Interior;
                        }
                        else
                        {
                            path.ClearValue(Line.StrokeProperty);
                        }
                    }

                    // Reset the adornment symbol
                    if (Series.adornmentInfo.adormentContainers.Count > index)
                    {
                        SymbolControl symbol = Series.adornmentInfo.adormentContainers[index].PredefinedSymbol;

                        if (symbol != null && Series.adornmentInfo.ShowMarker)
                        {
                            Binding binding;

                            if (Series.adornmentInfo.SymbolInterior == null)
                            {
                                binding        = new Binding();
                                binding.Source = Series.Adornments[index];
                                binding.Path   = new PropertyPath("Interior");
                                symbol.SetBinding(SymbolControl.BackgroundProperty, binding);
                            }
                            else
                            {
                                binding        = new Binding();
                                binding.Source = Series.adornmentInfo;
                                binding.Path   = new PropertyPath("SymbolInterior");
                                symbol.SetBinding(SymbolControl.BackgroundProperty, binding);
                            }

                            if (Series.adornmentInfo.SymbolStroke == null)
                            {
                                binding        = new Binding();
                                binding.Source = Series.Adornments[index];
                                binding.Path   = new PropertyPath("Interior");
                                symbol.SetBinding(SymbolControl.BorderBrushProperty, binding);
                            }
                            else
                            {
                                binding        = new Binding();
                                binding.Source = Series.adornmentInfo;
                                binding.Path   = new PropertyPath("SymbolStroke");
                                symbol.SetBinding(SymbolControl.BorderBrushProperty, binding);
                            }
                        }
                    }
                }
            }
        }