public Rect GetWindowRect()
        {
            double dpiX;
            double dpiY;

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(_handle))
            {
                dpiX = g.DpiX;
                dpiY = g.DpiY;
            }

            double top    = WindowExtensions.ActualTop(this, _handle);
            double left   = WindowExtensions.ActualLeft(this, _handle);
            double width  = this.Width;
            double height = this.Height;

            if (WindowState.Maximized == this.WindowState)
            {
                left = left / (dpiX / 96d);
                top  = top / (dpiY / 96d);

                if (this.ActualWidth > this.Width)
                {
                    width  = this.ActualWidth;
                    height = this.ActualHeight;
                }
            }

            return(new Rect(left, top, width, height));
        }
        public Rect GetWindowRect()
        {
            double top    = WindowExtensions.ActualTop(this, Handle);
            double left   = WindowExtensions.ActualLeft(this, Handle);
            double width  = this.Width;
            double height = this.Height;

            if (WindowState.Maximized == this.WindowState)
            {
                left = left / (this.DpiX / 96d);
                top  = top / (this.DpiY / 96d);

                if (this.ActualWidth > this.Width)
                {
                    width  = this.ActualWidth;
                    height = this.ActualHeight;
                }
            }

            return(new Rect(left, top, width, height));
        }