[12503] | 1 | // todo look to comment for EndlessAnimation
|
---|
| 2 |
|
---|
| 3 | //using System;
|
---|
| 4 | //using System.Collections.Generic;
|
---|
| 5 | //using System.Linq;
|
---|
| 6 | //using System.Text;
|
---|
| 7 | //using Microsoft.Research.DynamicDataDisplay.Navigation;
|
---|
| 8 | //using System.Windows.Input;
|
---|
| 9 | //using System.Windows;
|
---|
| 10 | //using System.Windows.Media.Animation;
|
---|
| 11 | //using System.Windows.Media;
|
---|
| 12 | //using System.Diagnostics;
|
---|
| 13 |
|
---|
| 14 | //namespace Microsoft.Research.DynamicDataDisplay.Charts.Navigation
|
---|
| 15 | //{
|
---|
| 16 | // [Obsolete("Unready because Viewport became non-visual and no longer has BeginAnimation method.", true)]
|
---|
| 17 | // public class InertialMouseNavigation : MouseNavigation
|
---|
| 18 | // {
|
---|
| 19 | // public InertialMouseNavigation()
|
---|
| 20 | // {
|
---|
| 21 | // }
|
---|
| 22 |
|
---|
| 23 | // Point visibleStart;
|
---|
| 24 | // Point panningStartPointInScreen;
|
---|
| 25 | // int panningStartTime;
|
---|
| 26 | // protected override void StartPanning(MouseButtonEventArgs e)
|
---|
| 27 | // {
|
---|
| 28 | // visibleStart = Viewport.Visible.Location;
|
---|
| 29 | // panningStartPointInScreen = e.GetPosition(this);
|
---|
| 30 | // base.StartPanning(e);
|
---|
| 31 | // panningStartTime = e.Timestamp;
|
---|
| 32 | // }
|
---|
| 33 |
|
---|
| 34 | // bool runningAnimation = false;
|
---|
| 35 | // protected override void StopPanning(MouseButtonEventArgs e)
|
---|
| 36 | // {
|
---|
| 37 | // Point panningStopPointInScreen = e.GetPosition(this);
|
---|
| 38 |
|
---|
| 39 | // base.StopPanning(e);
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | // // mouse click with no panning
|
---|
| 43 | // if (panningStartPointInScreen == panningStopPointInScreen)
|
---|
| 44 | // {
|
---|
| 45 | // // remove all animations on Viewport.Visible
|
---|
| 46 | // BeginVisibleAnimation(null);
|
---|
| 47 | // return;
|
---|
| 48 | // }
|
---|
| 49 |
|
---|
| 50 | // double panningDuration = (e.Timestamp - panningStartTime) / 1000.0;
|
---|
| 51 |
|
---|
| 52 | // double animationStartMinDuration = 0.5; // seconds
|
---|
| 53 | // double animationStartMinMouseShift = 50; // pixels
|
---|
| 54 |
|
---|
| 55 | // // mouse moved short enough and for rather long distance.
|
---|
| 56 | // if (panningDuration < animationStartMinDuration && (panningStopPointInScreen - panningStartPointInScreen).Length > animationStartMinMouseShift)
|
---|
| 57 | // {
|
---|
| 58 | // Vector visibleShift = Viewport.Visible.Location - visibleStart;
|
---|
| 59 |
|
---|
| 60 | // EndlessPanningRectAnimation panningAnimation = new EndlessPanningRectAnimation(
|
---|
| 61 | // Viewport.Visible,
|
---|
| 62 | // visibleShift / panningDuration);
|
---|
| 63 |
|
---|
| 64 | // BeginVisibleAnimation(panningAnimation);
|
---|
| 65 | // }
|
---|
| 66 | // }
|
---|
| 67 |
|
---|
| 68 | // private void BeginVisibleAnimation(AnimationTimeline animation)
|
---|
| 69 | // {
|
---|
| 70 | // if (animation != null)
|
---|
| 71 | // {
|
---|
| 72 | // if (runningAnimation)
|
---|
| 73 | // {
|
---|
| 74 | // BeginVisibleAnimation(null);
|
---|
| 75 | // }
|
---|
| 76 |
|
---|
| 77 | // //Plotter2D.Viewport.BeginAnimation(Viewport2D.VisibleProperty, animation);
|
---|
| 78 | // runningAnimation = true;
|
---|
| 79 | // }
|
---|
| 80 | // else
|
---|
| 81 | // {
|
---|
| 82 | // if (!runningAnimation)
|
---|
| 83 | // return;
|
---|
| 84 |
|
---|
| 85 | // Debug.WriteLine("Removing animation");
|
---|
| 86 |
|
---|
| 87 | // Rect visible = Plotter2D.Viewport.Visible;
|
---|
| 88 | // //Plotter2D.Viewport.BeginAnimation(Viewport2D.VisibleProperty, null);
|
---|
| 89 | // Plotter2D.Viewport.Visible = visible;
|
---|
| 90 | // runningAnimation = false;
|
---|
| 91 | // }
|
---|
| 92 | // }
|
---|
| 93 | // }
|
---|
| 94 | //}
|
---|