/// <summary> /// Returns an observable that returns a SW.DragDropKeyStates value /// whenever it changes, even if one of the events involved /// is handled. /// </summary> /// <param name="that">The element to listen to.</param> /// <param name="initialState">The initial state SW.DragDropKeyStates. /// </param> /// <returns>An observable that returns a SW.DragDropKeyStates value /// whenever it changes, even if one of the events involved /// is handled.</returns> internal static IObservable <SW.DragDropKeyStates> GetKeyStateChangedAlways( this UIElement that, SW.DragDropKeyStates initialState) { return (GetKeyStateChanged(that.GetMouseLeftButtonDownAlways(), that.GetMouseLeftButtonUpAlways(), that.GetKeyDownAlways(), that.GetKeyUpAlways(), initialState)); }
/// <summary> /// Returns an observable that returns a SW.DragDropKeyStates value /// whenever it changes, even if one of the events involved /// is handled or occurs in a sibling. /// </summary> /// <param name="that">The element to listen to.</param> /// <param name="initialState">The initial state SW.DragDropKeyStates. /// </param> /// <returns>An observable that returns a SW.DragDropKeyStates value /// whenever it changes, even if one of the events involved /// is handled.</returns> internal static IObservable <SW.DragDropKeyStates> GetKeyStateChangedOnSelfAndSiblingsAlways(this UIElement that, SW.DragDropKeyStates initialState) { IEnumerable <UIElement> popupRoots = VisualTreeExtensions.GetVisualDescendants(that) .OfType <Popup>() .Select(popup => popup.Child) .Where(popupRoot => popupRoot != null); return(GetKeyStateChanged( popupRoots .Select(popupRoot => popupRoot.GetMouseLeftButtonDownAlways()) .Aggregate(that.GetMouseLeftButtonDownAlways(), (left, right) => left.Merge(right)), popupRoots .Select(popupRoot => popupRoot.GetMouseLeftButtonUpAlways()) .Aggregate(that.GetMouseLeftButtonUpAlways(), (left, right) => left.Merge(right)), popupRoots .Select(popupRoot => popupRoot.GetKeyUpAlways()) .Aggregate(that.GetKeyUpAlways(), (left, right) => left.Merge(right)), popupRoots .Select(popupRoot => popupRoot.GetKeyDownAlways()) .Aggregate(that.GetKeyDownAlways(), (left, right) => left.Merge(right)), initialState)); }