Example #1
0
        /// <summary>
        /// Show the notification window if it is not already visible.
        /// If the window is currently disappearing, it is shown again.
        /// </summary>
        public void Popup()
        {
            if (!disposed)
            {
                if (!frmPopup.Visible)
                {
                    frmPopup.Size = Size;
                    if (Scroll)
                    {
                        posStart = Screen.PrimaryScreen.WorkingArea.Bottom;
                        posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - frmPopup.Height;
                    }
                    else
                    {
                        posStart = Screen.PrimaryScreen.WorkingArea.Bottom - frmPopup.Height;
                        posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - frmPopup.Height;
                    }
                    opacityStart = 0;
                    opacityStop  = 1;

                    frmPopup.Opacity  = opacityStart;
                    frmPopup.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - frmPopup.Size.Width - 1, posStart);
                    frmPopup.Show();
                    isAppearing = true;

                    tmrWait.Interval      = Delay;
                    tmrAnimation.Interval = AnimationInterval;
                    tmrAnimation.Start();
                    sw = System.Diagnostics.Stopwatch.StartNew();
                    System.Diagnostics.Debug.WriteLine("Animation started.");
                }
                else
                {
                    if (!isAppearing)
                    {
                        frmPopup.Top     = maxPosition;
                        frmPopup.Opacity = maxOpacity;
                        tmrAnimation.Stop();
                        System.Diagnostics.Debug.WriteLine("Animation stopped.");
                        tmrWait.Stop();
                        tmrWait.Start();
                        System.Diagnostics.Debug.WriteLine("Wait timer started.");
                    }
                    frmPopup.Invalidate();
                }
            }
        }
        /// <summary>
        /// Show the notification window if it is not already visible.
        /// If the window is currently disappearing, it is shown again.
        /// </summary>
        public void Popup()
        {
            if (IgnoreWhenFullScreen && Utils.IsForegroundFullScreen())
            {
                return;
            }
            if (!disposed)
            {
                if (!frmPopup.Visible)
                {
                    SetNextPosition();
                    frmPopup.Size = Size;
                    if (Scroll)
                    {
                        posStart = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                        posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                    }
                    else
                    {
                        posStart = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                        posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                    }
                    opacityStart = 0;
                    opacityStop  = 1;

                    frmPopup.Opacity  = opacityStart;
                    frmPopup.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - frmPopup.Size.Width - 1, posStart);
                    ShowInactiveTopmost(frmPopup);
                    isAppearing = true;

                    tmrWait.Interval      = Delay;
                    tmrAnimation.Interval = AnimationInterval;
                    realAnimationDuration = AnimationDuration;
                    tmrAnimation.Start();
                    sw = System.Diagnostics.Stopwatch.StartNew();
                }
                else
                {
                    if (!isAppearing)
                    {
                        frmPopup.Size = Size;
                        if (Scroll)
                        {
                            posStart = frmPopup.Top;
                            posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                        }
                        else
                        {
                            posStart = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                            posStop  = Screen.PrimaryScreen.WorkingArea.Bottom - currentPosition * frmPopup.Height;
                        }
                        opacityStart          = frmPopup.Opacity;
                        opacityStop           = 1;
                        isAppearing           = true;
                        realAnimationDuration = Math.Max((int)sw.ElapsedMilliseconds, 1);
                        sw.Restart();
                    }
                    frmPopup.Invalidate();
                }
            }
        }