コード例 #1
0
 private void GestureListener_OnFlick(object sender, FlickGestureEventArgs e)
 {
     if (UseAccelerometer || LoadPopup.IsOpen || SavePopup.IsOpen || HelpPopup.IsOpen ||
         MusicPopup.IsOpen || ChatPopup.IsOpen)
     {
         return;
     }
     if (Math.Abs(e.HorizontalVelocity - 0) > 0.001 &&
         e.Direction == System.Windows.Controls.Orientation.Horizontal)
     {
         if (e.GetPosition(LayoutRoot).Y < 400)
         {
             ShakeHead();
         }
         else
         {
             MoveFoot();
         }
     }
     if (Math.Abs(e.VerticalVelocity - 0) > 0.001 &&
         e.Direction == System.Windows.Controls.Orientation.Vertical)
     {
         BowHead();
     }
 }
コード例 #2
0
        private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
        {
            StackPanel p = sender as StackPanel;

            Log.Info("xxx", e.VerticalVelocity.ToString());
            Log.Info("xxx", e.HorizontalVelocity.ToString());
            Log.Info("xxx", e.Angle.ToString());
            Log.Info("xxx", e.Direction.ToString());
            Log.Info("xxx", e.GetPosition(p).X.ToString());
            Log.Info("xxx", e.GetPosition(p).X.ToString());

            if (PopupWindow.IsShown)
            {
                return;
            }

            if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
            {
                StackPanel parent = sender as StackPanel;
                if (parent == null)
                {
                    Log.Error(TAG, "GestureListener_Flick, parent is null.");
                    return;
                }
                ToDoItem item = parent.DataContext as ToDoItem;
                if (item != null)
                {
                    if (e.HorizontalVelocity > 1000 && Math.Abs(e.VerticalVelocity) < 300)//flick to right
                    {
                        this.SetItemCompleted(parent, item);
                    }
                    else if (e.HorizontalVelocity < 0)//flick to left
                    {
                        this.SetItemUnCompleted(parent, item);
                    }
                }
            }
        }