コード例 #1
0
ファイル: NotificationHelper.cs プロジェクト: zhxie/Ikas
 /// <summary>
 /// Initialize toast notification.
 /// </summary>
 public static void InitializeNotification()
 {
     // Register AUMID, COM server, and activator
     DesktopNotificationManagerCompat.RegisterAumidAndComServer <IkasNotificationActivator>(IkasNotificationActivator.AppId);
     DesktopNotificationManagerCompat.RegisterActivator <IkasNotificationActivator>();
 }
コード例 #2
0
 public static void PrepareNotificationManager()
 {
     // Register AUMID and COM server (for Desktop Bridge apps, this no-ops)
     DesktopNotificationManagerCompat.RegisterAumidAndComServer <MyNotificationActivator>("Manomama7.KTU-AIS_Scraper");
     DesktopNotificationManagerCompat.RegisterActivator <MyNotificationActivator>();
 }
コード例 #3
0
        private async void ButtonPopToast_Click(object sender, RoutedEventArgs e)
        {
            string title          = "Andrew sent you a picture";
            string content        = "Check this out, The Enchantments!";
            string image          = "https://picsum.photos/364/202?image=883";
            int    conversationId = 5;

            // Construct the toast content
            ToastContent toastContent = new ToastContent()
            {
                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "viewConversation" },
                    { "conversationId", conversationId.ToString() }
                }.ToString(),

                         Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text = title
                            },

                            new AdaptiveText()
                            {
                                Text = content
                            },

                            new AdaptiveImage()
                            {
                                // Non-Desktop Bridge apps cannot use HTTP images, so
                                // we download and reference the image locally
                                Source = await DownloadImageToDisk(image)
                            }
                        },

                        AppLogoOverride = new ToastGenericAppLogo()
                        {
                            Source   = await DownloadImageToDisk("https://unsplash.it/64?image=1005"),
                            HintCrop = ToastGenericAppLogoCrop.Circle
                        }
                    }
                },

                         Actions = new ToastActionsCustom()
                {
                    Inputs =
                    {
                        new ToastTextBox("tbReply")
                        {
                            PlaceholderContent = "Type a response"
                        }
                    },

                    Buttons =
                    {
                        // Note that there's no reason to specify background activation, since our COM
                        // activator decides whether to process in background or launch foreground window
                        new ToastButton("Reply", new QueryString()
                        {
                            { "action",          "reply"                   },
                            { "conversationId",  conversationId.ToString() }
                        }.ToString()),

                        new ToastButton("Like",  new QueryString()
                        {
                            { "action",          "like"                    },
                            { "conversationId",  conversationId.ToString() }
                        }.ToString()),

                        new ToastButton("View",  new QueryString()
                        {
                            { "action",          "viewImage"               },
                            { "imageUrl",        image                     }
                        }.ToString())
                    }
                }
            };

            // Make sure to use Windows.Data.Xml.Dom
            var doc = new XmlDocument();

            doc.LoadXml(toastContent.GetContent());

            // And create the toast notification
            var toast = new ToastNotification(doc);

            // And then show it
            DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
        }
コード例 #4
0
        private void CreateNotification(object sender, RoutedEventArgs e)
        {
            ToastContent content = new ToastContent()
            {
                // Arguments provided to the app when the notification is selected
                Launch = new QueryString()
                {
                    { "action", "null" }
                }.ToString(),

                // Visual component of the notification
                         Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text         = "New Notification Message",
                                HintMaxLines = 1
                            },
                            new AdaptiveText()
                            {
                                Text = "This test will make sure that notifications are working properly."
                            }
                        },

                        Attribution = new ToastGenericAttributionText()
                        {
                            Text = "Via App"
                        }
                    }
                },

                // Actions the user can perform from the notification
                         Actions = new ToastActionsCustom()
                {
                    Buttons =
                    {
                        new ToastButton("View Activity", "action=null")
                        {
                            ActivationType = ToastActivationType.Foreground
                        },

                        new ToastButton("Mark As Complete", "action=null")
                        {
                            ActivationType = ToastActivationType.Background
                        }
                    }
                }
            };

            // Create and show the notification
            //ToastNotification toast = new ToastNotification(content.GetXml());
            //DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);

            // Create a scheduled notification
            ScheduledToastNotification toast = new ScheduledToastNotification(content.GetXml(), DateTime.Now.AddSeconds(5));

            DesktopNotificationManagerCompat.CreateToastNotifier().AddToSchedule(toast);
        }
コード例 #5
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            _logger.Info("Zombie is powering up...");
            var connected = false;

            try
            {
                var binding  = ServiceUtils.CreateClientBinding(ServiceUtils.FreeTcpPort());
                var endpoint = new EndpointAddress(new Uri("http://localhost:8000/ZombieService/Service.svc"));
                var context  = new InstanceContext(new ZombieServiceCallback());
                Client = new ZombieServiceClient(context, binding, endpoint);

                GuiUpdateCallbackHandler callbackHandler = OnGuiUpdate;
                GuiUpdateCallbackEvent += callbackHandler;

                Client.Open();
                Client.Subscribe();

                // (Konrad) Get latest settings from ZombieService
                Settings = Client.GetSettings();

                connected = true;
                _logger.Info("Successfully connected to Zombie Service at http://localhost:8000/ZombieService/Service.svc");
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
            }

            // Register AUMID and COM server (for Desktop Bridge apps, this no-ops)
            DesktopNotificationManagerCompat.RegisterAumidAndComServer <MyNotificationActivator>("HOK.Zombie");

            // Register COM server and activator type
            DesktopNotificationManagerCompat.RegisterActivator <MyNotificationActivator>();

            // (Konrad) Create the startup window
            var m    = new ZombieModel(Settings);
            var vm   = new ZombieViewModel(m);
            var view = new ZombieView
            {
                DataContext = vm
            };

            var show = true;

            if (e.Args.Length == 1)
            {
                show = e.Args[0] == "show";
            }

            vm.Startup(view, show);

            Messenger.Default.Send(connected
                ? new UpdateStatus {
                Message = "Successfully connected to ZombieService!"
            }
                : new UpdateStatus {
                Message = "Connection to ZombieService failed!"
            });
            _logger.Info("Zombie is up and running!");
        }
コード例 #6
0
 public App()
 {
     DesktopNotificationManagerCompat.RegisterAumidAndComServer <MyNotificationActivator>("BoostBottonWpf.App");
     DesktopNotificationManagerCompat.RegisterActivator <MyNotificationActivator>();
 }
コード例 #7
0
 public void ShowToast()
 {
     DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
 }
コード例 #8
0
ファイル: Notifications.cs プロジェクト: AinaSnow/XFW
 public static void Initialise()
 {
     DesktopNotificationManagerCompat.RegisterAumidAndComServer <XivChatNotificationActivator>("XIVChat.XIVChat_Desktop");
     DesktopNotificationManagerCompat.RegisterActivator <XivChatNotificationActivator>();
 }