Example #1
0
        public MainWindow()
        {
            InitializeComponent();


            bool createdNew;

            Mutex = new Mutex(true, appName, out createdNew);

            if (!createdNew)
            {
                Environment.Exit(0);
            }

            String[] cla = Environment.GetCommandLineArgs();

            if (cla.Length != 3)
            {
                Environment.Exit(0);
            }

            this.Hide();

            Toaster toaster = new Toaster();

            toaster.Show(cla[1], new Exception(cla[2]));
        }
Example #2
0
        void Show(string selectedType, string message, string title)
        {
            switch (selectedType)
            {
            case "Custom":
                var adorner = _toaster.Show(message, title);
                if (adorner.ToastView is ToastView tv)
                {
                    tv.CloseButtonClicked += (s, e) => adorner.RequestClose();
                }
                break;

            case "Info":
                Toast.Info(this, message, title);
                break;

            case "Success":
                Toast.Success(this, message, title);
                break;

            case "Warning":
                Toast.Warning(this, message, title);
                break;

            case "Error":
                Toast.Error(this, message, title);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #3
0
        /// <summary>
        /// Event handler for when a toast notification arrives while your application is running.
        /// The toast will not display if your application is running so you must add this
        /// event handler if you want to do something with the toast notification.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
        {
            StringBuilder message     = new StringBuilder();
            string        relativeUri = string.Empty;

            message.AppendFormat("Received Toast {0}:\n", DateTime.Now.ToShortTimeString());

            // Parse out the information that was part of the message.
            foreach (string key in e.Collection.Keys)
            {
                message.AppendFormat("{0}: {1}\n", key, e.Collection[key]);

                if (string.Compare(
                        key,
                        "wp:Param",
                        System.Globalization.CultureInfo.InvariantCulture,
                        System.Globalization.CompareOptions.IgnoreCase) == 0)
                {
                    relativeUri = e.Collection[key];
                }
            }

            logger.debug("MPNS message {0}", message.ToString());
            Deployment.Current.Dispatcher.BeginInvoke(() => Toaster.Show("MPNS", message.ToString()));

//            Toaster.Show("MPNS", message.ToString());
            // Display a dialog of all the fields in the toast.
//            Dispatcher.BeginInvoke(() => MessageBox.Show(message.ToString()));
        }
        private void OnPlayerDroppedOntoPitch()
        {
            var player1 = GetClickedPlayerId();
            var player2 = GetClickedPlayerId();

            bus.Send(new SubstitutePlayersAction(player1, player2), this)
            .OnFail(task => Toaster.Show("SubstitutePlayerHandler_CannotSwapWithSamePlayer"));
        }
Example #5
0
        public static void RemindUser(string title)
        {
            Application.Current.Dispatcher.Invoke((Action) delegate {
                string message = "Reminder:";

                Toaster toaster = new Toaster();
                toaster.Show(message, title, (ToastTypes)ToastReminders.Properties.Settings.Default["ToastType"], (TimeSpan)ToastReminders.Properties.Settings.Default["DisplayTime"]);
            });
        }
Example #6
0
        //show alert dialog
        void alertMessage(string title, string message, ToastTypes type)
        {
            bool isPersistent = false;
            bool showInWindow = false;

            if (showInWindow)
            {
                Rect bounds = new Rect(
                    this.Left,
                    this.Top,
                    this.Width,
                    this.Height);

                _Toaster.Show(title, message, type, bounds, isPersistent);
            }
            else
            {
                _Toaster.Show(title, message, type, isPersistent: isPersistent);
            }
        }
Example #7
0
        private void toastRequested(object sender, RoutedEventArgs e)
        {
            ToastTypes type         = GetChosenToastType((Button)sender);
            string     title        = txtTitle.Text;
            string     message      = txtMessage.Text;
            bool       isPersistent = (bool)chkPersistent.IsChecked;
            bool       showInWindow = (bool)chkShowInWindow.IsChecked;

            if (showInWindow)
            {
                Rect bounds = new Rect(
                    this.Left,
                    this.Top,
                    this.Width,
                    this.Height);

                _Toaster.Show(title, message, type, bounds, isPersistent);
            }
            else
            {
                _Toaster.Show(title, message, type, isPersistent: isPersistent);
            }
        }
Example #8
0
        /// <summary>
        /// uses the peanutbutter.dll file to display toast notifications
        /// </summary>
        /// <param name="Error"></param>
        private void ShowToast(string Error)
        {
            var        time    = DateTime.Now;
            string     title   = "Title";
            string     message = "Message";
            ToastTypes type    = ToastTypes.Warning;

            TimeSpan span = time.Subtract(lastUsedTime);

            if (span.Minutes < 2)
            {
                return;
            }

            if (Error == "HighPing")
            {
                title        = "High Ping";
                message      = "Ping is over 500";
                type         = ToastTypes.Warning;
                lastUsedTime = DateTime.Now;
            }
            else if (Error == "Failure")
            {
                title        = "Ping Timeout";
                message      = "Ping Timed out";
                type         = ToastTypes.Error;
                lastUsedTime = DateTime.Now;
            }

            Toaster toaster = new Toaster();

            try
            {
                toaster.Show(title, message, type);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Concat("An error occured trying to show an alert, The alert was: ", message), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #9
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DisplayTime.Text != null && DisplayTime.Text != "" && DisplayTime.Text != DisplayTime.Tag.ToString())
                {
                    Properties.Settings.Default["DisplayTime"] = new TimeSpan(0, 0, int.Parse(DisplayTime.Text));
                }


                Properties.Settings.Default["ToastType"] = (ToastTypes)ToastType.SelectedIndex;
                Application.Current.Dispatcher.Invoke((Action) delegate {
                    Toaster toaster = new Toaster();
                    toaster.Show("Settings", "Saved", ToastTypes.Success, new TimeSpan(0, 0, 5));
                });
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke((Action) delegate {
                    Toaster toaster = new Toaster();
                    toaster.Show("Settings", "Failed saving", ToastTypes.Error, new TimeSpan(0, 0, 5));
                });
            }
        }