CK.WindowManager.WindowManager.OnWindowLocationChanged C# (CSharp) Method

OnWindowLocationChanged() protected method

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
protected OnWindowLocationChanged ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        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 );
                    }
                }
            }
        }