Esempio n. 1
0
        /// <summary>
        /// Creates a new thumbnail of a certain window.
        /// </summary>
        /// <param name="handle">Handle of the window to clone.</param>
        /// <param name="region">Optional region.</param>
        public void SetThumbnailHandle(WindowHandle handle, ThumbnailRegion region)
        {
            Log.WriteDetails("Setting new thumbnail",
                             "HWND {0}, region {1}", handle, region
                             );

            if (_thumbnail != null && !_thumbnail.IsInvalid)
            {
                _thumbnail.Close();
                _thumbnail = null;
            }

            //Attempt to get top level Form from Control
            Form owner = this.TopLevelControl as Form;

            if (owner == null)
            {
                throw new Exception("Internal error: ThumbnailPanel.TopLevelControl is not a Form.");
            }

            _labelGlass.Visible = false;

            //Register new thumbnail, update regioning directly and refresh thumbnail
            _thumbnail     = DwmManager.Register(owner, handle.Handle);
            _currentRegion = region;
            _regionEnabled = (region != null);
            UpdateThubmnail();
        }