Example #1
0
        internal override FrameworkElement GetLegendSymbol()
        {
            Grid grid = new Grid();

            grid.Width  = 20.0;
            grid.Height = 12.0;
            PointCollection pointCollection = new PointCollection();

            pointCollection.Add(new Point(0.0, 6.0));
            pointCollection.Add(new Point(20.0, 6.0));
            Collection <IAppearanceProvider> collection = new Collection <IAppearanceProvider>();
            LineDataPoint lineDataPoint1 = Enumerable.FirstOrDefault <LineDataPoint>(Enumerable.Where <LineDataPoint>(Enumerable.OfType <LineDataPoint>((IEnumerable)this.Series.DataPoints), (Func <LineDataPoint, bool>)(p =>
            {
                if (!p.ActualIsEmpty)
                {
                    return(p.IsVisible);
                }
                return(false);
            })));
            LineDataPoint lineDataPoint2 = this.Series.CreateDataPoint() as LineDataPoint;

            if (lineDataPoint1 != null)
            {
                lineDataPoint2.Stroke          = lineDataPoint1.Stroke;
                lineDataPoint2.StrokeThickness = lineDataPoint1.StrokeThickness;
                lineDataPoint2.StrokeDashType  = lineDataPoint1.StrokeDashType;
            }
            else if (this.Series.ItemsBinder != null)
            {
                this.Series.ItemsBinder.Bind((DataPoint)lineDataPoint2, this.Series.DataContext);
            }
            lineDataPoint2.Series = (Series)this.Series;
            collection.Add((IAppearanceProvider)lineDataPoint2);
            collection.Add((IAppearanceProvider)lineDataPoint2);
            lineDataPoint2.ActualEffect  = lineDataPoint2.Effect;
            lineDataPoint2.ActualOpacity = lineDataPoint2.Opacity;
            PolylineControl polylineControl = new PolylineControl();

            polylineControl.Points      = pointCollection;
            polylineControl.Appearances = collection;
            polylineControl.Update();
            polylineControl.Width  = 20.0;
            polylineControl.Height = 12.0;
            grid.Children.Add((UIElement)polylineControl);
            DataPoint dataPoint = (DataPoint)(lineDataPoint1 ?? lineDataPoint2);

            if (!this.IsSimplifiedRenderingModeEnabled && dataPoint.MarkerType != MarkerType.None)
            {
                FrameworkElement view = (FrameworkElement) new MarkerControl();
                this.MarkerPresenter.BindViewToDataPoint(dataPoint, view, (string)null);
                view.Opacity = lineDataPoint2.Opacity;
                view.Effect  = lineDataPoint2.Effect;
                grid.Children.Add((UIElement)view);
            }
            lineDataPoint2.Series = (Series)null;
            return((FrameworkElement)grid);
        }
Example #2
0
        public DataPoint GetDataPointFromMouseEvent(MouseButtonEventArgs e)
        {
            Polyline polyline1 = e.OriginalSource as Polyline;

            if (polyline1 != null)
            {
                PolylineControl polyline2 = polyline1.Parent as PolylineControl;
                if (polyline2 != null && polyline2.Parent is UIElement)
                {
                    return((DataPoint)LineSeriesPresenter.FindDataPoint(polyline2, e.GetPosition((IInputElement)(polyline2.Parent as UIElement))));
                }
            }
            return(this.GetDataPointFromVisualElement(e.OriginalSource as DependencyObject));
        }
Example #3
0
        internal static XYDataPoint FindDataPoint(PolylineControl polyline, Point position)
        {
            XYDataPoint xyDataPoint1 = (XYDataPoint)null;

            foreach (IAppearanceProvider appearanceProvider in polyline.Appearances)
            {
                XYDataPoint xyDataPoint2 = appearanceProvider as XYDataPoint;
                if (xyDataPoint2 != null && xyDataPoint2.View != null && !xyDataPoint2.ActualIsEmpty)
                {
                    if (xyDataPoint1 == null)
                    {
                        xyDataPoint1 = xyDataPoint2;
                    }
                    else if (LineSeriesPresenter.GetDistance(position, xyDataPoint2.View.AnchorPoint) < LineSeriesPresenter.GetDistance(position, xyDataPoint1.View.AnchorPoint))
                    {
                        xyDataPoint1 = xyDataPoint2;
                    }
                }
            }
            return(xyDataPoint1);
        }