Example #1
0
        public void Update()
        {
            if ((!this._windowManager.IsCompositionEnabled) || (this._handle == IntPtr.Zero))
            {
                return;
            }

            try
            {
                DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._handle, this._properties);
            }
            catch (ArgumentException)
            {
                //This exception will be thrown if the EVE client disappears while this method is running
            }
        }
Example #2
0
        public void Refresh(bool forceRefresh)
        {
            // To prevent flickering the old broken thumbnail is removed AFTER the new shiny one is created
            IntPtr obsoleteThumbnailHanlde = forceRefresh ? this._thumbnailHandle : IntPtr.Zero;

            if ((this._isThumbnailSetUp == false) || forceRefresh)
            {
                this.RegisterThumbnail();
            }

            bool sizeChanged     = this._isSizeChanged || forceRefresh;
            bool locationChanged = this._isPositionChanged || forceRefresh;

            if (sizeChanged)
            {
                this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height);
                try
                {
                    DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail);
                }
                catch (ArgumentException)
                {
                    //This exception will be thrown if the EVE client disappears while this method is running
                }
                this._isSizeChanged = false;
            }

            if (obsoleteThumbnailHanlde != IntPtr.Zero)
            {
                this.UnregisterThumbnail(obsoleteThumbnailHanlde);
            }

            if (!this.IsOverlayEnabled)
            {
                if (this._isOverlayVisible)
                {
                    this._overlay.Hide();
                    this._isOverlayVisible = false;
                }

                return;
            }

            if (!this._isOverlayVisible)
            {
                this._overlay.Show();
                this._isOverlayVisible = true;
            }
            else if (!(sizeChanged || locationChanged))
            {
                // No need to adjust in the overlay location if it is already visible and properly set
                return;
            }

            Size overlaySize = this.ClientSize;

            overlaySize.Width  -= 2 * 5;
            overlaySize.Height -= 2 * 5;

            Point overlayLocation = this.Location;

            overlayLocation.X += 5 + (this.Size.Width - this.ClientSize.Width) / 2;
            overlayLocation.Y += 5 + (this.Size.Height - this.ClientSize.Height) - (this.Size.Width - this.ClientSize.Width) / 2;

            this._isPositionChanged = false;
            this._overlay.Size      = overlaySize;
            this._overlay.Location  = overlayLocation;
        }