Beispiel #1
0
        public static void ShowSpotify(ToastBehaviour behaviour)
        {
            ToastWindowViewModel toastWindowViewModel = new ToastWindowViewModel(behaviour, ToastType.Spotify)
            {
                Toast = new SpotifyToastViewModel()
            };

            ShowToast(toastWindowViewModel);
        }
Beispiel #2
0
        public static void ShowError(Exception exception, ToastBehaviour behaviour)
        {
            ToastWindowViewModel toastWindowViewModel = new ToastWindowViewModel(behaviour, ToastType.Error)
            {
                Toast = new ErrorToastViewModel(exception)
            };

            ShowToast(toastWindowViewModel);
        }
Beispiel #3
0
        public static void ShowError(string message, ToastBehaviour behaviour)
        {
            ToastWindowViewModel toastWindowViewModel = new ToastWindowViewModel(behaviour, ToastType.Error)
            {
                Toast = new ErrorToastViewModel(message)
            };

            ShowToast(toastWindowViewModel);
        }
Beispiel #4
0
        public static void ShowWarning(ToastBehaviour behaviour)
        {
            ToastWindowViewModel toastWindowViewModel = new ToastWindowViewModel(behaviour, ToastType.Warning)
            {
                Toast = new WarningToastViewModel()
            };

            ShowToast(toastWindowViewModel);
        }
Beispiel #5
0
        private static void ShowToast(ToastWindowViewModel toastWindowViewModel) //TODO: can there be more than one toast at a time? if not a handling for this case is needed, maybe add to an itemsource
        {
            ToastWindow toastWindow = new ToastWindow
            {
                DataContext = toastWindowViewModel,
                Visibility  = Visibility.Hidden
            };

            toastWindow.Show();

            Win32Api.W32Rect monitor = WindowHelper.GetPrimaryMonitor();
            toastWindow.Left = monitor.Right - toastWindow.Width;
            toastWindow.Top  = monitor.Bottom - toastWindow.Height;

            toastWindow.Visibility = Visibility.Visible;

            if (toastWindowViewModel.Behaviour == ToastBehaviour.TimedShort)
            {
                toastWindow.Timer             = new Timer(HideToast, toastWindow, SHORT_TIMED_TOAST, 100);
                toastWindow.MouseOverChanged += delegate(object sender, bool isMouseOver)
                {
                    if (isMouseOver)
                    {
                        toastWindow.Timer.Change(Timeout.Infinite, Timeout.Infinite);
                        toastWindow.Opacity = 1;
                    }
                    else
                    {
                        toastWindow.Timer.Change(SHORT_TIMED_TOAST, 100);
                    }
                };
            }
            else if (toastWindowViewModel.Behaviour == ToastBehaviour.TimedLong)
            {
                toastWindow.Timer             = new Timer(HideToast, toastWindow, LONG_TIMED_TOAST, 100);
                toastWindow.MouseOverChanged += delegate(object sender, bool isMouseOver)
                {
                    if (isMouseOver)
                    {
                        toastWindow.Timer.Change(Timeout.Infinite, Timeout.Infinite);
                        toastWindow.Opacity = 1;
                    }
                    else
                    {
                        toastWindow.Timer.Change(LONG_TIMED_TOAST, 100);
                    }
                };
            }
        }