Пример #1
0
 protected virtual void OnPlotDataChanged(
     IPlotDataSource oldValue, IPlotDataSource newValue)
 {
     UnsubscribeFromPlotDataChanging(oldValue);
     SubscribeToPlotDataUpdating(newValue);
     RaiseUpdatedEvent(GraphItemUpdateOptions.DataSourceChanged);
 }
Пример #2
0
        private void UnsubscribeFromPlotDataChanging(IPlotDataSource source)
        {
            if (source == null)
            {
                return;
            }

            source.PointsChanged -= PlotDataChanged;
        }
Пример #3
0
        private void SubscribeToPlotDataUpdating(IPlotDataSource source)
        {
            if (source == null)
            {
                return;
            }

            source.PointsChanged += PlotDataChanged;
        }
Пример #4
0
        internal void UpdatePosition(double realX)
        {
            mXCoordinate = realX;
            IPlotDataSource plotSource = mGraphItem.PlotData;

            if (plotSource == null)
            {
                return;
            }

            if (!UpdateVisibility())
            {
                return;
            }

            var realPnt = plotSource.Interpolate(realX);

            XValue = Math.Round(realPnt.X, TEXT_DOUBLE_PRECISION).ToString();
            YValue = Math.Round(realPnt.Y, TEXT_DOUBLE_PRECISION).ToString();

            GraphControlBase.SetBindPointX(this, realPnt.X);
            GraphControlBase.SetBindPointY(this, realPnt.Y);
        }
Пример #5
0
      private void UnsubscribeFromPlotDataChanging(IPlotDataSource source)
      {
         if (source == null)
            return;

         source.PointsChanged -= PlotDataChanged;
      }
Пример #6
0
      private void SubscribeToPlotDataUpdating(IPlotDataSource source)
      {
         if (source == null)
            return;

         source.PointsChanged += PlotDataChanged;
      }
Пример #7
0
 protected virtual void OnPlotDataChanged(
    IPlotDataSource oldValue, IPlotDataSource newValue)
 {
    UnsubscribeFromPlotDataChanging(oldValue);
    SubscribeToPlotDataUpdating(newValue);
    RaiseUpdatedEvent(GraphItemUpdateOptions.DataSourceChanged);
 }
Пример #8
0
        internal void Draw(DrawingContext dc, PointTranslater pt,
                           GraphDrawingOptions op)
        {
            IPlotDataSource plotData = PlotData;

            if (plotData == null)
            {
                return;
            }

            double plotDataBegin = plotData.GetSegmentBegin();
            double plotDataEnd   = plotData.GetSegmentEnd();
            double from          = Math.Max(Math.Max(op.From, SegmentBegin), plotDataBegin);
            double to            = Math.Min(Math.Min(op.To, SegmentEnd), plotDataEnd);

            if (from >= to)
            {
                return;
            }

            //plotData.SetZoom(pt.Zoom);
            plotData.SetSegment(from, to);
            var pointsToDraw = plotData.GetPoints();

            if (pointsToDraw == null)
            {
                return;
            }

            if (pointsToDraw.Count <= 1)
            {
                return;
            }

            var graphPen   = new Pen(StrokeBrush, StrokeThickness);
            int startIndex = plotData.GetStartIndex();

            if (startIndex < 0)
            {
                return;
            }

            Rect rect = op.GraphRect;

            rect.X     = pt.TransalteX(from);
            rect.Width = pt.TransalteX(to) - rect.X;
            Point next = pt.Translate(pointsToDraw[startIndex]);

            Point boundPoint;

            if (IsInterpolationEnabled)
            {
                boundPoint = plotData.Interpolate(from);
            }
            else
            {
                boundPoint = pointsToDraw[startIndex];
            }

            boundPoint = pt.Translate(boundPoint);
            if (IsInterpolationEnabled)
            {
                dc.DrawLine(graphPen, boundPoint, next);
            }

            if (rect.Left > op.GraphRect.Left)
            {
                dc.DrawEllipse(StrokeBrush, null, boundPoint,
                               BOUND_POINT_RADOUS, BOUND_POINT_RADOUS);
            }

            int endIndex = plotData.GetEndIndex();

            for (int i = startIndex; i <= endIndex; i++)
            {
                Point prev = next;
                next = pt.Translate(pointsToDraw[i]);
                if (!(rect.Contains(prev) || rect.Contains(next)))
                {
                    continue;
                }

                dc.DrawLine(graphPen, prev, next);
            }

            if (IsInterpolationEnabled)
            {
                boundPoint = plotData.Interpolate(to);
            }
            else
            {
                boundPoint = pointsToDraw[endIndex];
            }

            boundPoint = pt.Translate(boundPoint);
            if (IsInterpolationEnabled)
            {
                dc.DrawLine(graphPen, next, boundPoint);
            }

            if (rect.Right < op.GraphRect.Right)
            {
                dc.DrawEllipse(StrokeBrush, null, boundPoint,
                               BOUND_POINT_RADOUS, BOUND_POINT_RADOUS);
            }
        }