protected override void OnNextGesture(Gesture gesture) { if (!this.IsEnabled) { return; } switch (gesture.Type) { case GestureType.LeftButtonDown: this.isLeftButtonDown = true; if (this.CaptureMouse()) { this.IsPressed = true; } break; case GestureType.LeftButtonUp: this.isLeftButtonDown = false; if (this.IsPressed) { this.OnClick(); } this.ReleaseMouseCapture(); this.IsPressed = false; break; case GestureType.Move: if (this.isLeftButtonDown && this.IsMouseCaptured) { this.IsPressed = this.HitTest(gesture.Point); } break; } }
protected override void OnNextGesture(Gesture gesture) { switch (gesture.Type) { case GestureType.LeftButtonDown: this.CaptureMouse(); break; case GestureType.FreeDrag: if (this.scrollInfo != null && this.IsMouseCaptured) { this.scrollInfo.SetHorizontalOffset(this.scrollInfo.Offset.X - gesture.Delta.X); this.scrollInfo.SetVerticalOffset(this.scrollInfo.Offset.Y - gesture.Delta.Y); } break; case GestureType.LeftButtonUp: if (this.IsMouseCaptured) { this.ReleaseMouseCapture(); } break; } }
protected virtual void OnNextGesture(Gesture gesture) { }
private static bool OnNextGestureFindElement(IElement element, Gesture gesture) { if (element is IInputElement && element.HitTest(gesture.Point)) { element.Gestures.OnNext(gesture); return true; } return false; }
private static bool OnNextGestureFindChild(IElement element, Gesture gesture) { return element.GetVisualChildren().Reverse().Where(child => !OnNextGestureFindChild(child, gesture)).Any( child => OnNextGestureFindElement(child, gesture)); }
protected override void OnNextGesture(Gesture gesture) { if (this.elementWithMouseCapture != null) { this.elementWithMouseCapture.Gestures.OnNext(gesture); } else { if (!OnNextGestureFindChild(this, gesture)) { OnNextGestureFindElement(this, gesture); } } }