Ejemplo n.º 1
0
 private void DragCallback(UIElement sender, GestureEventArgs e)
 {
     var pos = e.Values.Get<PositionChanged>();
     if (pos != null)
     {
         MoveItem(sender, pos);
     }
 }
Ejemplo n.º 2
0
 private void DragCallback(UIElement sender, GestureEventArgs e)
 {
     var pos = e.Values.Get<PositionChanged>();
     if (pos != null)
     {
         //sender.SetValue(Canvas.TopProperty, pos.Y);
         //sender.SetValue(Canvas.LeftProperty, pos.X);
         MoveItem(sender, pos);
     }
 }
Ejemplo n.º 3
0
        void DragCallback(UIElement sender, GestureEventArgs e)
        {
            // Note: e.Values property contains the return type(s) defined in the gesture definition
            var positionChanged = e.Values.Get<PositionChanged>();

            if (positionChanged != null)
            {
                // Since we know that this callback is only used for the Rectangle
                // type of objects we can safely cast it to Rectangle
                Rectangle rect = sender as Rectangle;

                double x = (double)rect.GetValue(Canvas.LeftProperty);
                double y = (double)rect.GetValue(Canvas.TopProperty);

                rect.SetValue(Canvas.LeftProperty, x + positionChanged.X);
                rect.SetValue(Canvas.TopProperty, y + positionChanged.Y);
            }
        }
Ejemplo n.º 4
0
        private void DragCallback(UIElement sender, GestureEventArgs e)
        {
            var posChanged = e.Values.Get<PositionChanged>();

            var touchActions = e.Values.Get<TouchActions>();
            foreach (var action in touchActions)
            {
                Debug.WriteLine("Touch action: " + action.Action);
            }

            if (posChanged != null && sender != null)
            {
                ThreadStart start = delegate()
                {
                    sender.Dispatcher.Invoke(DispatcherPriority.Send,
                                      new Action<UIElement, PositionChanged>(MoveItem), sender, posChanged);
                };
                start.Invoke();
            }
        }
Ejemplo n.º 5
0
 private void RightCallBack(UIElement sender, GestureEventArgs e)
 {
     Thread t = new Thread(Scatter);
     t.Start();
 }
Ejemplo n.º 6
0
 private void LeftCallBack(UIElement sender, GestureEventArgs e)
 {
     Thread t = new Thread(Revert);
     t.Start();
 }
Ejemplo n.º 7
0
        private void LineCallBack(UIElement sender, GestureEventArgs e)
        {
            if (e.Values.Get<TouchPoints>().Count > 0)
            {

            }
        }
Ejemplo n.º 8
0
 private void ActorCallback_step2(UIElement sender, GestureEventArgs e)
 {
     // log.Text = "Actor gesture step 2" + Environment.NewLine + log.Text;
 }
Ejemplo n.º 9
0
        public static void Validate(string gestureName, string dataKey, GestureEventHandler gestureDetected = null, TouchToolkit.Framework.Components.TouchInputRecorder.GesturePlaybackCompleted playbackCompleted = null)
        {
            if (!_isInitialized)
                throw new FrameworkException("You must initialize the framework first!");

            _storage.GetGesture(_projectname, dataKey, (projName, gesName, data, error) =>
                {
                    // Callback on data receive from storage

                    if (error != null)
                    {
                        // Failed to retrieve data from storage
                        if (gestureDetected != null)
                        {
                            GestureEventArgs e = new GestureEventArgs();
                            e.Error = error;

                            gestureDetected(_layoutRoot, e);
                        }
                    }
                    else
                    {
                        // Subscribe to the specified gesture event
                        GestureFramework.EventManager.AddEvent(_layoutRoot, gestureName, gestureDetected);

                        // Playback the user interaction via virtual touch provider
                        _recorder.RunGesture(data, () =>
                        {
                            GestureFramework.EventManager.RemoveEvent(_layoutRoot, gestureName);
                            playbackCompleted();
                        });

                    }
                });
        }
Ejemplo n.º 10
0
        private void ZoomCallback(UIElement sender, GestureEventArgs e)
        {
            var dis = e.Values.Get<DistanceChanged>();

            if (dis != null)
                Resize(sender as Image, dis.Delta);
        }
Ejemplo n.º 11
0
 private void RotateCallback(UIElement sender, GestureEventArgs e)
 {
     var slopeChanged = e.Values.Get<SlopeChanged>();
     if (slopeChanged != null)
     {
         var img = sender as Image;
         if (img != null)
         {
             ThreadStart start = delegate()
             {
                 sender.Dispatcher.Invoke(DispatcherPriority.Send,
                                   new Action<Image, double>(Rotate), sender as Image, Math.Round(slopeChanged.Delta, 1));
             };
             start.Invoke();
         }
     }
 }
Ejemplo n.º 12
0
        void ResizeCallback(UIElement sender, GestureEventArgs e)
        {
            // Note: e.Values property contains the return type(s) defined in the gesture definition
            var distanceChanged = e.Values.Get<DistanceChanged>();

            if (distanceChanged != null)
            {
                // Since we know that this callback is only used for the Rectangle
                // type of objects we can safely cast it to Rectangle
                Rectangle rect = sender as Rectangle;

                rect.Width += distanceChanged.Delta;
                rect.Height += distanceChanged.Delta;
            }
        }
Ejemplo n.º 13
0
        void RotateCallback(UIElement sender, GestureEventArgs e)
        {
            // Note: e.Values property contains the return type(s) defined in the gesture definition
            var slopeChanged = e.Values.Get<SlopeChanged>();

            if (slopeChanged != null)
            {
                // Since we know that this callback is only used for the Rectangle
                // type of objects we can safely cast it to Rectangle
                Rectangle rect = sender as Rectangle;

                if (!rotateInProgress & slopeChanged.Delta != 0)
                {
                    rotateInProgress = true;

                    // Get current state
                    RotateTransform rt = rect.RenderTransform as RotateTransform;

                    if (rt == null)
                        rt = new RotateTransform();

                    // Set new values
                    rt.Angle += slopeChanged.Delta;
                    rt.CenterX = rect.Width / 2;
                    rt.CenterY = rect.Height / 2;

                    // Update
                    rect.RenderTransform = rt;

                    rotateInProgress = false;
                }
            }
        }
Ejemplo n.º 14
0
 private void DragCallback(UIElement sender, GestureEventArgs e)
 {
     var posChanged = e.Values.Get<PositionChanged>();
     var id = e.Values.Get<TouchID>()[0];
     if (ValidateID(id, sender))
     {
         if (posChanged != null && sender != null)
         {
             ThreadStart start = delegate()
             {
                 sender.Dispatcher.Invoke(DispatcherPriority.Send,
                                   new Action<UIElement, PositionChanged>(MoveItem), sender, posChanged);
             };
             start.Invoke();
         }
     }
 }
Ejemplo n.º 15
0
 private void BoxCallback(UIElement sender, GestureEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("Box");
 }
Ejemplo n.º 16
0
        private void ZoomCallback(UIElement sender, GestureEventArgs e)
        {
            var dis = e.Values.Get<DistanceChanged>();

            if (dis != null)
            {
                ThreadStart start = delegate()
                {
                    sender.Dispatcher.Invoke(DispatcherPriority.Send,
                                      new Action<Image, double>(Resize), sender as Image, dis.Delta);
                };
                start.Invoke();
            }
        }
Ejemplo n.º 17
0
        private void LassoCallback(UIElement sender, GestureEventArgs e)
        {
            TouchPoints touchPoints = e.Values.Get<TouchPoints>();

            // Create a dummy polygon shape using the points of lasso
            // to run a hit test to find the selected elements
            Polygon polygon = CreatePolygon(touchPoints);
            polygon.Fill = new SolidColorBrush(Colors.White);

            polygon.Opacity = .01;
            polygon.Tag = "LASSO_TEST";
            LayoutRoot.Children.Add(polygon);

            Thread t = new Thread(new ParameterizedThreadStart(HighlightItems));

            t.Start(polygon);
        }
Ejemplo n.º 18
0
 public void selectCallback(UIElement sender, GestureEventArgs e)
 {
     var touchPoints = e.Values.Get<TouchPoints>();
 }
Ejemplo n.º 19
0
 private void RotateCallback(UIElement sender, GestureEventArgs e)
 {
     var slopeChanged = e.Values.Get<SlopeChanged>();
     if (slopeChanged != null)
     {
         var img = sender as Image;
         if (img != null)
             Rotate(img, Math.Round(slopeChanged.Delta, 1));
     }
 }
Ejemplo n.º 20
0
 void GestureRecognizedCallback(UIElement sender, GestureEventArgs e)
 {
     String msg = "Gesture" + Environment.NewLine +
               "recognized!";
     ShowMessageOnCanvas(msg, 3);
     GestureFramework.EventManager.RemoveEvent(testArea, GestureName.Text.ToLower());
     testArea.Visibility = Visibility.Hidden;
     gesture.Visibility = Visibility.Visible;
     TryButton.Content = "TRY";
 }
Ejemplo n.º 21
0
        private void SelectionCallback(UIElement sender, GestureEventArgs e)
        {
            _polyLine.Points.Clear();
            var points = e.Values.Get<TouchPoints>();
            foreach (var point in points)
            {
                _polyLine.Points.Add(point.Position);
            }

            _polyLine.Points.Add(points[0].Position);

            LassoCallback(sender, e);
        }
Ejemplo n.º 22
0
        private void BackgroundMapLayer_Lasso(UIElement sender, GestureEventArgs e)
        {
            TouchPoints pts = e.Values.Get<TouchPoints>();

            int middlePt = (int)Math.Floor((decimal)(pts.Count / 2));
            Point scrPoint1 = new Point(pts[0].Y, BackgroundScatterView.Height - pts[0].X);
            Point scrPoint2 = new Point(pts[middlePt].Y, BackgroundScatterView.Height - pts[middlePt].X);

            MapPoint mapPoint1 = BackgroundMap.Map.ScreenToMap(scrPoint1);
            MapPoint mapPoint2 = BackgroundMap.Map.ScreenToMap(scrPoint2);

            Point point1 = BackgroundMap.Map.MapToScreen(mapPoint1);
            Point point2 = BackgroundMap.Map.MapToScreen(mapPoint2);

            IInputElement iie = BackgroundScatterView.InputHitTest(point1);

            //only create the frame if the origin of the lasso gesture was not drawn on an existing screen element
            if (iie == null)
            {
                MapFrame mf = MapFrameFactory.Instance.CreateMapFrame(mapPoint1, mapPoint2, scrPoint1, scrPoint2);
                AddMapFrame(mf);
            }
        }