void PerformGesture(GestureDescription.StrokeDescription StrokeDescription) { _gestureWaitHandle.Reset(); var gestureBuilder = new GestureDescription.Builder(); gestureBuilder.AddStroke(StrokeDescription); _accessibilityService.DispatchGesture(gestureBuilder.Build(), new GestureCompletedCallback(_gestureWaitHandle), null); _gestureWaitHandle.Wait(); }
/// <inheritdoc /> /// <summary> /// 同时模拟多个手势。每个手势的参数为[delay, duration, 坐标], delay为延迟多久(毫秒)才执行该手势;duration为手势执行时长 /// </summary> /// <param name="handler">回调的处理程序</param> /// <param name="strokes">手势</param> /// <returns>是否成功</returns> public bool Gestures(Handler handler = null, params GestureDescription.StrokeDescription[] strokes) { var service = AutoAccessibilityService.Instance; if (service == null) { return(false); } var builder = new GestureDescription.Builder(); foreach (var stroke in strokes) { builder.AddStroke(stroke); } return(handler == null ? GesturesWithoutHandler(builder.Build()) : GesturesWithHandler(builder.Build(), handler)); }
protected override GestureDescription BuildGesture() { float xStart = 0; float xEnd = (float)DeviceDisplay.MainDisplayInfo.Width / 2; float y = (float)DeviceDisplay.MainDisplayInfo.Height / 2; Path path = new Path(); path.MoveTo(xStart, y); path.LineTo(xEnd, y); GestureDescription.StrokeDescription stroke = new GestureDescription.StrokeDescription( path, 0, OPEN_GESTURE_DURATION ); GestureDescription.Builder gestureBuilder = new GestureDescription.Builder(); gestureBuilder.AddStroke(stroke); return(gestureBuilder.Build()); }
protected override GestureDescription BuildGesture() { float x = (float)DeviceDisplay.MainDisplayInfo.Width / 2; float yStart = (float)DeviceDisplay.MainDisplayInfo.Height / 3; float yEnd = (float)DeviceDisplay.MainDisplayInfo.Height * 2 / 3; Path path = new Path(); path.MoveTo(x, yStart); path.LineTo(x, yEnd); GestureDescription.StrokeDescription stroke = new GestureDescription.StrokeDescription( path, 0, UPDATE_GESTURE_DURATION ); GestureDescription.Builder gestureBuilder = new GestureDescription.Builder(); gestureBuilder.AddStroke(stroke); return(gestureBuilder.Build()); }
private void CancelGesture(int id) { Log.Info(TAG, "CancelGesture"); //extendedMotionHandler.RemoveCallbacks(extendedMotionCallback); Path path = new Path(); path.MoveTo(activeMotions[id].endX, activeMotions[id].endY); path.LineTo(activeMotions[id].endX, activeMotions[id].endY); var stroke = new GestureDescription.StrokeDescription(path, 0, 1, false); GestureDescription.Builder gestureBuilder = new GestureDescription.Builder(); gestureBuilder.AddStroke(stroke); TryDispatchGesture(gestureBuilder.Build()); activeMotions.Remove(id); if (activeMotions.Count > 0) { RunActiveGestures(); } }
private void RunActiveGestures() { var strokes = GenerateActiveStrokeList(); if (strokes.Count == 0) { Log.Info(TAG, "Warning: Tried to run empty gesture set"); return; } // Add a callback in case the gesture lasts more than the max duration //extendedMotionHandler.RemoveCallbacks(extendedMotionCallback); //extendedMotionHandler.PostDelayed(extendedMotionCallback, HOLD_STROKE_DURATION_MS); GestureDescription.Builder gestureBuilder = new GestureDescription.Builder(); foreach (var stroke in strokes) { gestureBuilder.AddStroke(stroke); } TryDispatchGesture(gestureBuilder.Build()); }