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 );
}
}
}
}