/// <summary> /// This function is called by a function that bypasses the window system event. /// Warning : do not call a function that is called when a WindowMoved event that leading to a call MoveResult.Broadcast /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnWindowLocationChanged( object sender, EventArgs e ) { if( Dispatcher.CurrentDispatcher != Application.Current.Dispatcher ) throw new InvalidOperationException( "This method should only be called by the Application Thread. Call OnWindowLocationChangedInternal to make sure the correct thread carries on." ); IWindowElement windowElementFromSender = sender as IWindowElement; if( windowElementFromSender != null ) { WindowElementData data = null; if( _dic.TryGetValue( windowElementFromSender, out data ) ) { //This is done to reduce the number of times we fetch a window's position directly from the Window, which could trigger Invokes double previousTop = data.Top; double previousLeft = data.Left; data.UpdateFromWindow(); double deltaTop = data.Top - previousTop; double deltaLeft = data.Left - previousLeft; if( deltaTop != 0 || deltaLeft != 0 ) { var evt = new WindowElementLocationEventArgs( windowElementFromSender, deltaTop, deltaLeft ); if( WindowMoved != null ) WindowMoved( sender, evt ); } } } }
void OnWindowManagerWindowMoved( object sender, WindowElementLocationEventArgs e ) { Debug.Assert( Dispatcher.CurrentDispatcher == Application.Current.Dispatcher, "This method should only be called by the ExternalThread." ); IWindowElement triggerHolder = e.Window; // Gets all windows attached to the given window ISpatialBinding binding = WindowBinder.GetBinding( triggerHolder ); if( binding != null ) { //temporary ResizingWindow( binding ); PlacingWindow( binding ); } }
private void OnWindowManagerWindowMoved( object sender, WindowElementLocationEventArgs e ) { HideButtons( e.Window ); }
void OnWindowMoved( object sender, WindowElementLocationEventArgs e ) { Debug.Assert( Dispatcher.CurrentDispatcher == Application.Current.Dispatcher, "This method should only be called by the Application Thread." ); //avoids bind during a resize if( !_resizeMoveLock && !_pointerDownLock ) { if( _tester.CanTest ) { ISpatialBinding binding = WindowBinder.GetBinding( e.Window ); IDictionary<IWindowElement, Rect> rect = WindowManager.WindowElements.ToDictionary( x => x, y => WindowManager.GetClientArea( y ) ); IBinding result = _tester.Test( binding, rect, AttractionRadius ); if( result != null ) { _bindResult = WindowBinder.PreviewBind( result.Target, result.Origin, result.Position ); } else { if( _tester.LastResult != null ) { WindowBinder.PreviewUnbind( _tester.LastResult.Target, _tester.LastResult.Origin ); _bindResult = null; } } } } _resizeMoveLock = false; }