コード例 #1
0
        protected override Rect GetBoundingRectangleCore()
        {
            if (this.Series == null || this.Series.ChartArea == null || !this.Series.ChartArea.IsTemplateApplied)
            {
                return(base.GetBoundingRectangleCore());
            }
            FrameworkElement dataPointView = SeriesVisualStatePresenter.GetDataPointView(this.DataPoint);

            if (dataPointView != null)
            {
                return(new FrameworkElementAutomationPeer(dataPointView).GetBoundingRectangle());
            }
            AutomationPeer peerForElement = UIElementAutomationPeer.CreatePeerForElement((UIElement)this.Series);

            if (!(this.Series is LineSeries) || this.DataPoint.View == null || peerForElement == null)
            {
                return(base.GetBoundingRectangleCore());
            }
            Point anchorPoint       = this.DataPoint.View.AnchorPoint;
            Rect  rectangle         = RectExtensions.Expand(new Rect(anchorPoint.X, anchorPoint.Y, 0.0, 0.0), 2.0, 2.0);
            Rect  boundingRectangle = peerForElement.GetBoundingRectangle();
            Size  renderSize        = this.Series.SeriesPresenter.RootPanel.RenderSize;
            Size  size = RectExtensions.GetSize(boundingRectangle);

            return(RectExtensions.Translate(RectExtensions.Transform(rectangle, (Transform) new ScaleTransform()
            {
                ScaleX = (size.Width / renderSize.Width),
                ScaleY = (size.Height / renderSize.Height)
            }), boundingRectangle.X, boundingRectangle.Y));
        }