Example #1
0
        /// <summary>
        /// The on timer.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <param name="ea">
        /// The ea.
        /// </param>
        private void OnTimer(object obj, EventArgs ea)
        {
            switch (this._state)
            {
                case NotiferState.Appearing:
                    if (this.Opacity < 1)
                    {
                        this.Opacity += this._opacityStep;
                    }
                    else
                    {
                        this._timer.Stop();
                        this._timer.Interval = this._stayDuration;
                        this._state = NotiferState.Visible;
                        this._timer.Start();
                    }

                    break;

                case NotiferState.Visible:
                    this._timer.Stop();
                    this._timer.Interval = TIMER_STEP;
                    if (!this._bIsMouseOverPopup)
                    {
                        this._state = NotiferState.Disappearing;
                    }

                    this._timer.Start();
                    break;

                case NotiferState.Disappearing:
                    if (this._bIsMouseOverPopup)
                    {
                        this._state = NotiferState.Appearing;
                    }
                    else
                    {
                        if (this.Opacity > 0)
                        {
                            this.Opacity -= this._opacityStep;
                        }
                        else
                        {
                            this.Hide();
                        }
                    }

                    break;

                case NotiferState.Hidden:
                    this._timer.Enabled = false;
                    break;
            }
        }
Example #2
0
        /// <summary>
        /// Displays the popup for a certain amount of time
        /// </summary>
        /// <param name="timeToStay">
        /// Time to stay in milliseconds
        /// </param>
        /// <param name="type">
        /// Notification type
        /// </param>
        protected void Display(int timeToStay, NotificationType type)
        {
            this._stayDuration = timeToStay;
            this.SetWindowMetrics();
            this.ApplyTheme(type);
            this._timer.Enabled = true;
            this._timer.Interval = 100;
            this.pnlMiddle.Invalidate();

            switch (this._state)
            {
                case NotiferState.Hidden:
                case NotiferState.Disappearing:
                    this._timer.Stop();
                    this._state = NotiferState.Appearing;
                    NativeMethods.ShowWindow(this.Handle, 4); // We Show the popup without stealing focus
                    this._timer.Interval = TIMER_STEP;
                    this._timer.Start();
                    break;

                case NotiferState.Appearing:
                    if (!this._timer.Enabled)
                    {
                        this._timer.Interval = TIMER_STEP;
                        this._timer.Start();
                    }

                    break;

                case NotiferState.Visible:
                    this._timer.Stop();
                    this._timer.Interval = this._stayDuration;
                    this._timer.Start();
                    break;
            }
        }
Example #3
0
 /// <summary>
 /// The on mouse enter.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="ea">
 /// The ea.
 /// </param>
 private void OnMouseEnter(object sender, EventArgs ea)
 {
     this._bIsMouseOverPopup = this.imgClose.Visible = true;
     this.Opacity = 1;
     this._state = NotiferState.Visible;
 }
Example #4
0
 /// <summary>
 /// Hides the popup
 /// </summary>
 public new void Hide()
 {
     if (this._state != NotiferState.Hidden)
     {
         this._timer.Stop();
         this._state = NotiferState.Hidden;
         this.imgClose.Visible = false;
         base.Hide();
     }
 }