示例#1
0
        private static IntPtr ShowInternal(Control parent, string message, Image image, int timeoutInterval, eToastGlowColor toastGlowColor, eToastPosition? toastPosition, int x, int y)
        {
            if (parent == null) throw new NullReferenceException("parent parameter for toast notification must be set.");

            if (timeoutInterval < 1) timeoutInterval = 0;

            ToastDisplay toast = new ToastDisplay();
            toast.BackColor = Color.Transparent;
            toast.ToastBackColor = _ToastBackColor;
            toast.ForeColor = _ToastForeColor;
            if (_ToastFont != null) toast.Font = _ToastFont;
            bool isTerminalSession = NativeFunctions.IsTerminalSession();
            toast.Alpha = isTerminalSession ? 255 : 0;
            toast.Text = message;
            toast.Image = image;
            toast.GlowColor = toastGlowColor;
            parent.Controls.Add(toast);
            Size toastSize = toast.DesiredSize(_ToastMargin, parent.ClientRectangle);
            toast.BringToFront();
            if (toastPosition != null)
                toast.Bounds = CalculateToastBounds(toastPosition.Value, parent.ClientRectangle, toastSize);
            else
                toast.Bounds = new Rectangle(x, y, toastSize.Width, toastSize.Height);

            toast.Visible = true;
            IntPtr toastId = toast.Handle;
            if (!isTerminalSession)
            {
                Animation.AnimationInt anim = new DevComponents.DotNetBar.Animation.AnimationInt(new Animation.AnimationRequest(toast, "Alpha", 0, 255),
                        Animation.AnimationEasing.EaseOutQuad, 250);
                //anim.FixedStepCount = 10;
                anim.AutoDispose = true;
                anim.Start();
            }

            if (timeoutInterval > 0)
                BarUtilities.InvokeDelayed(new MethodInvoker(delegate { CloseToast(toast); }), timeoutInterval);

            return toastId;
        }
示例#2
0
        private Color GetGlowColor(eToastGlowColor glowColor)
        {
            if (glowColor == eToastGlowColor.Blue)
                return ColorScheme.GetColor(32, 0x0070C0); // Color.FromArgb(48, Color.Blue);
            else if (glowColor == eToastGlowColor.Green)
                return Color.FromArgb(32, Color.Green);
            else if (glowColor == eToastGlowColor.Orange)
                return Color.FromArgb(32, Color.Orange);
            else if (glowColor == eToastGlowColor.Red)
                return Color.FromArgb(32, Color.Red);
            else if (glowColor == eToastGlowColor.None)
                return Color.Empty;
            else if (glowColor == eToastGlowColor.Custom)
                return ToastNotification.CustomGlowColor;

            return Color.FromArgb(50, Color.Red);
        }
示例#3
0
 public static void ShowToastnotification(Control Parent, string Text, eToastGlowColor Color, int Timeout = 5000)
 {
     // ToastNotification.ToastBackColor = Drawing.Color.LightGray
     // ToastNotification.ToastForeColor = Drawing.Color.Black
     ToastNotification.Show(Parent, Text, null, Timeout, Color);
 }
示例#4
0
 /// <summary>
 /// Displays the toast notification on top of the specified parent control, we recommend always using a parent form.
 /// </summary>
 /// <param name="parent">Parent form to display toast notification on top of</param>
 /// <param name="message">Message to display.</param>
 /// <param name="image">Image to display next to toast text.</param>
 /// <param name="timeoutInterval">Interval in milliseconds after which the notification is hidden.</param>
 /// /// <param name="toastGlowColor">Specifies toast-glow color used.</param>
 public static IntPtr Show(Control parent, string message, Image image, int timeoutInterval, eToastGlowColor toastGlowColor)
 {
     return Show(parent, message, image, timeoutInterval, toastGlowColor, eToastPosition.BottomCenter);
 }
示例#5
0
 /// <summary>
 /// Displays the toast notification on top of the specified parent control, we recommend always using a parent form.
 /// </summary>
 /// <param name="parent">Parent form to display toast notification on top of</param>
 /// <param name="message">Message to display.</param>
 /// <param name="image">Image to display next to toast text.</param>
 /// <param name="timeoutInterval">Interval in milliseconds after which the notification is hidden.</param>
 /// <param name="toastGlowColor">Specifies toast-glow color used.</param>
 /// <param name="x">Specifies the X position of the toast notification with its parent window.</param>
 /// <param name="y">Specifies the Y position of the toast notification with its parent window.</param>
 public static IntPtr Show(Control parent, string message, Image image, int timeoutInterval, eToastGlowColor toastGlowColor, int x, int y)
 {
     return ShowInternal(parent, message, image, timeoutInterval, toastGlowColor, null, x, y);
 }
示例#6
0
 /// <summary>
 /// Displays the toast notification on top of the specified parent control, we recommend always using a parent form.
 /// </summary>
 /// <param name="parent">Parent form to display toast notification on top of</param>
 /// <param name="message">Message to display.</param>
 /// <param name="image">Image to display next to toast text.</param>
 /// <param name="timeoutInterval">Interval in milliseconds after which the notification is hidden.</param>
 /// <param name="toastGlowColor">Specifies toast-glow color used.</param>
 /// <param name="toastPosition">Specifies the position of the toast notification.</param>
 public static IntPtr Show(Control parent, string message, Image image, int timeoutInterval, eToastGlowColor toastGlowColor, eToastPosition toastPosition)
 {
     return ShowInternal(parent, message, image, timeoutInterval, toastGlowColor, toastPosition, 0, 0);
 }