本文整理匯總了C#中Windows.UI.Input.GestureRecognizer類的典型用法代碼示例。如果您正苦於以下問題:C# GestureRecognizer類的具體用法?C# GestureRecognizer怎麽用?C# GestureRecognizer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GestureRecognizer類屬於Windows.UI.Input命名空間,在下文中一共展示了GestureRecognizer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ManipulationInputProcessor
public ManipulationInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target, Windows.UI.Xaml.UIElement referenceframe)
{
this.gestureRecognizer = gr;
this.element = target;
this.reference = referenceframe;
this.gestureRecognizer.GestureSettings =
Windows.UI.Input.GestureSettings.Tap |
Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
Windows.UI.Input.GestureSettings.RightTap |
Windows.UI.Input.GestureSettings.ManipulationTranslateX |
Windows.UI.Input.GestureSettings.ManipulationTranslateY |
Windows.UI.Input.GestureSettings.ManipulationRotate |
Windows.UI.Input.GestureSettings.ManipulationScale |
Windows.UI.Input.GestureSettings.ManipulationTranslateInertia |
Windows.UI.Input.GestureSettings.ManipulationRotateInertia |
Windows.UI.Input.GestureSettings.ManipulationMultipleFingerPanning | //reduces zoom jitter when panning with multiple fingers
Windows.UI.Input.GestureSettings.ManipulationScaleInertia;
// Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
this.element.PointerCanceled += OnPointerCanceled;
this.element.PointerPressed += OnPointerPressed;
this.element.PointerReleased += OnPointerReleased;
this.element.PointerMoved += OnPointerMoved;
// Set up event handlers to respond to gesture recognizer output
this.gestureRecognizer.Tapped += OnTapped;
this.gestureRecognizer.RightTapped += OnRightTapped;
this.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
this.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
this.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
InitializeTransforms();
}
示例2: InputManager
/// <summary>
/// Initialise the input system. Note that accelerometer input defaults to off.
/// </summary>
/// <param name="game"></param>
public InputManager(Project2Game game) : base(game)
{
// initialisation
useMouseDelta = false;
accelerometerEnabled = false;
mouseDelta = new Vector2();
keyboardManager = new KeyboardManager(game);
mouseManager = new MouseManager(game);
pointerManager = new PointerManager(game);
keyMapping = new KeyMapping();
// get the accelerometer. Returns null if no accelerometer found
accelerometer = Accelerometer.GetDefault();
window = Window.Current.CoreWindow;
// Set up the gesture recognizer. In this game, it only responds to TranslateX, TranslateY and Tap events
gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX |
GestureSettings.ManipulationTranslateY | GestureSettings.Tap;
// Register event handlers for pointer events
window.PointerPressed += OnPointerPressed;
window.PointerMoved += OnPointerMoved;
window.PointerReleased += OnPointerReleased;
// automatically enable accelerometer if we have one
this.AccelerometerEnabled(true);
this.MouseDeltaEnabled(true);
}
示例3: MainPage_Loaded
void MainPage_Loaded(object senderX, RoutedEventArgs e)
{
recognizer = new GestureRecognizer();
recognizer.GestureSettings =
GestureSettings.HoldWithMouse | GestureSettings.Hold;
// Forward pointer input to the gesture recognizer.
Rect1.PointerCanceled += OnPointerCanceled;
Rect1.PointerPressed += OnPointerPressed;
Rect1.PointerReleased += OnPointerReleased;
Rect1.PointerMoved += OnPointerMoved;
// Attach handlers for recognized gestures.
// In each of these event handlers, args.PointerDeviceType
// indicates the input device and 'sender' is GestureRecognizer.
// args - TappedEventArgs
recognizer.Tapped += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "Tapped raised"); };
// args - RightTappedEventArgs
recognizer.RightTapped += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "RightTapped raised"); };
// The press-and-hold gesture.
// args - HoldingEventArgs
recognizer.Holding += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "Holding raised {0}", args.HoldingState); };
// The slide or swipe gesture within a content area that supports
// panning along the perpendicular direction of the gesture.
// args - CrossSlidingEventArgs
recognizer.CrossSliding += (sender, args) => { tbxMessage.Text += string.Format("{0}\r\n", "CrossSliding raised"); };
}
示例4: AdnGestureManager
public AdnGestureManager(
UIElement window,
AdnRenderer renderer)
{
_window = window;
_renderer = renderer;
_pointerMode = PointerMode.kIdleMode;
_accumulator = new ValueAccumulator(
-30.0 * 1000.0 / 5.0,
-100.0 * 1000.0 / 5.0,
-5.0 * 1000.0 / 5.0);
_pointers = new Dictionary<uint, PointerPoint>();
window.PointerMoved += OnPointerMoved;
window.PointerPressed += OnPointerPressed;
window.PointerReleased += OnPointerReleased;
window.PointerWheelChanged += OnPointerWheelChanged;
_gr = new GestureRecognizer();
_gr.GestureSettings =
GestureSettings.Tap |
GestureSettings.Drag |
GestureSettings.DoubleTap |
GestureSettings.ManipulationScale;
_gr.Tapped += OnTapped;
_gr.ManipulationStarted += OnManipulationStarted;
_gr.ManipulationUpdated += OnManipulationUpdated;
_gr.ManipulationCompleted += OnManipulationCompleted;
}
示例5: OnGameLoopStarting
private void OnGameLoopStarting(ICanvasAnimatedControl sender, object args)
{
//
// The GestureRecognizer needs to be created and accessed from the
// same thread -- in this case the game loop thread, so we use the GameLoopStarting event
// for this.
//
gestureRecognizer = new GestureRecognizer();
gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateInertia | GestureSettings.ManipulationTranslateY;
gestureRecognizer.ManipulationStarted += gestureRecognizer_ManipulationStarted;
gestureRecognizer.ManipulationUpdated += gestureRecognizer_ManipulationUpdated;
gestureRecognizer.ManipulationCompleted += gestureRecognizer_ManipulationCompleted;
gestureRecognizer.InertiaTranslationDeceleration = -0.05f;
//
// When the GestureRecognizer goes into intertia mode (ie after the pointer is released)
// we want it to generate ManipulationUpdated events in sync with the game loop's Update.
// We do this by disabling AutoProcessIntertia and explicitly calling ProcessInertia()
// from the Update.
//
gestureRecognizer.AutoProcessInertia = false;
inputSource = animatedControl.CreateCoreIndependentInputSource(CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch);
inputSource.PointerPressed += Input_PointerPressed;
inputSource.PointerMoved += Input_PointerMoved;
inputSource.PointerReleased += Input_PointerReleased;
}
示例6: Attach
public void Attach(DependencyObject associatedObject)
{
Guard.Assert(associatedObject is UIElement, "associatedObject is UIElement");
AssociatedObject = associatedObject;
gestureRecognizer = new GestureRecognizer
{
GestureSettings = GestureSettings.CrossSlide
};
//CrossSliding distance thresholds are disabled by default. Use CrossSlideThresholds to set these values.
var cst = new CrossSlideThresholds
{
SelectionStart = 2,
SpeedBumpStart = 3,
SpeedBumpEnd = 4,
RearrangeStart = 5
};
gestureRecognizer.CrossSlideHorizontally = true; //Enable horinzontal slide
gestureRecognizer.CrossSlideThresholds = cst;
gestureRecognizer.CrossSliding += gestureRecognizer_CrossSliding;
UIElement.PointerCanceled += OnPointerCanceled;
UIElement.PointerPressed += OnPointerPressed;
UIElement.PointerReleased += OnPointerReleased;
UIElement.PointerMoved += OnPointerMoved;
}
示例7: Scenario1
public Scenario1()
{
this.InitializeComponent();
Windows.UI.Input.GestureRecognizer gr1 = new Windows.UI.Input.GestureRecognizer();
Windows.UI.Input.GestureRecognizer gr2 = new Windows.UI.Input.GestureRecognizer();
GestureInputProcessor ShapeInput1 = new GestureInputProcessor(gr1, MyRect1);
GestureInputProcessor ShapeInput2 = new GestureInputProcessor(gr2, MyRect2);
}
示例8: GtGestureListener
/*
* Windows.UI.Input.GestureSettings 是一個 flag 枚舉,其值包括:
* None, Tap, DoubleTap, Hold, HoldWithMouse, RightTap, Drag, CrossSlide, ManipulationTranslateX, ManipulationTranslateY, ManipulationTranslateRailsX, ManipulationTranslateRailsY, ManipulationRotate, ManipulationScale, ManipulationTranslateInertia, ManipulationRotateInertia, ManipulationScaleInertia
*/
public GestureRecognizer GtGestureListener(UIElement ele)
{
_gestureRecognizer = new GestureRecognizer();
ele.PointerMoved += GestureRecognizerDemo_PointerMoved;
ele.PointerPressed += GestureRecognizerDemo_PointerPressed;
ele.PointerReleased += GestureRecognizerDemo_PointerReleased;
return _gestureRecognizer;
}
示例9: Scenario5
public Scenario5()
{
this.InitializeComponent();
InitOptions();
// Create a GestureRecognizer which will be used to process the manipulations
// done on the rectangle
recognizer = new GestureRecognizer();
// Create a ManipulationInputProcessor which will listen for events on the
// rectangle, process them, and update the rectangle's position, size, and rotation
manipulationProcessor = new ManipulationInputProcessor(recognizer, manipulateMe, mainCanvas);
}
示例10: GameInput
public GameInput()
{
// Get the accelerometer object
accelerometer = Accelerometer.GetDefault();
window = Window.Current.CoreWindow;
// Set up the gesture recognizer. In this example, it only responds to TranslateX, Scale and Tap events
gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | GestureSettings.ManipulationScale | GestureSettings.Tap;
// Register event handlers for pointer events
window.PointerPressed += OnPointerPressed;
window.PointerMoved += OnPointerMoved;
window.PointerReleased += OnPointerReleased;
}
示例11: InputProcessor
/// <summary>
/// Constructor.
/// </summary>
/// <param name="element">
/// Manipulation target.
/// </param>
/// <param name="reference">
/// Element that contains the coordinate space used for expressing transformations
/// during manipulations, usually the parent element of Target in the UI tree.
/// </param>
/// <remarks>
/// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
/// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
/// will be an ancestor of <paramref name="element"/> in the UI tree.
/// </remarks>
internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
{
_target = element;
_reference = reference;
// Setup pointer event handlers for the element.
// They are used to feed the gesture recognizer.
_target.PointerMoved += OnPointerMoved;
_target.PointerPressed += OnPointerPressed;
_target.PointerReleased += OnPointerReleased;
_target.PointerCanceled += OnPointerCanceled;
_target.PointerWheelChanged += OnPointerWheelChanged;
CrossSlideThresholds cst = new CrossSlideThresholds();
//cst.RearrangeStart = 10;//cst.SelectionStart = 12;
//cst.SpeedBumpStart = 12;//cst.SpeedBumpEnd = 24;
// Create the gesture recognizer
_gestureRecognizer = new GestureRecognizer();
_gestureRecognizer.GestureSettings =
GestureSettings.Hold |
GestureSettings.ManipulationRotate |
GestureSettings.ManipulationRotateInertia |
GestureSettings.ManipulationScale |
GestureSettings.ManipulationScaleInertia |
GestureSettings.ManipulationTranslateInertia |
GestureSettings.ManipulationTranslateX |
GestureSettings.ManipulationTranslateY |
GestureSettings.RightTap |
GestureSettings.Tap |
GestureSettings.CrossSlide;
_gestureRecognizer.CrossSlideHorizontally = true;
_gestureRecognizer.CrossSlideThresholds = cst;
_gestureRecognizer.ManipulationStarted += OnManipulationStarted;
_gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
_gestureRecognizer.ManipulationInertiaStarting += OnManipulationInertiaStarting;
_gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
_gestureRecognizer.Dragging += OnDragging;
_gestureRecognizer.Holding += OnHolding;
_gestureRecognizer.RightTapped += OnRightTapped;
_gestureRecognizer.Tapped += OnTapped;
_gestureRecognizer.CrossSliding += OnCrossSliding;
}
示例12: InitializeGesture
private void InitializeGesture()
{
Gesture = new GestureRecognizer();
Gesture.GestureSettings =
GestureSettings.Tap |
GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
GestureSettings.ManipulationTranslateInertia |
GestureSettings.ManipulationTranslateX |
GestureSettings.ManipulationTranslateY;
// Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
PointerCanceled += OnPointerCanceled;
PointerPressed += OnPointerPressed;
PointerReleased += OnPointerReleased;
PointerMoved += OnPointerMoved;
// Set up event handlers to respond to gesture recognizer output
Gesture.ManipulationUpdated += OnManipulationUpdated;
}
示例13: GestureInputProcessor
public GestureInputProcessor(Windows.UI.Input.GestureRecognizer gr, Windows.UI.Xaml.UIElement target)
{
this.gestureRecognizer = gr;
this.element = target;
this.gestureRecognizer.GestureSettings =
Windows.UI.Input.GestureSettings.Tap |
Windows.UI.Input.GestureSettings.Hold | //hold must be set in order to recognize the press & hold gesture
Windows.UI.Input.GestureSettings.RightTap;
// Set up pointer event handlers. These receive input events that are used by the gesture recognizer.
this.element.PointerCanceled += OnPointerCanceled;
this.element.PointerPressed += OnPointerPressed;
this.element.PointerReleased += OnPointerReleased;
this.element.PointerMoved += OnPointerMoved;
// Set up event handlers to respond to gesture recognizer output
this.gestureRecognizer.Tapped += OnTapped;
this.gestureRecognizer.RightTapped += OnRightTapped;
}
示例14: GestureInputProcessor
public void GestureInputProcessor(GestureRecognizer gr,UIElement target)
{
this.gestureRecognizer = gr;
this.element = target;
this.gestureRecognizer.GestureSettings = GestureSettings.Tap | GestureSettings.Hold | GestureSettings.RightTap | GestureSettings.CrossSlide;
this.element.PointerCanceled += MainPage_PointerCanceled;
this.element.PointerPressed += MainPage_PointerPressed;
this.element.PointerReleased += MainPage_PointerReleased;
this.element.PointerMoved += Element_PointerMoved;
gestureRecognizer.Holding += GestureRecognizer_Holding;
gestureRecognizer.Tapped += GestureRecognizer_Tapped;
gestureRecognizer.RightTapped += GestureRecognizer_RightTapped;
CrossSlideThresholds cst = new CrossSlideThresholds();
cst.SelectionStart = 2;
cst.SpeedBumpStart = 3;
cst.SpeedBumpEnd = 4;
cst.RearrangeStart = 5;
gestureRecognizer.CrossSlideHorizontally = true;
gestureRecognizer.CrossSlideThresholds = cst;
gestureRecognizer.CrossSliding += GestureRecognizer_CrossSliding;
}
示例15: OnManipulationUpdated
public void OnManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs args)
{
if (main.focussld == false)
{
scaleFactor /= (float)args.Delta.Scale;
AngleH += (float)args.Delta.Translation.X / 500;
AngleV += (float)args.Delta.Translation.Y / 500;
}
}