예제 #1
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     ToastNotificationManagerCompat.OnActivated += t =>
     {
         ToastArguments args = ToastArguments.Parse(t.Argument);
         //t.Use
         Current.Dispatcher.Invoke(delegate
         {
             if (!args.Contains("action"))
             {
                 return;
             }
             else
             {
                 int state = args.GetInt("action");
                 if (state == 0)
                 {
                     Modetor.Net.Server.Core.HttpServers.BaseServer.Servers[args.Get("si")].Suspend();
                 }
                 else if (state == 1)
                 {
                     Modetor.Net.Server.Core.HttpServers.BaseServer.Servers[args.Get("si")].Resume();
                 }
                 else if (state == 2)
                 {
                     // Started....
                 }
             }
             //MessageBox.Show(args.Get("action"));
         });
     };
 }
예제 #2
0
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            if (e is ToastNotificationActivatedEventArgs toastActivationArgs)
            {
                // Obtain the arguments from the notification
                ToastArguments args = ToastArguments.Parse(toastActivationArgs.Argument);

                if (args.Get("action") is "Settings")
                {
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                }
            }
        }
        private static bool IsSame(ToastArguments expected, ToastArguments actual)
        {
            if (expected.Count != actual.Count)
            {
                return(false);
            }

            foreach (var pair in expected)
            {
                if (!actual.Contains(pair.Key))
                {
                    return(false);
                }

                if (actual.Get(pair.Key) != pair.Value)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #4
0
        private void Init(bool isFirst)
        {
            if (isFirst)
            {
                Timer.Enabled = true;

#if DEBUG
                Label_CurrentRequestCountText.Visible = true;
                Label_CurrentRequestCount.Visible     = true;
                Width += 200;
#endif

                #region Setting

                if (!ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).HasFile)
                {
                    Settings.Default.Upgrade();//低版本配置文件复制到高版本配置文件
                }

                #endregion

                DateTimePicker.Value   = DateTime.Today;
                DateTimePicker.MaxDate = DateTime.Today;
                DataGridViewIssues.AutoGenerateColumns = false;
                DataGridViewIssues.MultiSelect         = false;

                ToastManager.Clear();

                issueExcludeIdList = Settings.Default.issueExclude;
                ContextMenuStripForNotifyIcon.ItemClicked += new ToolStripItemClickedEventHandler(ToolStripItemForNotifyIcon_Click);
                if (Settings.Default.IsLogout)
                {
                    Logout();
                }
                else
                {
                    Login();
                }
                ToastNotificationManagerCompat.OnActivated += toastArgs =>
                {
                    ToastArguments args = ToastArguments.Parse(toastArgs.Argument);

                    switch (Enum.Parse(typeof(ToastActionType), args.Get("action")))
                    {
                    case ToastActionType.RemindLater:
                        issueManager.SendToast(args.Get("contentId"), isShow: false);
                        break;

                    case ToastActionType.Click:
                        Invoke((EventHandler) delegate
                        {
                            System.Diagnostics.Process.Start(Settings.Default.RedMineHost + "issues/" + args.Get("contentId"));
                        });
                        break;

                    default:
                        break;
                    }
                };
            }
        }
        public void TestStronglyTyped()
        {
            ToastArguments args = new ToastArguments()
                                  .Add("isAdult", true)
                                  .Add("isPremium", false)
                                  .Add("age", 22)
                                  .Add("level", 0)
                                  .Add("gpa", 3.97)
                                  .Add("percent", 97.3f);

#if !WINRT
            args.Add("activationKind", ToastActivationType.Background);
#endif

            AssertEqual(
                new ToastArguments()
            {
                { "isAdult", "1" },
                { "isPremium", "0" },
                { "age", "22" },
                { "level", "0" },
                { "gpa", "3.97" },
                { "percent", "97.3" },
#if !WINRT
                { "activationKind", "1" }
#endif
            }, args);

            Assert.AreEqual(true, args.GetBool("isAdult"));
            Assert.AreEqual("1", args.Get("isAdult"));

            Assert.AreEqual(false, args.GetBool("isPremium"));
            Assert.AreEqual("0", args.Get("isPremium"));

            Assert.AreEqual(22, args.GetInt("age"));
            Assert.AreEqual(22d, args.GetDouble("age"));
            Assert.AreEqual(22f, args.GetFloat("age"));
            Assert.AreEqual("22", args.Get("age"));

            Assert.AreEqual(0, args.GetInt("level"));

            Assert.AreEqual(3.97d, args.GetDouble("gpa"));

            Assert.AreEqual(97.3f, args.GetFloat("percent"));

#if !WINRT
            Assert.AreEqual(ToastActivationType.Background, args.GetEnum <ToastActivationType>("activationKind"));

            if (args.TryGetValue("activationKind", out ToastActivationType activationType))
            {
                Assert.AreEqual(ToastActivationType.Background, activationType);
            }
            else
            {
                Assert.Fail("TryGetValue as enum failed");
            }

            // Trying to get enum that isn't an enum should return false
            Assert.IsFalse(args.TryGetValue("percent", out activationType));
#endif

            // After serializing and deserializing, the same should work
            args = ToastArguments.Parse(args.ToString());

            Assert.AreEqual(true, args.GetBool("isAdult"));
            Assert.AreEqual("1", args.Get("isAdult"));

            Assert.AreEqual(false, args.GetBool("isPremium"));
            Assert.AreEqual("0", args.Get("isPremium"));

            Assert.AreEqual(22, args.GetInt("age"));
            Assert.AreEqual(22d, args.GetDouble("age"));
            Assert.AreEqual(22f, args.GetFloat("age"));
            Assert.AreEqual("22", args.Get("age"));

            Assert.AreEqual(0, args.GetInt("level"));

            Assert.AreEqual(3.97d, args.GetDouble("gpa"));

            Assert.AreEqual(97.3f, args.GetFloat("percent"));

#if !WINRT
            Assert.AreEqual(ToastActivationType.Background, args.GetEnum <ToastActivationType>("activationKind"));

            if (args.TryGetValue("activationKind", out activationType))
            {
                Assert.AreEqual(ToastActivationType.Background, activationType);
            }
            else
            {
                Assert.Fail("TryGetValue as enum failed");
            }

            // Trying to get enum that isn't an enum should return false
            Assert.IsFalse(args.TryGetValue("percent", out activationType));
#endif
        }