public void InvokeHoverClick(HandPosition hand) { if (hand != null) { hand.IsInteracting = false; HandHoverTimer timer = this.trackedHandHovers.FirstOrDefault(h => h.Hand.Equals(hand)); if (timer != null) { timer.Stop(); this.trackedHandHovers.Remove(timer); } } this.IsSelected = true; if (this.soundPlayerOnClick != null) { this.soundPlayerOnClick.Play(); } var t = new DispatcherTimer(); t.Interval = TimeSpan.FromSeconds(0.6); t.Tick += (o, s) => { t.Stop(); var clickArgs = new HandInputEventArgs(HoverClickEvent, this, hand); this.RaiseEvent(clickArgs); this.IsSelected = false; }; t.Start(); }
/// <summary> /// 将空气鼠标ActiveHand的“进入”、“离开”事件激发(RaiseEvent) /// </summary> /// <param name="hand"></param> private void HitTestHand(HandPosition hand) { var pt = new Point(hand.X, hand.Y); IInputElement input = this.parentWindow.InputHitTest(pt); if (hand.CurrentElement != input) { var inputObject = input as DependencyObject; var currentObject = hand.CurrentElement as DependencyObject; // If the new input is a child of the current element then don't fire the leave event. // It will be fired later when the current input moves to the parent of the current element. if (hand.CurrentElement != null && Utility.IsElementChild(currentObject, inputObject) == false) { // Raise the HandLeaveEvent on the CurrentElement, which at this point is the previous element the hand was over. hand.CurrentElement.RaiseEvent(new HandInputEventArgs(HandLeaveEvent, hand.CurrentElement, hand)); } // If the current element is the parent of the new input element then don't // raise the entered event as it has already been fired. if (input != null && Utility.IsElementChild(inputObject, currentObject) == false) { input.RaiseEvent(new HandInputEventArgs(HandEnterEvent, input, hand)); } hand.CurrentElement = input; } else if (hand.CurrentElement != null) { hand.CurrentElement.RaiseEvent(new HandInputEventArgs(HandMoveEvent, hand.CurrentElement, hand)); } }
public TimeSpan GetTimeRemaining(HandPosition hand) { HandHoverTimer timer = this.trackedHandHovers.FirstOrDefault(h => h.Hand.Equals(hand)); if (timer != null) { return(timer.TimeRemaining); } return(TimeSpan.MaxValue); }
private void RemoveHand(HandPosition hand) { this.IsHoveredOver = false; hand.IsInteracting = false; hand.Magnetized = false; // Stop active hover timer (if it exists) for this hand. HandHoverTimer timer = this.trackedHandHovers.FirstOrDefault(h => h.Hand.Equals(hand)); if (timer != null) { timer.Stop(); this.trackedHandHovers.Remove(timer); } }
public HandInputEventArgs(RoutedEvent routedEvent, object source, HandPosition hand) : base(routedEvent, source) { this.Hand = hand; }