Esempio n. 1
0
        private void TouchEffect_TouchAction(object sender, TouchActionEventArgs args)
        {
            BoxView box = sender as BoxView;

            switch (args.Type)
            {
            case TouchActionType.Pressed:
                if (!dragDictionary.ContainsKey(box))
                {
                    dragDictionary.Add(box, new DragInfo(args.Id, args.Location));

                    TouchEffect touchEffect = (TouchEffect)box.Effects.FirstOrDefault(e => e is TouchEffect);
                    touchEffect.Capture = true;
                }
                break;

            case TouchActionType.Moved:
                if (dragDictionary.ContainsKey(box) && dragDictionary[box].Id == args.Id)
                {
                    Rectangle rect            = AbsoluteLayout.GetLayoutBounds(box);
                    Point     initialLocation = dragDictionary[box].PressPoint;
                    rect.X += args.Location.X - initialLocation.X;
                    rect.Y += args.Location.Y - initialLocation.Y;
                    AbsoluteLayout.SetLayoutBounds(box, rect);
                }
                break;

            case TouchActionType.Released:
                if (dragDictionary.ContainsKey(box) && dragDictionary[box].Id == args.Id)
                {
                    dragDictionary.Remove(box);
                    //show the result on the label
                    txtResult.Text += string.Format(" ({0},{1}) ", Math.Round(box.X, 2), Math.Round(box.Y, 2));
                }
                break;
            }
        }
Esempio n. 2
0
 public void OnTouchAction(Element element, TouchActionEventArgs args)
 {
     TouchAction?.Invoke(element, args);
 }