예제 #1
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            Logger.LogInformation("OnActivated() {0}", args.GetType());
            DisappearingMessagesManager.DeleteExpiredMessages();
            if (args is ToastNotificationActivatedEventArgs toastArgs)
            {
                string requestedConversation = toastArgs.Argument;
                bool   createdMainWindow     = await CreateMainWindow(requestedConversation);

                if (!createdMainWindow)
                {
                    if (args is IViewSwitcherProvider viewSwitcherProvider && viewSwitcherProvider.ViewSwitcher != null)
                    {
                        ActivationViewSwitcher switcher = viewSwitcherProvider.ViewSwitcher;
                        int currentId = toastArgs.CurrentlyShownApplicationViewId;
                        if (viewSwitcherProvider.ViewSwitcher.IsViewPresentedOnActivationVirtualDesktop(toastArgs.CurrentlyShownApplicationViewId))
                        {
                            var   taskCompletionSource = new TaskCompletionSource <bool>();
                            await Views[currentId].Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                try
                                {
                                    Logger.LogInformation("OnActivated() selecting conversation");
                                    Views[currentId].Locator.MainPageInstance.TrySelectConversation(requestedConversation);
                                }
                                catch (Exception e)
                                {
                                    Logger.LogError("OnActivated() TrySelectConversation() failed: {0}\n{1}", e.Message, e.StackTrace);
                                }
                                finally
                                {
                                    taskCompletionSource.SetResult(false);
                                }
                            });
                            await taskCompletionSource.Task;
                            await viewSwitcherProvider.ViewSwitcher.ShowAsStandaloneAsync(currentId);
                        }
                        else
                        {
                            await CreateSecondaryWindowOrShowMain(switcher, requestedConversation);
                        }
                    }
                    else
                    {
                        Logger.LogError("OnActivated() has no ViewSwitcher");
                    }
                }
            }
예제 #2
0
 private async void App_Resuming(object sender, object e)
 {
     Logger.LogInformation("Resuming");
     DisappearingMessagesManager.DeleteExpiredMessages();
     await Handle.Reacquire();
 }
예제 #3
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            Logger.LogInformation("OnActivated() {0}", args.GetType());
            if (args.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs;
                // We support multiple protocols so check what scheme was used to launch the app
                if (protocolArgs.Uri.Scheme.ToLower() == "signalpassback")
                {
                    if (protocolArgs.Data.ContainsKey("token"))
                    {
                        string signalCaptchaToken   = (string)protocolArgs.Data["token"];
                        var    registerPageInstance = CurrentSignalWindowsFrontend(MainViewId).Locator.RegisterPageInstance;
                        registerPageInstance.CaptchaCode           = signalCaptchaToken;
                        registerPageInstance.CaptchaWebViewEnabled = false;
                        CurrentSignalWindowsFrontend(MainViewId).Locator.CaptchaPageInstance.View.Frame.GoBack();
                    }
                    else
                    {
                        Logger.LogError("App was launched with signalpassback:// but wasn't passed a token");
                    }
                    return;
                }
            }
            DisappearingMessagesManager.DeleteExpiredMessages();
            if (args is ToastNotificationActivatedEventArgs toastArgs)
            {
                string requestedConversation = toastArgs.Argument;
                bool   createdMainWindow     = await CreateMainWindow(requestedConversation);

                if (!createdMainWindow)
                {
                    if (args is IViewSwitcherProvider viewSwitcherProvider && viewSwitcherProvider.ViewSwitcher != null)
                    {
                        ActivationViewSwitcher switcher = viewSwitcherProvider.ViewSwitcher;
                        int currentId = toastArgs.CurrentlyShownApplicationViewId;
                        if (viewSwitcherProvider.ViewSwitcher.IsViewPresentedOnActivationVirtualDesktop(toastArgs.CurrentlyShownApplicationViewId))
                        {
                            var   taskCompletionSource = new TaskCompletionSource <bool>();
                            await Views[currentId].Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                try
                                {
                                    Logger.LogInformation("OnActivated() selecting conversation");
                                    Views[currentId].Locator.MainPageInstance.TrySelectConversation(requestedConversation);
                                }
                                catch (Exception e)
                                {
                                    Logger.LogError("OnActivated() TrySelectConversation() failed: {0}\n{1}", e.Message, e.StackTrace);
                                }
                                finally
                                {
                                    taskCompletionSource.SetResult(false);
                                }
                            });
                            await taskCompletionSource.Task;
                            await viewSwitcherProvider.ViewSwitcher.ShowAsStandaloneAsync(currentId);
                        }
                        else
                        {
                            await CreateSecondaryWindowOrShowMain(switcher, requestedConversation);
                        }
                    }
                    else
                    {
                        Logger.LogError("OnActivated() has no ViewSwitcher");
                    }
                }
            }