Exemplo n.º 1
0
 public NotifyWindow()
 {
     alphaBlendValue = 1;
     animStatus      = NotifyTimers.Hidden;
     SetStyle(ControlStyles.ContainerControl, false);
     this.AccessibleRole        = AccessibleRole.Alert;
     this.AccessibleDescription = "Notification window";
 }
Exemplo n.º 2
0
        internal void KillTimers()
        {
            switch (animStatus)
            {
            case NotifyTimers.Appearing: NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                break;

            case NotifyTimers.Waiting: NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Waiting));
                break;

            case NotifyTimers.Disappearing: NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                break;

            default: break;
            }

            animStatus = NotifyTimers.Hidden;
        }
Exemplo n.º 3
0
        private void WMMouseHover(ref Message msg)
        {
            if (animStatus == NotifyTimers.Waiting)
            {
                NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Waiting));
            }

            if (!mouseInControl)
            {
                mouseInControl = true;

                if (animStatus == NotifyTimers.Disappearing)
                {
                    NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                    animStatus = NotifyTimers.Appearing;
                    NativeMethods.SetTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Appearing), notifier.Precision, new HandleRef(this, IntPtr.Zero));
                }
            }
            msg.Result = IntPtr.Zero;
        }
Exemplo n.º 4
0
        private void WMTimer(ref Message msg)
        {
            switch ((NotifyTimers)msg.WParam)
            {
            case NotifyTimers.Appearing:
                animStatus = NotifyTimers.Appearing;
                if (alphaBlendValue + StepSize >= alphaMax)
                {
                    AlphaBlendValue = alphaMax;
                    if (!notifier.Sliding)
                    {
                        NativeMethods.KillTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                        NativeMethods.SetTimer(new HandleRef(this, this.Handle), new HandleRef(this, (IntPtr)NotifyTimers.Waiting), notifier.ShowTime, new HandleRef(this, IntPtr.Zero));
                        animStatus = NotifyTimers.Waiting;
                    }
                }
                else
                {
                    AlphaBlendValue = (byte)(alphaBlendValue + StepSize);
                }

                if (notifier.Sliding)
                {
                    switch (edge)
                    {
                        #region ABE_LEFT
                    case TaskbarPosition.ScreenLeft:
                    {
                        if ((this.Width + scrollSpeed) < notifier.AdjustedWidth)
                        {
                            Width = Width + scrollSpeed;
                        }
                        else
                        {
                            this.Width = notifier.AdjustedWidth;
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                            NativeMethods.SetTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Waiting), notifier.ShowTime, new HandleRef(this, IntPtr.Zero));
                            animStatus = NotifyTimers.Waiting;
                        }
                        break;
                    }

                        #endregion
                        #region ABE_TOP
                    case TaskbarPosition.ScreenTop:
                    {
                        if ((this.Height + ScrollSpeed) < notifier.AdjustedHeight)
                        {
                            this.Height = this.Height + ScrollSpeed;
                        }
                        else
                        {
                            this.Height = notifier.AdjustedHeight;
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                            NativeMethods.SetTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Waiting), notifier.ShowTime, new HandleRef(this, IntPtr.Zero));
                            animStatus = NotifyTimers.Waiting;
                        }
                        break;
                    }

                        #endregion
                        #region ABE_BOTTOM
                    case TaskbarPosition.ScreenBottom:
                    {
                        if ((this.Height + ScrollSpeed) < notifier.AdjustedHeight)
                        {
                            this.Top    = this.Top - ScrollSpeed;
                            this.Height = this.Height + ScrollSpeed;
                        }
                        else
                        {
                            this.Height = notifier.AdjustedHeight;
                            this.Top    = WARect.Bottom - this.Height;
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                            NativeMethods.SetTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Waiting), notifier.ShowTime, new HandleRef(this, IntPtr.Zero));
                            animStatus = NotifyTimers.Waiting;
                        }
                        break;
                    }

                        #endregion
                        #region ABE_RIGHT
                    case TaskbarPosition.ScreenRight:
                    {
                        if ((this.Width + ScrollSpeed) < notifier.AdjustedWidth)
                        {
                            this.Left  = this.Left - ScrollSpeed;
                            this.Width = this.Width + ScrollSpeed;
                        }
                        else
                        {
                            this.Width = notifier.AdjustedWidth;
                            this.Left  = WARect.Right - this.Width;
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Appearing));
                            NativeMethods.SetTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Waiting), notifier.ShowTime, new HandleRef(this, IntPtr.Zero));
                            animStatus = NotifyTimers.Waiting;
                        }
                        break;
                    }
                        #endregion
                    }
                }
                break;

            case NotifyTimers.Waiting:
                NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Waiting));
                NativeMethods.SetTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing), notifier.Precision, new HandleRef(this, IntPtr.Zero));
                animStatus = NotifyTimers.Disappearing;
                break;

            case NotifyTimers.Disappearing:

                if (alphaBlendValue - StepSize <= 1)
                {
                    AlphaBlendValue = 1;
                    if (!notifier.Sliding)
                    {
                        NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                        animStatus = NotifyTimers.Hidden;
                        NativeMethods.ShowWindow(Handle, (int)ShowWindowStyles.SW_HIDE);
                        Notifier.DoDeactivate();
                    }
                }
                else
                {
                    AlphaBlendValue = (byte)(AlphaBlendValue - StepSize);
                }
                if (Notifier.Sliding)
                {
                    switch (Notifier.GetEdge())
                    {
                        #region ABE_LEFT
                    case TaskbarPosition.ScreenLeft:
                    {
                        if ((this.Width - ScrollSpeed) > 0)
                        {
                            this.Width = this.Width - ScrollSpeed;
                        }
                        else
                        {
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                            animStatus = NotifyTimers.Hidden;
                            NativeMethods.ShowWindow(Handle, (int)ShowWindowStyles.SW_HIDE);
                            Notifier.DoDeactivate();
                        }
                        break;
                    }

                        #endregion
                        #region ABE_TOP
                    case TaskbarPosition.ScreenTop:
                    {
                        if ((this.Height - ScrollSpeed) > 0)
                        {
                            this.Height = this.Height - ScrollSpeed;
                        }
                        else
                        {
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                            animStatus = NotifyTimers.Hidden;
                            NativeMethods.ShowWindow(Handle, (int)ShowWindowStyles.SW_HIDE);
                            Notifier.DoDeactivate();
                        }
                        break;
                    }

                        #endregion
                        #region ABE_BOTTOM
                    case TaskbarPosition.ScreenBottom:
                    {
                        if ((this.Height - ScrollSpeed) > 0)
                        {
                            this.Top    = this.Top + ScrollSpeed;
                            this.Height = this.Height - ScrollSpeed;
                        }
                        else
                        {
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                            animStatus = NotifyTimers.Hidden;
                            NativeMethods.ShowWindow(Handle, (int)ShowWindowStyles.SW_HIDE);
                            Notifier.DoDeactivate();
                        }
                        break;
                    }

                        #endregion
                        #region ABE_RIGHT
                    case TaskbarPosition.ScreenRight:
                    {
                        if ((this.Width - ScrollSpeed) > 0)
                        {
                            this.Left  = this.Left + ScrollSpeed;
                            this.Width = this.Width - ScrollSpeed;
                        }
                        else
                        {
                            NativeMethods.KillTimer(ThisHandle, new HandleRef(this, (IntPtr)NotifyTimers.Disappearing));
                            animStatus = NotifyTimers.Hidden;
                            NativeMethods.ShowWindow(Handle, (int)ShowWindowStyles.SW_HIDE);
                            Notifier.DoDeactivate();
                        }
                        break;
                    }
                        #endregion
                    }
                }

                break;
            }
        }