private void HandleToastActivatedEvent(object sender, object e)
        {
            RpToastNotificationActivatedEventArgs rpEvent;

            try
            {
                ToastActivatedEventArgs myEvent = (ToastActivatedEventArgs)e;
                rpEvent = JsonConvert
                          .DeserializeObject <RpToastNotificationActivatedEventArgs>(
                    JsonConvert.SerializeObject(myEvent)
                    );

                _log.Information(LogHelper.GetMethodName(this), "{ eventArguments}", rpEvent.Arguments);

                QueryString args = QueryString.Parse(rpEvent.Arguments);
                if (args["action"] == "LoginRequested")
                {
                    ShowLoginToast();
                }
                else
                if (args["action"] == "LoginDataSent")
                {
                    var usr = rpEvent.UserInput["Username"];
                    var pwd = rpEvent.UserInput["Password"];

                    var response = _apiHandler.GetAuth(usr, pwd);

                    LoginResponseToast(response);

                    if (response.Status == "success")
                    {
                        Application.Restart();
                    }
                }
                else if (args["action"] == "RateSubmitted")
                {
                    if (Int32.TryParse(rpEvent.UserInput["UserRate"], out int userRate) &&
                        1 <= userRate && userRate <= 10 &&
                        Int32.TryParse(args["SongId"], out int songId))
                    {
                        var ratingResponse = _apiHandler.GetRating(songId.ToString(), userRate);
                        if (ratingResponse.Status == "success")
                        {
                            _config.State.Playback = new Playback(_apiHandler.GetNowplayingList());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(LogHelper.GetMethodName(this), ex);
            }
        }
Exemple #2
0
        private async void Toast_Activated(ToastNotification sender, object args)
        {
            // Handle toast activation
            if (args is ToastActivatedEventArgs)
            {
                ToastActivatedEventArgs tArg = (ToastActivatedEventArgs)args;

                // Process the action
                if (tArg.Arguments == "positive")
                {
                    await this.NotificationConsumer.ControlPoint.PerformNotificationActionAsync(Convert.ToUInt32(sender.Tag), ActionID.Positive);
                }
                else if (tArg.Arguments == "negative")
                {
                    await this.NotificationConsumer.ControlPoint.PerformNotificationActionAsync(Convert.ToUInt32(sender.Tag), ActionID.Negative);
                }
            }
        }
        private void PromptNotificationOnActivated(ToastNotification sender, object args)
        {
            ToastActivatedEventArgs strArgs = args as ToastActivatedEventArgs;

            switch (strArgs.Arguments)
            {
            case "Yes":
                Properties.Settings.Default.SuppressN = "False";
                Properties.Settings.Default.Save();
                break;

            case "No":
                Properties.Settings.Default.SuppressN = "True";
                Properties.Settings.Default.Save();
                break;

            case "bodyTapped":
                main.PromptCalled = false;
                break;
            }
        }
        private void ToastOnActivated(ToastNotification sender, object invokedArgs)
        {
            // Tapping on the top-level header launches with empty args
            ToastActivatedEventArgs strArgs = invokedArgs as ToastActivatedEventArgs;

            switch (strArgs.Arguments)
            {
            // Open the image
            case "Block":
            {
                try
                {
                    if (Device.IsGateway || Device.IsLocalDevice)
                    {
                        throw new CustomExceptions.GatewayTargeted();
                    }

                    if (main.InvokeRequired)
                    {
                        main.BeginInvoke(new Action(() =>
                            {
                                main.SubItemCheckingHandler(new SubItemCheckingEventArgs(view.ListView1.GetColumn(6), new OLVListItem(Device), 6, CheckState.Unchecked, CheckState.Checked));
                            }));
                    }
                    else
                    {
                        main.SubItemCheckingHandler(new SubItemCheckingEventArgs(view.ListView1.GetColumn(6), new OLVListItem(Device), 6, CheckState.Unchecked, CheckState.Checked));
                    }
                }
                catch
                {
                    //Show a message that this is the gateway/local device
                    if (Device.IsGateway)
                    {
                        CreateAndShowMessage("Gateway can not be blocked!");
                    }
                    else if (Device.IsLocalDevice)
                    {
                        CreateAndShowMessage("The Local Device can not be blocked!");
                    }
                }

                break;
            }

            case "Show":
            {
                if (main.InvokeRequired)
                {
                    main.BeginInvoke(new Action(() =>
                        {
                            main.Show();
                            main.WindowState = FormWindowState.Normal;
                            if (main.notifyIcon1.Visible)
                            {
                                main.notifyIcon1.Visible = false;
                            }
                        }));
                }
                else
                {
                    main.Show();
                    main.WindowState = FormWindowState.Normal;
                    if (main.notifyIcon1.Visible)
                    {
                        main.notifyIcon1.Visible = false;
                    }
                }

                break;
            }

            case "Suppress":
            {
                Properties.Settings.Default.SuppressN = "True";
                Properties.Settings.Default.Save();
                break;
            }
            }
        }
        private void ToastActivated(ToastNotification sender, object e)
        {
            ToastActivatedEventArgs args = (ToastActivatedEventArgs)e;

            this.UserResponseCallback?.Invoke(args.Arguments);
        }
Exemple #6
0
        private void ToastOnActivated(ToastNotification sender, object invokedArgs)
        {
            // Tapping on the top-level header launches with empty args
            ToastActivatedEventArgs strArgs = invokedArgs as ToastActivatedEventArgs;

            switch (strArgs.Arguments)
            {
            // Open the image
            case "Block":
            {
                try
                {
                    if (Device.IsGateway || Device.IsLocalDevice)
                    {
                        throw new Controller.GatewayTargeted();
                    }

                    if (main.InvokeRequired)
                    {
                        main.BeginInvoke(new Action(() =>
                            {
                                if (!Device.BlockerActive && !Device.RedirectorActive)
                                {
                                    Device.GatewayMAC    = main.GetGatewayMAC();
                                    Device.GatewayIP     = main.GetGatewayIP();
                                    Device.LocalIP       = main.GetLocalIP();
                                    Device.Blocked       = true;
                                    Device.BlockerActive = true;
                                    Device.DeviceStatus  = "Offline";
                                    Device.BlockOrRedirect();
                                    main.fastObjectListView1.UpdateObject(Device);
                                    main.pictureBox1.Image = NetStalker.Properties.Resources.icons8_ok_96;
                                }
                            }));
                    }
                }
                catch (Exception)
                {
                    //Show a message that this is the gateway/local device
                    if (Device.IsGateway)
                    {
                        CreateAndShowMessage("Gateway can not be blocked!");
                    }
                    else if (Device.IsLocalDevice)
                    {
                        CreateAndShowMessage("The Local Device can not be blocked!");
                    }
                }

                break;
            }

            case "Show":
            {
                if (main.InvokeRequired)
                {
                    main.BeginInvoke(new Action(() =>
                        {
                            main.Show();
                            main.WindowState = FormWindowState.Normal;
                            if (main.notifyIcon1.Visible)
                            {
                                main.notifyIcon1.Visible = false;
                            }
                        }));
                }
                else
                {
                    main.Show();
                    main.WindowState = FormWindowState.Normal;
                    if (main.notifyIcon1.Visible)
                    {
                        main.notifyIcon1.Visible = false;
                    }
                }

                break;
            }

            case "Suppress":
            {
                Properties.Settings.Default.SuppressN = "True";
                Properties.Settings.Default.Save();
                break;
            }
            }
        }