コード例 #1
0
        public async void OnToastNotificationReceived(IActivatedEventArgs e)
        {
            // Handle toast activation
            if (e is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = e as ToastNotificationActivatedEventArgs;

                // Parse the query string
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                // See what action is being requested
                if (args.Contains("action"))
                {
                    switch (args["action"])
                    {
                    case "positive":
                        await ControlPoint.PerformNotificationActionAsync(Convert.ToUInt32(args["uid"]), ActionID.Positive);

                        break;

                    case "negative":
                        await ControlPoint.PerformNotificationActionAsync(Convert.ToUInt32(args["uid"]), ActionID.Negative);

                        break;
                    }
                }
            }
        }
コード例 #2
0
        public void postTurnOn()
        {
            TurnOffMode mode      = TurnOffMode.Automatic;
            int         turnOffMs = 0;
            int         delayBrew = 0;

            // Parse any parameters of the request that exist
            if (QueryString.Contains("mode"))
            {
                if (QueryString["mode"].ToString() == "manual")
                {
                    mode = TurnOffMode.Manual;
                }
            }

            if (QueryString.Contains("turnoffin"))
            {
                turnOffMs = Convert.ToInt32(QueryString["turnoffin"].ToString());
            }

            if (QueryString.Contains("delaybrew"))
            {
                delayBrew = Convert.ToInt32(QueryString["delaybrew"].ToString());
            }

            Application.Instance?.RequestTurnOnCoffeeMachine(mode, turnOffMs, delayBrew);
            SendSuccessStatusResponse();
        }
コード例 #3
0
        public async Task <T> Execute()
        {
            //if (QueryData != null && typeof(T) != typeof(int)) return QueryData;

            while (SQL == null)
            {
                await BaseScript.Delay(0);
            }

            if (QueryString.Contains("INSERT") || QueryString.Contains("UPDATE") || QueryString.Contains("DELETE"))
            {
                SQL.execute(QueryString, builtWhereParameters, new Action <T>(data => QueryData = data));
            }

            if (QueryString.Contains("SELECT"))
            {
                SQL.execute(QueryString, builtWhereParameters, new Action <T>(data => QueryData = data));
            }

            var ticks = 0;

            while (QueryData == null && ticks < 300)
            {
                await BaseScript.Delay(0);

                ticks++;
            }

            return(QueryData);
        }
コード例 #4
0
ファイル: Echo.cs プロジェクト: shinyboy/websocket-sharp
        protected override void OnMessage(MessageEventArgs e)
        {
            var msg = QueryString.Contains("name")
              ? String.Format("Returns '{0}' to {1}", e.Data, QueryString ["name"])
              : e.Data;

            Send(msg);
        }
コード例 #5
0
ファイル: QueryStringTests.cs プロジェクト: Axinom/Toolkit
        public void BasicOperations()
        {
            var qs = new QueryString();

            qs.Set("key", "value");
            Assert.AreEqual("value", qs.Get("key"));
            Assert.AreEqual("value", qs["key"]);
            Assert.AreEqual("value", qs.TryGet("key", "default"));
            Assert.AreEqual("default", qs.TryGet("nonexistingkey", "default"));

            Assert.IsTrue(qs.Contains("key"));
            qs.Remove("key");
            Assert.IsFalse(qs.Contains("key"));

            qs["key"] = "value";
            Assert.IsTrue(qs.Contains("key"));
        }
コード例 #6
0
ファイル: NetService.cs プロジェクト: stadham/LOVC
 protected string Query(string key)
 {
     if (QueryString.Contains(key))
     {
         return(QueryString [key]);
     }
     return(null);
 }
コード例 #7
0
        public void postChangeDelay()
        {
            int delay = 0;

            // Parse any parameters of the request that exist
            if (QueryString.Contains("minutes"))
            {
                delay = Convert.ToInt32(QueryString["minutes"].ToString());
            }

            Application.Instance?.RequestChangeBrewingDelay(delay);
            SendSuccessStatusResponse();
        }
コード例 #8
0
        /// <inheritdoc />
        public override void OnActivated(string arguments, NotificationUserInput userInput, string appUserModelId)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                if (arguments.Length == 0)
                {
                    return;
                }

                QueryString args = QueryString.Parse(arguments);

                if (args.Contains("action") == false)
                {
                    LogTo.Warning($"Received a Toast activation without an action argument: '{arguments}'");
                    return;
                }

                switch (args["action"])
                {
                // Restart plugin after crash
                case SMAPluginManager.ToastActionRestartAfterCrash:
                    if (args.Contains(SMAPluginManager.ToastActionParameterPluginId) == false)
                    {
                        LogTo.Error($"Received a ToastActionRestartAfterCrash toast activation without a plugin id parameter: '{arguments}'");
                        return;
                    }

                    var packageId = args[SMAPluginManager.ToastActionParameterPluginId];
                    SMAPluginManager.Instance.StartPlugin(packageId).RunAsync();
                    break;

                default:
                    LogTo.Warning($"Unknown notification action {args["action"]}: '{arguments}'");
                    break;
                }
            });
        }
コード例 #9
0
        public static string GetParameter(string args, string attribute)
        {
            if (string.IsNullOrWhiteSpace(args) == false)
            {
                QueryString arguments = QueryString.Parse(args);

                // See what action is being requested
                if (arguments.Contains(attribute))
                {
                    return(arguments[attribute]);
                }
                else
                {
                    return(string.Empty);
                }
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #10
0
        public async void Execute(Action <T> onQueryComplete)
        {
            /*if (QueryData != null)
             * {
             *  onQueryComplete(QueryData);
             *  return;
             * }*/

            while (SQL == null)
            {
                await BaseScript.Delay(0);
            }

            if (QueryString.Contains("INSERT") || QueryString.Contains("UPDATE") || QueryString.Contains("DELETE"))
            {
                SQL.execute(QueryString, builtWhereParameters, new Action <T>(onQueryComplete));
            }

            if (QueryString.Contains("SELECT"))
            {
                SQL.execute(QueryString, builtWhereParameters, new Action <T>(onQueryComplete));
            }
        }
コード例 #11
0
        public void TestContains()
        {
            QueryString qs = new QueryString();

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            qs.Add("isBook");

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsTrue(qs.Contains("isBook", null));
            Assert.IsFalse(qs.Contains("isBook", "True"));

            qs.Add("isBook", "True");

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsTrue(qs.Contains("isBook", null));
            Assert.IsTrue(qs.Contains("isBook", "True"));

            qs.Add("name", "Andrew");

            Assert.IsTrue(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", null));     // Value doesn't exist
            Assert.IsTrue(qs.Contains("name", "Andrew"));
            Assert.IsFalse(qs.Contains("Name", "Andrew")); // Wrong case on name
            Assert.IsFalse(qs.Contains("name", "andrew")); // Wrong case on value
            Assert.IsFalse(qs.Contains("Name"));           // Wrong case on name
        }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: toraidl/JPDict
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);
            await ActivationService.ActivateAsync(args);

            Helpers.ThemeHelper.SetThemeForJPDict();
            if (args is ToastNotificationActivatedEventArgs)
            {
                var         toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                QueryString parameters          = QueryString.Parse(toastActivationArgs.Argument);
                Frame       rootFrame           = Window.Current.Content as Frame;
                if (parameters.Contains("action"))
                {
                    switch (parameters["action"])
                    {
                    case "detailResult":
                        string keyword = parameters["keyword"];
                        if (rootFrame == null)
                        {
                            rootFrame = new Frame();
                            rootFrame.NavigationFailed += OnNavigationFailed;
                            // Place the frame in the current Window
                            Window.Current.Content = rootFrame;
                        }
                        if (rootFrame.Content == null)
                        {
                            rootFrame.Navigate(typeof(MainPage));
                            rootFrame.Navigate(typeof(ResultPage), keyword);
                        }
                        else
                        {
                            if (rootFrame.CanGoBack)
                            {
                                rootFrame.GoBack();
                            }
                            rootFrame.Navigate(typeof(ResultPage), keyword);
                            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
                        }
                        break;
                    }
                }

                CopyMainDb();
                InitOnlineServiceAsync();
                Helpers.ThemeHelper.SetThemeForJPDict();
                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }

                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    UpdatePromptHelper.LoadState();
                    if (UpdatePromptHelper.Updated)
                    {
                        rootFrame.Navigate(typeof(UpdatePage));
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(MainPage));
                    }
                }

                // Ensure the current window is active
                Window.Current.Activate();
                StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();
                string originalArgs = engagementManager.ParseArgumentsAndTrackAppLaunch(toastActivationArgs.Argument);

                // Use the originalArgs variable to access the original arguments
                // that were passed to the app.
            }

            if (args.Kind == ActivationKind.Protocol)
            {
                var uriArgs = args as ProtocolActivatedEventArgs;
                if (uriArgs != null)
                {
                    Frame rootFrame = Window.Current.Content as Frame;
                    CopyMainDb();
                    InitOnlineServiceAsync();
                    // Do not repeat app initialization when the Window already has content,
                    // just ensure that the window is active
                    if (rootFrame == null)
                    {
                        // Create a Frame to act as the navigation context and navigate to the first page
                        rootFrame = new Frame();
                        rootFrame.NavigationFailed += OnNavigationFailed;
                        // Place the frame in the current Window
                        Window.Current.Content = rootFrame;
                    }
                    if (rootFrame.Content == null)
                    {
                        if (uriArgs.Uri.Host == "result")
                        {
                            //rootFrame.BackStack.Insert(0,new PageStackEntry(typeof(MainPage), null, new EntranceNavigationTransitionInfo()));
                            rootFrame.Navigate(typeof(MainPage));
                            rootFrame.Navigate(typeof(ResultPage), Uri.UnescapeDataString(uriArgs.Uri.Query.Replace("?keyword=", "")));
                        }
                    }

                    // Ensure the current window is active
                    Window.Current.Activate();
                }
            }
        }
コード例 #13
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            // 处理正常启动
            if (e is LaunchActivatedEventArgs launchActivatedArgs && launchActivatedArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    rootFrame.Navigate(typeof(MainPage), launchActivatedArgs.Arguments);
                }
            }

            // Handle toast activation
            if (e is ToastNotificationActivatedEventArgs toastActivationArgs)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(MainPage));
                }

                // 等待加载完成
                while (true)
                {
                    if (MainPage.RootPage.IsLoaded)
                    {
                        break;
                    }
                    await Task.Delay(500);
                }

                // Parse the query string (using QueryString.NET)
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                if (args.Contains("action"))
                {
                    string id = string.Empty;
                    // See what action is being requested
                    switch (args["action"])
                    {
                    // Open the subject
                    case "viewSubject":
                        id = args["subjectId"];
                        MainPage.RootPage.ResetFrameBackStack();
                        MainPage.RootPage.NavigateToPage(typeof(EpisodePage), args["subjectId"], null);
                        break;

                    case "gotoPlaySite":
                        id = args["url"];
                        var sites = await BangumiData.GetAirSitesByBangumiIdAsync(id);

                        await Launcher.LaunchUriAsync(new Uri(args["url"]));

                        var episode = JsonConvert.DeserializeObject <EpisodeForSort>(args["episode"]);
                        ToastNotificationHelper.Toast("看完了吗?",
                                                      $"Ep.{episode.Sort} {Converters.StringOneOrTwo(episode.NameCn, episode.Name)}", "看完了!看完了!",
                                                      "markEpWatched", "episodeId", episode.Id.ToString(), string.Empty, string.Empty,
                                                      Microsoft.Toolkit.Uwp.Notifications.ToastActivationType.Background, true);
                        break;
                    }
                }
            }

            // 处理其它激活方式

            // 确保当前窗口处于活动状态
            Window.Current.Activate();
        }
コード例 #14
0
        protected override void OnActivated(IActivatedEventArgs e)
        {
            // Get the root frame
            Frame rootFrame = Window.Current.Content as Frame;

            // TODO: Initialize root frame just like in OnLaunched

            // Handle toast activation
            if (e is ToastNotificationActivatedEventArgs && SignInManager.CurrentUser != null)
            {
                var toastActivationArgs = e as ToastNotificationActivatedEventArgs;

                // Parse the query string (using QueryString.NET)
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                Func <Type, Guid, Tuple <IndexGridViewItem, Guid> > ToNavigationParameters = (type, id) =>
                {
                    var item = IndexPage.GetIndexGridViewItems(SignInManager.CurrentUser.Role).First(x => x.Views.Contains(type));
                    item.Views = item.Views.OrderBy(x => x != type);
                    return(new Tuple <IndexGridViewItem, Guid>(item, id));
                };

                if (args.Contains("Type"))
                {
                    switch (args["Type"])
                    {
                    case "Account":
                    {
                        rootFrame.Navigate(typeof(PanelPage), ToNavigationParameters(typeof(ViewAccount), Guid.Parse(args["ObjectId"])), new DrillInNavigationTransitionInfo());
                        break;
                    }

                    case "Order":
                    {
                        rootFrame.Navigate(typeof(PanelPage), ToNavigationParameters(typeof(ViewOrder), Guid.Parse(args["ObjectId"])), new DrillInNavigationTransitionInfo());
                        break;
                    }

                    case "Product":
                    {
                        rootFrame.Navigate(typeof(PanelPage), ToNavigationParameters(typeof(ViewProduct), Guid.Parse(args["ObjectId"])), new DrillInNavigationTransitionInfo());
                        break;
                    }

                    case "Promotion":
                    {
                        rootFrame.Navigate(typeof(PanelPage), ToNavigationParameters(typeof(ViewOrder), Guid.Parse(args["ObjectId"])), new DrillInNavigationTransitionInfo());
                        break;
                    }

                    case "Dic":
                    {
                        rootFrame.Navigate(typeof(PanelPage), ToNavigationParameters(typeof(ViewOrderDispatchStatus), Guid.Parse(args["ObjectId"])), new DrillInNavigationTransitionInfo());
                        break;
                    }
                    }
                }
            }

            // TODO: Handle other types of activation

            // Ensure the current window is active
            Window.Current.Activate();
        }
コード例 #15
0
ファイル: App.xaml.cs プロジェクト: rymate1234/WinIRC
        protected async Task Activated(IActivatedEventArgs e)
        {
            // Initialise the app if it's not already open
            Debug.WriteLine("App activated!");
            var loaded = await InitApp(e);

            // Handle toast activation
            if (e.Kind == ActivationKind.ToastNotification && loaded && NavigationService.Content is MainPage)
            {
                MainPage mainPage = NavigationService.Content as MainPage;

                var args = e as ToastNotificationActivatedEventArgs;
                var toastActivationArgs = args;
                // Parse the query string
                QueryString qryStr = QueryString.Parse(toastActivationArgs.Argument);
                if (!qryStr.Contains("action"))
                {
                    return;
                }
                var ircHandler = IrcUiHandler.Instance;
                if (ircHandler == null)
                {
                    return;
                }
                // See what action is being requested
                if (qryStr["action"] == "reply")
                {
                    string channel  = qryStr["channel"];
                    string server   = qryStr["server"];
                    string username = qryStr["username"];
                    var    message  = args.UserInput["tbReply"].ToString();
                    if (!ircHandler.connectedServersList.Contains(server))
                    {
                        return;
                    }

                    if (mainPage != null)
                    {
                        string replyMessage = channel.StartsWith("#")
                            ? (username + ": " + message)
                            : message;

                        mainPage.MentionReply(server, channel, replyMessage);
                    }
                    if (!mainPage.currentChannel.Equals(channel))
                    {
                        mainPage.SwitchChannel(server, channel, false);
                    }
                }
                else if (qryStr["action"] == "viewConversation")
                {
                    // The conversation ID retrieved from the toast args
                    string channel = qryStr["channel"];
                    string server  = qryStr["server"];

                    if (mainPage == null)
                    {
                        return;
                    }

                    if (!ircHandler.connectedServersList.Contains(server))
                    {
                        return;
                    }

                    // If we're already viewing that channel, do nothing
                    if (!mainPage.currentChannel.Equals(channel))
                    {
                        mainPage.SwitchChannel(server, channel, false);
                    }
                }
            }

            if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs eventArgs = e as ProtocolActivatedEventArgs;
                // TODO: Handle URI activation
                // The received URI is eventArgs.Uri.AbsoluteUri
                var uri  = eventArgs.Uri;
                var port = 0;
                if (uri.Port == 0)
                {
                    port = 6667;
                }
                else
                {
                    port = uri.Port;
                }

                WinIrcServer server = new WinIrcServer
                {
                    Name     = uri.Host,
                    Hostname = uri.Host,
                    Port     = port,
                    Ssl      = uri.Scheme == "ircs"
                };
                if (uri.Segments.Length >= 2)
                {
                    server.Channels += "#" + uri.Segments[1];
                }

                MainPage.instance.IrcPrompt(server);
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
コード例 #16
0
        public static bool ContainsAttribute(string args, string attribute)
        {
            QueryString arguments = QueryString.Parse(args);

            return(arguments.Contains(attribute));
        }
コード例 #17
0
        /// <summary>
        /// Chamado quando notificações são clicadas
        /// </summary>
        /// <param name="args"></param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Não repita a inicialização do aplicativo quando a Janela já tiver conteúdo,
            // apenas verifique se a janela está ativa
            if (rootFrame == null)
            {
                // Crie um Quadro para atuar como o contexto de navegação e navegue para a primeira página
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Carregue o estado do aplicativo suspenso anteriormente
                }

                // Coloque o quadro na Janela atual
                Window.Current.Content = rootFrame;

                if (args.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplashScreen extendedSplash = new ExtendedSplashScreen(args.SplashScreen, loadState);
                    Window.Current.Content = extendedSplash;
                }
            }


            if (args is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = args as ToastNotificationActivatedEventArgs;

                // Parse the query string (using QueryString.NET)
                QueryString q = QueryString.Parse(toastActivationArgs.Argument);

                if (!q.Contains("action"))
                {
                    return;
                }

                // See what action is being requested
                switch (q["action"])
                {
                    //case "acceptResponderRequest":
                    //    ResponderService.Service.AcceptRequest(q["conversationId"]);
                    //    //if (rootFrame.Content.GetType() == typeof(MainPage))
                    //    //{
                    //    //    MainPage mp = rootFrame.Content as MainPage;
                    //    //    mp.ViewModel.NavigationService.Navigate("Responder", q["conversationId"]);
                    //    //}
                    //    AnalyticsTracker.Send(HitBuilder.CreateCustomEvent("Responder Notification", "Accept").Build());
                    //    break;
                    //case "launchResponder":
                    //    if (rootFrame.Content.GetType() == typeof(MainPage))
                    //    {
                    //        MainPage mp = rootFrame.Content as MainPage;
                    //        mp.ViewModel.NavigationService.Navigate("Responder", q["conversationId"]);
                    //    }
                    //    AnalyticsTracker.Send(HitBuilder.CreateCustomEvent("Responder Notification", "Launch").Build());
                    //    break;
                }
            }
        }
コード例 #18
0
ファイル: App.xaml.cs プロジェクト: meteorsnows/Roamit
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            Debug.WriteLine("Activated.");

            Frame rootFrame = Window.Current.Content as Frame;

            bool isJustLaunched = (rootFrame == null);

            if (e is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = e as ToastNotificationActivatedEventArgs;

                // Parse the query string
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                if (!args.Contains("action"))
                {
                    LaunchRootFrameIfNecessary(ref rootFrame, true);
                    return;
                }

                HistoryRow hr;
                switch (args["action"])
                {
                case "cloudClipboard":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ClipboardReceive), "CLOUD_CLIPBOARD");
                    break;

                case "clipboardReceive":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ClipboardReceive), args["guid"]);
                    break;

                case "fileProgress":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    if (rootFrame.Content is MainPage)
                    {
                        break;
                    }
                    rootFrame.Navigate(typeof(MainPage));
                    break;

                case "fileFinished":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    if (rootFrame.Content is MainPage)
                    {
                        break;
                    }
                    rootFrame.Navigate(typeof(MainPage), "history");
                    break;

                case "openFolder":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFolderFromPathAsync((hr.Data as ReceivedFileCollection).StoreRootPath);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "openFolderSingleFile":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFolderFromPathAndSelectSingleItemAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "openSingleFile":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFileFromPathAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "saveAsSingleFile":
                case "saveAs":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ProgressPage));
                    var guid = Guid.Parse(args["guid"]);
                    await ReceivedSaveAsHelper.SaveAs(guid);

                    if ((isJustLaunched) || (DeviceInfo.FormFactorType != DeviceInfo.DeviceFormFactorType.Desktop))
                    {
                        Application.Current.Exit();
                    }
                    else
                    {
                        rootFrame.GoBack();
                    }
                    break;

                default:
                    LaunchRootFrameIfNecessary(ref rootFrame, true);
                    break;
                }
            }
            else if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs pEventArgs = e as ProtocolActivatedEventArgs;

                if ((pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake") || (pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake/"))
                {
                    Debug.WriteLine("Wake request received");
                    Application.Current.Exit();
                }
                else
                {
                    string clipboardData       = ParseFastClipboardUri(pEventArgs.Uri.AbsoluteUri);
                    string remoteLaunchUriData = ParseRemoteLaunchUri(pEventArgs.Uri.AbsoluteUri);
                    string localLaunchUriData  = ParseLocalLaunchUri(pEventArgs.Uri.AbsoluteUri);
                    string commServiceData     = ParseCommunicationServiceData(pEventArgs.Uri.AbsoluteUri);
                    bool   isSettings          = ParseSettings(pEventArgs.Uri.AbsoluteUri);
                    string receiveDialogData   = ParseReceive(pEventArgs.Uri.AbsoluteUri);


                    if (isSettings)
                    {
                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                        }
                        rootFrame.Navigate(typeof(MainPage), "settings");
                    }
                    else if (receiveDialogData.Length > 0)
                    {
                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                        }
                        rootFrame.Navigate(typeof(MainPage), "receiveDialog");

                        if (receiveDialogData.Length > 1)
                        {
                            var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(receiveDialogData.Substring(1).DecodeBase64());
                            await ParseMessage(data);
                        }
                    }
                    else if (commServiceData.Length > 0)
                    {
                        var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(commServiceData.DecodeBase64());
                        await ParseMessage(data);
                    }
                    else if (clipboardData.Length > 0)
                    {
                        string[] parts = clipboardData.Split('?');
                        var      guid  = await TextReceiver.QuickTextReceivedAsync(parts[0].DecodeBase64(), parts[1].DecodeBase64());

                        LaunchRootFrameIfNecessary(ref rootFrame, false);
                        rootFrame.Navigate(typeof(ClipboardReceive), guid.ToString());
                    }
                    else if (remoteLaunchUriData.Length > 0)
                    {
#if !DEBUG
                        App.Tracker.Send(HitBuilder.CreateCustomEvent("ExtensionCalled", "").Build());
#endif

                        string type = ExternalContentHelper.SetUriData(new Uri(remoteLaunchUriData.DecodeBase64()));

                        SendDataTemporaryStorage.IsSharingTarget = true;

                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                            rootFrame.Navigate(typeof(MainPage), new ShareTargetDetails
                            {
                                Type = type,
                            });
                        }
                        else
                        {
                            MainPage.Current.BeTheShareTarget(new ShareTargetDetails
                            {
                                Type = type,
                            });
                        }
                    }
                    else if (localLaunchUriData.Length > 0)
                    {
                        try
                        {
                            //TODO: Log it in history
                            await LaunchOperations.LaunchUrl(localLaunchUriData.DecodeBase64());
                        }
                        catch
                        {
                        }

                        if (rootFrame == null)
                        {
                            Application.Current.Exit();
                        }
                    }
                    else
                    {
                        LaunchRootFrameIfNecessary(ref rootFrame, true);
                    }
                }
            }
            else
            {
                LaunchRootFrameIfNecessary(ref rootFrame, true);
            }

            base.OnActivated(e);
        }
コード例 #19
0
        public void TestContains()
        {
            QueryString qs = new QueryString();

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            qs.Add("isBook");

            Assert.IsFalse(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", "Andrew"));

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsTrue(qs.Contains("isBook", null));
            Assert.IsFalse(qs.Contains("isBook", "True"));

            qs.Add("isBook", "True");

            Assert.IsTrue(qs.Contains("isBook"));
            Assert.IsTrue(qs.Contains("isBook", null));
            Assert.IsTrue(qs.Contains("isBook", "True"));

            qs.Add("name", "Andrew");

            Assert.IsTrue(qs.Contains("name"));
            Assert.IsFalse(qs.Contains("name", null)); // Value doesn't exist
            Assert.IsTrue(qs.Contains("name", "Andrew"));
            Assert.IsFalse(qs.Contains("Name", "Andrew")); // Wrong case on name
            Assert.IsFalse(qs.Contains("name", "andrew")); // Wrong case on value
            Assert.IsFalse(qs.Contains("Name")); // Wrong case on name
        }
コード例 #20
0
ファイル: Chat.cs プロジェクト: agoragames/websocket-sharp
 private string getName()
 {
     return(QueryString.Contains("name")
      ? QueryString["name"]
      : "anon#" + getNum());
 }
コード例 #21
0
ファイル: App.xaml.cs プロジェクト: MattBDev/WinIRC
        protected override void OnActivated(IActivatedEventArgs e)
        {
            // Get the root frame
            Frame rootFrame = Window.Current.Content as Frame;

            var loaded = true;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                this.SetTheme();

                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
                loaded = false;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage));

                // Ensure the current window is active
                Window.Current.Activate();
                loaded = false;
            }

            // Handle toast activation
            if (e.Kind == ActivationKind.ToastNotification && loaded)
            {
                var args = e as ToastNotificationActivatedEventArgs;
                var toastActivationArgs = args;

                // Parse the query string
                QueryString qryStr = QueryString.Parse(toastActivationArgs.Argument);

                if (!qryStr.Contains("action"))
                {
                    return;
                }

                var ircHandler = IrcUiHandler.Instance;
                if (ircHandler == null)
                {
                    return;
                }

                // See what action is being requested
                if (qryStr["action"] == "reply")
                {
                    string channel  = qryStr["channel"];
                    string server   = qryStr["server"];
                    string username = qryStr["username"];

                    var message = args.UserInput["tbReply"];

                    var mainPage = (MainPage)rootFrame.Content;

                    if (!ircHandler.connectedServersList.Contains(server))
                    {
                        return;
                    }

                    if (mainPage != null)
                    {
                        mainPage.MentionReply(server, channel, username + ": " + message);
                    }

                    if (!mainPage.currentChannel.Equals(channel))
                    {
                        mainPage.SwitchChannel(server, channel, false);
                    }
                }
                else if (qryStr["action"] == "viewConversation")
                {
                    // The conversation ID retrieved from the toast args
                    string channel = qryStr["channel"];
                    string server  = qryStr["server"];

                    var mainPage = (MainPage)rootFrame.Content;

                    if (mainPage == null)
                    {
                        return;
                    }

                    if (!ircHandler.connectedServersList.Contains(server))
                    {
                        return;
                    }

                    // If we're already viewing that channel, do nothing
                    if (!mainPage.currentChannel.Equals(channel))
                    {
                        mainPage.SwitchChannel(server, channel, false);
                    }
                }

                // If we're loading the app for the first time, place the main page on
                // the back stack so that user can go back after they've been
                // navigated to the specific page
                if (rootFrame.BackStack.Count == 0)
                {
                    rootFrame.BackStack.Add(new PageStackEntry(typeof(MainPage), null, null));
                }
            }

            if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs eventArgs = e as ProtocolActivatedEventArgs;

                // TODO: Handle URI activation
                // The received URI is eventArgs.Uri.AbsoluteUri
                var uri  = eventArgs.Uri;
                var port = 0;

                if (uri.Port == 0)
                {
                    port = 6667;
                }
                else
                {
                    port = uri.Port;
                }

                IrcServer server = new IrcServer
                {
                    name     = uri.Host,
                    hostname = uri.Host,
                    port     = port,
                    ssl      = uri.Scheme == "ircs",
                };

                if (uri.Segments.Length >= 2)
                {
                    server.channels += "#" + uri.Segments[1];
                }

                MainPage.instance.IrcPrompt(server);
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }