Пример #1
0
        /// <summary>
        /// Used for creating UIElement for rendering this segment. This method is not
        /// intended to be called explicitly outside the Chart but it can be overriden by
        /// any derived class.
        /// </summary>
        /// <param name="size">Size of the panel</param>
        /// <returns>
        /// retuns UIElement
        /// </returns>
        public override UIElement CreateVisual(Size size)
        {
            if (adormentContainer == null)
            {
                adormentContainer = new ChartAdornmentContainer(this);
            }

            return(adormentContainer);
        }
        /// <summary>
        /// Method is used to highlight the adornment.
        /// </summary>
        /// <param name="adornmentSelectedIndex">The Adornment Index</param>
        internal void UpdateAdornmentSelection(List <int> selectedAdornmentIndexes, bool isDataPointSelection)
        {
            Brush selectionBrush = null;

            if (Series.ActualArea.GetEnableSeriesSelection() && !isDataPointSelection)
            {
                selectionBrush = Series.ActualArea.GetSeriesSelectionBrush(Series);
            }
            else if (Series.ActualArea.GetEnableSegmentSelection())
            {
                selectionBrush = (Series as ISegmentSelectable).SegmentSelectionBrush;
            }

            if (selectionBrush != null)
            {
                if (selectedAdornmentIndexes != null && selectedAdornmentIndexes.Count > 0)
                {
                    foreach (var index in selectedAdornmentIndexes)
                    {
                        // Set selection brush to adornment label.
                        if (Series.adornmentInfo.ShowLabel && Series.adornmentInfo.LabelTemplate == null &&
                            (Series.adornmentInfo.UseSeriesPalette || Series.adornmentInfo.Background != null || Series.adornmentInfo.BorderBrush != null))
                        {
                            Border border = null;

                            if (Series.adornmentInfo.LabelPresenters.Count > 0 && 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, 0) as Border;
                                }
                            }

                            if (border != null)
                            {
                                if (border.Background != null)
                                {
                                    border.Background = selectionBrush;
                                }
                                if (border.BorderBrush != null)
                                {
                                    border.BorderBrush = selectionBrush;
                                }
                            }
                        }

                        // Set selection brush to adornment symbol
                        if (Series.adornmentInfo.ShowMarker && Series.adornmentInfo.adormentContainers.Count > 0)
                        {
                            ChartAdornmentContainer symbol = Series.adornmentInfo.adormentContainers[index];

                            if (symbol.PredefinedSymbol != null)
                            {
                                symbol.PredefinedSymbol.Background  = selectionBrush;
                                symbol.PredefinedSymbol.BorderBrush = selectionBrush;
                            }
                        }

                        // Set selection brush to adornment connector line.
                        if (Series.adornmentInfo.ConnectorLines.Count > 0 && Series.adornmentInfo.ShowConnectorLine)
                        {
                            Path line = Series.adornmentInfo.ConnectorLines[index];
                            line.Stroke = selectionBrush;
                        }
                    }
                }
            }
        }