Interaction logic for SelectionOverlay.xaml
Inheritance: System.Windows.Controls.Grid
Exemplo n.º 1
0
        internal void HandleZoomTooltip(ChartStack stack, Point mouseDownPos, Point pos)
        {
            Point localStartPos = stack.TransformToDescendant(this).Transform(mouseDownPos);
            Point localEndPos   = stack.TransformToDescendant(this).Transform(pos);

            if (localEndPos.X >= 0 && localEndPos.Y >= 0 && localEndPos.X < this.ActualWidth && localEndPos.Y < this.ActualHeight)
            {
                int s = FindNearestValue(localStartPos, true);
                int e = FindNearestValue(localEndPos, true);
                if (s >= 0 && e >= 0)
                {
                    DataValue startData    = series.Values[s];
                    DataValue endData      = series.Values[e];
                    Point     tipPosition  = this.TransformToDescendant(Graph).Transform(localEndPos);
                    double    microseconds = endData.X - startData.X;
                    TimeSpan  span         = TimeSpan.FromMilliseconds((double)microseconds / 1000.0);
                    double    seconds      = span.TotalSeconds;
                    double    diff         = endData.Y - startData.Y;
                    double    sum          = 0;
                    double    count        = e - s;
                    for (int i = s; i <= e; i++)
                    {
                        DataValue d = series.Values[i];
                        sum += d.Y;
                    }
                    double average = sum / count;
                    string msg     = string.Format("{0:N3} sec, avg={1:N4}, dist={2:N3}, rate={3:N3}, samples={4:N3}", seconds, average, diff, diff / seconds, e - s);
                    ShowTip(msg, tipPosition);
                }
                else
                {
                    HidePointer();
                }
            }
        }
Exemplo n.º 2
0
        internal void HandleZoomTooltip(ChartStack stack, Point mouseDownPos, Point pos)
        {
            Point localStartPos = stack.TransformToDescendant(this).Transform(mouseDownPos);
            Point localEndPos   = stack.TransformToDescendant(this).Transform(pos);

            if (localEndPos.X >= 0 && localEndPos.Y >= 0 && localEndPos.X < this.ActualWidth && localEndPos.Y < this.ActualHeight)
            {
                int s = FindNearestValue(localStartPos, true);
                int e = FindNearestValue(localEndPos, true);
                if (s >= 0 && e >= 0)
                {
                    DataValue startData    = series.Values[s];
                    DataValue endData      = series.Values[e];
                    Point     tipPosition  = this.TransformToDescendant(Graph).Transform(localEndPos);
                    double    microseconds = endData.X - startData.X;
                    TimeSpan  span         = new TimeSpan((long)microseconds * 10);
                    double    seconds      = span.TotalSeconds;
                    double    diff         = endData.Y - startData.Y;
                    string    msg          = string.Format("{0:N3} sec, dist={1:N3}, rate={2:N3}, samples={3:N3}", seconds, diff, diff / seconds, e - s);
                    ShowTip(msg, tipPosition);
                }
                else
                {
                    HidePointer();
                }
            }
        }
        internal void HandleZoomTooltip(ChartStack stack, Point mouseDownPos, Point pos)
        {
            Point localStartPos = stack.TransformToDescendant(this).Transform(mouseDownPos);
            Point localEndPos   = stack.TransformToDescendant(this).Transform(pos);

            if (localEndPos.X >= 0 && localEndPos.Y >= 0 && localEndPos.X < this.ActualWidth && localEndPos.Y < this.ActualHeight)
            {
                DataValue startData = FindNearestValue(localStartPos, true);
                DataValue endData   = FindNearestValue(localEndPos, true);
                if (startData != null && endData != null)
                {
                    Point    tipPosition  = this.TransformToDescendant(Graph).Transform(localEndPos);
                    double   microseconds = endData.X - startData.X;
                    TimeSpan span         = new TimeSpan((long)microseconds * 10);
                    ShowTip(span.ToString(), tipPosition);
                }
                else
                {
                    HidePointer();
                }
            }
        }