Exemplo n.º 1
0
        protected override void BindViewToDataPoint(DataPoint dataPoint, FrameworkElement view, string valueName)
        {
            IAppearanceProvider appearanceProvider = (IAppearanceProvider)dataPoint;

            if (appearanceProvider != null)
            {
                BarControl barControl = view as BarControl;
                if (barControl != null)
                {
                    if (valueName == "Fill" || valueName == null)
                    {
                        barControl.Background = appearanceProvider.Fill;
                    }
                    if (valueName == "Stroke" || valueName == null)
                    {
                        barControl.BorderBrush = appearanceProvider.Stroke;
                    }
                    if (valueName == "StrokeThickness" || valueName == null)
                    {
                        barControl.BorderThickness = new Thickness(appearanceProvider.StrokeThickness);
                    }
                    if (valueName == "Opacity" || valueName == "ActualOpacity" || valueName == null)
                    {
                        barControl.Opacity = dataPoint.ActualOpacity;
                    }
                    if (valueName == "Effect" || valueName == "ActualEffect" || valueName == null)
                    {
                        barControl.Effect = dataPoint.ActualEffect;
                    }
                }
                else
                {
                    Shape shape = view as Shape;
                    if (shape != null)
                    {
                        if (valueName == "Fill" || valueName == null)
                        {
                            shape.Fill = dataPoint.Fill;
                        }
                        if (valueName == "Opacity" || valueName == "ActualOpacity" || valueName == null)
                        {
                            shape.Opacity = dataPoint.ActualOpacity;
                        }
                        if (valueName == "Effect" || valueName == "ActualEffect" || valueName == null)
                        {
                            shape.Effect = dataPoint.ActualEffect is ShaderEffect ? dataPoint.ActualEffect : (Effect)null;
                        }
                    }
                }
            }
            DataPointView dataPointView = dataPoint != null ? dataPoint.View : (DataPointView)null;

            if (dataPointView == null)
            {
                return;
            }
            this.LabelPresenter.BindViewToDataPoint(dataPoint, (FrameworkElement)dataPointView.LabelView, valueName);
            this.MarkerPresenter.BindViewToDataPoint(dataPoint, dataPointView.MarkerView, valueName);
        }
Exemplo n.º 2
0
        protected override void UpdateView(DataPoint dataPoint)
        {
            if (!this.IsDataPointViewVisible(dataPoint))
            {
                return;
            }
            DateTime    now         = DateTime.Now;
            XYDataPoint xyDataPoint = dataPoint as XYDataPoint;

            if (xyDataPoint != null && this.CanGraph(xyDataPoint))
            {
                DataPointView view = dataPoint.View;
                if (view != null)
                {
                    FrameworkElement mainView = view.MainView;
                    if (mainView != null)
                    {
                        bool            flag                = this.ChartArea.Orientation != Orientation.Horizontal;
                        RectOrientation rectOrientation     = RectOrientation.BottomTop;
                        Point           positionInAxisUnits = this.GetPositionInAxisUnits(xyDataPoint);
                        Point           point1              = new Point(Math.Round(positionInAxisUnits.X), Math.Round(positionInAxisUnits.Y));
                        object          crossingPosition    = this.Series.YAxis.Scale.ActualCrossingPosition;
                        Point           basePoint           = new Point(positionInAxisUnits.X, this.Series.YAxis.AxisPresenter.ConvertDataToAxisUnits(crossingPosition) ?? 0.0);
                        Point           point2              = new Point(Math.Round(basePoint.X), Math.Round(basePoint.Y));
                        double          num1                = point1.X + Math.Round(this.PointClusterOffset);
                        double          num2                = this.MinMaxScreenCoordinates(positionInAxisUnits.Y);
                        double          num3                = Math.Round(this.PointWidth);
                        double          height              = this.MinMaxScreenCoordinates(basePoint.Y - positionInAxisUnits.Y);
                        if (ValueHelper.Compare(xyDataPoint.YValue as IComparable, crossingPosition as IComparable) != 0 && Math.Abs(height) < 2.0 && this.CanAdjustHeight())
                        {
                            height = basePoint.Y - positionInAxisUnits.Y >= 0.0 ? 2.0 : -2.0;
                            num2   = point2.Y - height;
                        }
                        if (height < 0.0)
                        {
                            rectOrientation = RectOrientation.TopBottom;
                            height          = Math.Abs(height);
                            num2           -= height;
                        }
                        double num4 = this.MinMaxScreenCoordinates(this.GetYOffsetInAxisUnits(xyDataPoint, positionInAxisUnits, basePoint));
                        double num5 = Math.Round(num2 - num4);
                        double num6 = this.AdjustColumnHeight(height);
                        if (flag)
                        {
                            if (rectOrientation == RectOrientation.BottomTop)
                            {
                                rectOrientation = RectOrientation.RightLeft;
                            }
                            else if (rectOrientation == RectOrientation.TopBottom)
                            {
                                rectOrientation = RectOrientation.LeftRight;
                            }
                            Canvas.SetLeft((UIElement)mainView, num5);
                            Canvas.SetTop((UIElement)mainView, num1);
                            mainView.Width   = num6;
                            mainView.Height  = num3;
                            view.AnchorRect  = new Rect(num5, num1, num6, num3);
                            view.AnchorPoint = rectOrientation != RectOrientation.RightLeft ? new Point(num5 + num6, num1 + this.PointWidth / 2.0) : new Point(num5, num1 + this.PointWidth / 2.0);
                        }
                        else
                        {
                            Canvas.SetLeft((UIElement)mainView, num1);
                            Canvas.SetTop((UIElement)mainView, num5);
                            mainView.Width   = num3;
                            mainView.Height  = num6;
                            view.AnchorRect  = new Rect(num1, num5, num3, num6);
                            view.AnchorPoint = rectOrientation != RectOrientation.BottomTop ? new Point(num1 + this.PointWidth / 2.0, num5 + num6) : new Point(num1 + this.PointWidth / 2.0, num5);
                        }
                        BarControl barControl = mainView as BarControl;
                        if (barControl != null)
                        {
                            barControl.Orientation = rectOrientation;
                        }
                        view.AnchorRectOrientation = rectOrientation;
                    }
                }
            }
            base.UpdateView(dataPoint);
            if (this.ChartArea == null)
            {
                return;
            }
            this.ChartArea.UpdateSession.AddCounter("ColumnSeriesPresenter.UpdateView", DateTime.Now - now);
        }