Пример #1
0
        public void Reshow(bool animated, bool modal)
        {
            lock (instanceLock)
            {
                // If there's no current instance then we are just a left over that is going to
                // be closed/disposed shortly anyway.
                if (currentInstance == null)
                {
                    return;
                }

                Form mainForm = Application.OpenForms["MainForm"];
                if (mainForm == null)
                {
                    throw new Exception("HUD display needs main form to be named \"MainForm\" to find it.");
                }

                mainForm.Update();

                // The (transparent) HUD will cover the entire application window.
                Bounds = mainForm.Bounds;

                PrepareBitmap(modal);

                // Don't use animations in a terminal session (remote desktop).
                useAnimation = animated && !SystemInformation.TerminalServerSession;

                if (IsDisposed || Disposing)
                {
                    return;
                }

                if (useAnimation)
                {
                    ControlUtilities.SetBitmap(this, contentBitmap, 0);
                    Win32.ShowWindow(Handle, (uint)SW.SHOWNOACTIVATE);
                    for (float i = 1; i <= animationSteps; i++)
                    {
                        ControlUtilities.SetBitmap(this, contentBitmap, (int)(i / animationSteps * 255));
                    }
                }
                else
                {
                    ControlUtilities.SetBitmap(this, contentBitmap, 255);
                    Win32.ShowWindow(Handle, (uint)SW.SHOWNOACTIVATE);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Hides the HUD form and releases any used bitmap resource.
        /// </summary>
        private void DoHide()
        {
            if (useAnimation && contentBitmap != null)
            {
                for (float i = animationSteps; i >= 0; i--)
                {
                    ControlUtilities.SetBitmap(this, contentBitmap, (int)(i / animationSteps * 255));
                }
            }

            base.Hide();

            if (contentBitmap != null)
            {
                contentBitmap.Dispose();
                contentBitmap = null;
            }
            cancelDelegate = null;
        }