예제 #1
0
        // Toast Notification이 ActivationKind 종류인 앱을 시작하면 트리거된다.
        // Toast로부터 UserInput을 받아와서 MessageDialog를 띄워준다.
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            base.OnActivated(e);
            try
            {
                if (e.Kind == ActivationKind.ToastNotification)
                {
                    ToastNotificationActivatedEventArgs toastArgs = (ToastNotificationActivatedEventArgs)e;
                    await new Windows.UI.Popups.MessageDialog((string)toastArgs.UserInput["message"]).ShowAsync();
                }
            }
            catch { }
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;
                Window.Current.Content      = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage), e);
            }
            Window.Current.Activate();
        }
예제 #2
0
        private bool ToastificationHandle(ToastNotificationActivatedEventArgs toastActivationArgs)
        {
            Frame rootFrame = Window.Current.Content as Frame;
            // Parse the query string
            QueryString args = QueryString.Parse(toastActivationArgs.Argument);

            // See what action is being requested
            switch (args["action"])
            {
            case "HotNews":
                // The URL retrieved from the toast args
                string queryString = args["queryString"];
                News   news        = JsonSerializeHelper.Deserialize <News>(queryString);
                //二级Frame才显示该页
                if (NavigationService.DetailFrame.Content is NewsBodyPage &&
                    (NavigationService.DetailFrame.Content as NewsBodyPage).NewsBodyViewModel.News.Id.Equals(news.Id))
                {
                    break;
                }
                // Otherwise navigate to view it
                NavigationService.DetailFrameNavigate(typeof(NewsBodyPage), news);
                return(true);
            }
            //导航失败
            return(false);
        }
예제 #3
0
        /// <summary>
        /// Вызывается при переходе в приложение из Toast уведомлений
        /// </summary>
        /// <param name="e">Аргументы Toast уведомления</param>
        protected override void OnActivated(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 (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage), "N");
            }

            // Обработчик клика на уведомления.
            if (e.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs toastArgs = e as ToastNotificationActivatedEventArgs;
                if (rootFrame.Content is MainPage)
                {
                    (rootFrame.Content as MainPage).FindNotification(toastArgs.Argument);
                }
            }

            Window.Current.Activate();
        }
예제 #4
0
 public static async void Activated(ToastNotificationActivatedEventArgs args)
 {
     if (args != null)
     {
         string argument = args.Argument;
         await ShowDialogAsync($"Selected - {new AdaptableItem(argument)}");
     }
 }
예제 #5
0
 protected override void OnActivated(IActivatedEventArgs args)
 {
     if (args.Kind == ActivationKind.ToastNotification)
     {
         ToastNotificationActivatedEventArgs eventArgs = args as ToastNotificationActivatedEventArgs;
         WwwFormUrlDecoder query = new WwwFormUrlDecoder(eventArgs.Argument);
         context.SendMessageAsync(query[0].Value, eventArgs.UserInput["replyTextBox"].ToString(), query[1].Value == "1");
     }
 }
예제 #6
0
        //When launched through a notification, we do absolutely f*****g nothing different
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            ToastNotificationActivatedEventArgs e = args as ToastNotificationActivatedEventArgs;

            Frame rootFrame = Window.Current.Content as Frame;

            // Ne répétez pas l'initialisation de l'application lorsque la fenêtre comporte déjà du contenu,
            // assurez-vous juste que la fenêtre est active
            if (rootFrame == null)
            {
                // Créez un Frame utilisable comme contexte de navigation et naviguez jusqu'à la première page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Placez le frame dans la fenêtre active
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // Quand la pile de navigation n'est pas restaurée, accédez à la première page,
                // puis configurez la nouvelle page en transmettant les informations requises en tant que
                // paramètre

                if (localSettings.Values["token"] != null && localSettings.Values["stayConnect"] != null)
                {
                    bool isOnline = await API.IsOnlineAsync();

                    if (!isOnline) //On récupère un nouveau jeton d'accès pour cette session si l'ancien est mort
                    {
                        bool isReLogged = await API.RenewAccessTokenAsync();

                        if (isReLogged) //Si ça marche, on va à l'accueil
                        {
                            rootFrame.Navigate(typeof(acceuil), null);
                        }
                        else //Sinon, on renvoie à la mainpage
                        {
                            rootFrame.Navigate(typeof(MainPage), null);
                        }
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(acceuil), null);
                    }
                }
                else
                {
                    rootFrame.Navigate(typeof(MainPage), null);
                }
            }
            // Vérifiez que la fenêtre actuelle est active
            Window.Current.Activate();
        }
예제 #7
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            Debug.WriteLine("OnActivated");
            ViewModel.LoadData();

            if (args.Kind == ActivationKind.Protocol)
            {
                Debug.WriteLine("OnActivated:Protocol");
                Frame rootFrame = CreateRootFrame();
                RestoreStatus(args.PreviousExecutionState);

                if (rootFrame.Content == null)
                {
                    if (!rootFrame.Navigate(typeof(MainPage)))
                    {
                        throw new Exception(LocalizableStrings.APP_NO_INITIAL_PAGE);
                    }
                }

                MainPage mainPage = rootFrame.Content as MainPage;
                ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs;
                if (protocolArgs.Uri != null && !string.IsNullOrEmpty(protocolArgs.Uri.PathAndQuery))
                {
                    string itemTitle = protocolArgs.Uri.PathAndQuery;
                    Debug.WriteLine("protocol activation: itemTitle = " + itemTitle);

                    try
                    {
                        TileViewModel pinnedItem = TilesViewModel.Items.First(x => x.Title == itemTitle);
                        if (pinnedItem != null)
                        {
                            rootFrame.Navigate(typeof(SecondaryTilePage), protocolArgs.Uri.PathAndQuery);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("OnActivated: " + ex.Message);
                    }
                }
            }
            else if (args.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs toastArgs = args as ToastNotificationActivatedEventArgs;
                ValueSet values = toastArgs.UserInput;
                foreach (var v in values)
                {
                    Debug.WriteLine("ToastNotificationActivatedEventArgs: {0}={1}", v.Key, v.Value);
                }
            }
            else if (args.Kind == ActivationKind.VoiceCommand)
            {
                OnVoiceActivation(args);
            }
            Window.Current.Activate();
        }
예제 #8
0
        public void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            Frame frame = ConstructUI();

            App.Current.CallSystem.CallManager.ActiveCallChanged += CallManager_ActiveCallChanged;
            MainWindow = Window.Current;

            switch (args.Kind)
            {
            case ActivationKind.Launch:
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            ShowCallUIWindow();
                        }
                        frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                App.Current.OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
예제 #9
0
        private async void HandleArguments(ToastNotificationActivatedEventArgs args)
        {
            string arguments = args.Argument;

            string action   = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("action=", StringComparison.InvariantCulture)).Split('=')[1];
            string from     = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("from=", StringComparison.InvariantCulture)).Split('=')[1];
            string deviceid = args.Argument.Split('&').First(x => x.ToLower(new CultureInfo("en-US")).StartsWith("deviceid=", StringComparison.InvariantCulture)).Split('=')[1];

            switch (action.ToLower(new CultureInfo("en-US")))
            {
            case "reply":
            {
                try
                {
                    string     messagetosend = (string)args.UserInput["textBox"];
                    SmsDevice2 smsDevice     = SmsDevice2.FromId(deviceid);
                    await SmsUtils.SendTextMessageAsync(smsDevice, from, messagetosend);
                }
                catch
                {
                }

                break;
            }

            case "openthread":
            {
                ChatMenuItemControl selectedConvo = null;
                foreach (var convo in ViewModel.ChatConversations)
                {
                    var contact = convo.ViewModel.Contact;
                    foreach (var num in contact.Phones)
                    {
                        if (ContactUtils.ArePhoneNumbersMostLikelyTheSame(from, num.Number))
                        {
                            selectedConvo = convo;
                            break;
                        }
                    }
                    if (selectedConvo != null)
                    {
                        break;
                    }
                }
                if (selectedConvo != null)
                {
                    ViewModel.SelectedItem = selectedConvo;
                }
                break;
            }
            }
        }
예제 #10
0
파일: StartUp.cs 프로젝트: Huios/PhotoStore
        static void HandleToastNotification(ToastNotificationActivatedEventArgs args)
        {
            ValueSet userInput     = args.UserInput;
            string   pathFromToast = userInput["textBox"].ToString();

            ImageFile item = new ImageFile(pathFromToast);

            item.AddToCache();

            SingleInstanceManager singleInstanceManager = new SingleInstanceManager();

            singleInstanceManager.Run(Environment.GetCommandLineArgs());
        }
 public void Initialize(ToastNotificationActivatedEventArgs args)
 {
     // args.Argument contains information specified on Toast notification creation in file ToastNotificationsService.Samples.cs
     if (args.Argument == "ToastButtonActivationArguments")
     {
         // The application was launched by clicking on OK button of Toast Notification
         ActivationSource = "ActivationSourceButtonOk".GetLocalized();
     }
     else if (args.Argument == "ToastContentActivationParams")
     {
         // The application was launched by clicking on the main body of Toast Notification
         ActivationSource = "ActivationSourceContent".GetLocalized();
     }
 }
예제 #12
0
        /// <summary>
        /// Fired when the app is opened from a toast message.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            if (args is ToastNotificationActivatedEventArgs)
            {
                ToastNotificationActivatedEventArgs toastArgs = (ToastNotificationActivatedEventArgs)args;
                SetupAndALaunchApp(toastArgs.Argument);
            }
            else
            {
                SetupAndALaunchApp("");
            }
        }
예제 #13
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            try
            {
                if (args.Kind == ActivationKind.ToastNotification)
                {
                    ToastNotificationActivatedEventArgs toastargs = (ToastNotificationActivatedEventArgs)args;
                    Frame root = Window.Current.Content as Frame;
                    if (root == null)
                    {
                        root = new Frame();
                        Window.Current.Content = root;
                    }
                    if (root.Content == null)
                    {
                        root.Navigate(typeof(MainPage));
                    }
                    MainPage page            = (MainPage)root.Content;
                    string   toastactiveargs = toastargs.Argument;
                    if (toastactiveargs == "" || toastactiveargs == null)
                    {
                        return;
                    }
                    string      filepath = toastactiveargs.Substring(0, toastactiveargs.IndexOf('.') + 4);
                    StorageFile SF       = await StorageFile.GetFileFromPathAsync(filepath);

                    if (toastactiveargs.Contains("Open"))
                    {
                        await Windows.System.Launcher.LaunchFileAsync(SF);
                    }
                    if (toastactiveargs.Contains("Share"))
                    {
                        DataTransferManager.GetForCurrentView().DataRequested +=
                            (DataTransferManager sender, DataRequestedEventArgs Dataargs) =>
                        {
                            Dataargs.Request.Data.Properties.Title       = "共享图像";
                            Dataargs.Request.Data.Properties.Description = "共享以下图片。";
                            Dataargs.Request.Data.SetBitmap(Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(SF));
                        };
                        DataTransferManager.ShowShareUI();
                    }
                    if (toastactiveargs.EndsWith(".png") || toastactiveargs.EndsWith(".jpg"))
                    {
                        await Windows.System.Launcher.LaunchFileAsync(SF);
                    }
                }
            }
            catch { }
        }
예제 #14
0
        async protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            string parameter = string.Empty;

            if (args.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs t = args as ToastNotificationActivatedEventArgs;
                // Parse the query string
                parameter = t.Argument;
            }

            OnLaunchedOrActivated(parameter);
        }
예제 #15
0
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs toastArgs = args as ToastNotificationActivatedEventArgs;
                string jsonNotificationData = toastArgs.Argument;

                await OnLaunchOrActivated(args, jsonNotificationData);

                PwdCrypter.App.Logger.Debug("OnActivated");

                // Ensure the current window is active
                Window.Current.Activate();
                return;
            }
            base.OnActivated(args);
        }
예제 #16
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // 获取 ToastNotificationActivatedEventArgs 对象(从 App.xaml.cs 传来的)
            _toastArgs = e.Parameter as ToastNotificationActivatedEventArgs;

            if (_toastArgs != null)
            {
                // 获取 toast 的参数
                lblMsg.Text  = "argument: " + _toastArgs.Argument;
                lblMsg.Text += Environment.NewLine;

                // 获取 toast 的 输入框数据
                // UserInput 是一个 ValueSet 类型的数据,其继承自 IEnumerable 接口,可以 foreach(不能 for)
                foreach (string key in _toastArgs.UserInput.Keys)
                {
                    lblMsg.Text += $"key:{key}, value:{_toastArgs.UserInput[key]}";
                    lblMsg.Text += Environment.NewLine;
                }
            }
        }
예제 #17
0
        public static Dictionary <string, string> GetData(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;

                var dictionary = SplitArguments(toastActivationArgs.Argument);
                if (toastActivationArgs.UserInput != null && toastActivationArgs.UserInput.Count > 0)
                {
                    for (int i = 0; i < toastActivationArgs.UserInput.Count; i++)
                    {
                        dictionary.Add(toastActivationArgs.UserInput.Keys.ElementAt(i), toastActivationArgs.UserInput.Values.ElementAt(i).ToString());
                    }
                }

                return(dictionary);
            }

            return(null);
        }
예제 #18
0
        // Add any OnActivationCompleted customization here.
        private void OnActivatedByToast(ToastNotificationActivatedEventArgs toastActivationArgs)
        {
            ToastArguments toastArguments = ToastArguments.Parse(toastActivationArgs.Argument);
            ValueSet       userInput      = toastActivationArgs.UserInput;

            if (toastArguments.Contains("opcode"))
            {
                string opcode = toastArguments["opcode"];
                if ("device".Equals(opcode))
                {
                    sDeviceManager.HandleToast(toastArguments, userInput);
                }
            }

            // Close System Tray
            if (sAppServiceManager != null)
            {
                sAppServiceManager.Dispose();
                sAppServiceManager = null;
            }
        }
예제 #19
0
        /// <summary>
        /// Fired when the app is opened from a toast message.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            if (args is ToastNotificationActivatedEventArgs)
            {
                ToastNotificationActivatedEventArgs toastArgs = (ToastNotificationActivatedEventArgs)args;
                SetupAndALaunchApp(toastArgs.Argument);
            }
            else if (args is ProtocolActivatedEventArgs)
            {
                ProtocolActivatedEventArgs protcolArgs = (ProtocolActivatedEventArgs)args;
                string argsString = protcolArgs.Uri.OriginalString;
                int    protEnd    = argsString.IndexOf("://");
                argsString = protEnd == -1 ? argsString : argsString.Substring(protEnd + 3);
                SetupAndALaunchApp(argsString);
            }
            else
            {
                SetupAndALaunchApp(String.Empty);
            }
        }
예제 #20
0
        private void HandleToastActivation(ToastNotificationActivatedEventArgs args)
        {
            // Parse the query string
            var query = QueryString.Parse(args.Argument);

            query.TryGetValue("action", out string action);

            // See what action is being requested
            switch (action)
            {
            case NotificationConstants.AlertNewEpisode:
                if (long.TryParse(query["episodeId"], out long episodeId))
                {
                    new LocalObjectStorageHelper().Save(LocalStorageConstants.NavigateToEpisode, episodeId);

                    if (args.PreviousExecutionState == ApplicationExecutionState.Running ||
                        args.PreviousExecutionState == ApplicationExecutionState.Suspended)
                    {
                        ServiceLocator.Current.GetInstance <MainViewModel>().HandleActivation();
                    }
                }
                break;
            }
        }
예제 #21
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            // 通过协议激活应用程序时(参见 AssociationLaunching/ProtocolAssociation.xaml.cs 中的示例)
            if (args.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs;

                Frame rootFrame = new Frame();
                rootFrame.Navigate(typeof(Windows10.AssociationLaunching.ProtocolAssociation), protocolArgs);
                Window.Current.Content = rootFrame;
            }

            // 通过可返回结果的协议激活应用程序时(参见 App2AppCommunication/LaunchUriForResults.xaml.cs 中的示例)
            if (args.Kind == ActivationKind.ProtocolForResults)
            {
                ProtocolForResultsActivatedEventArgs protocolForResultsArgs = args as ProtocolForResultsActivatedEventArgs;

                Frame rootFrame = new Frame();
                rootFrame.Navigate(typeof(Windows10.App2AppCommunication.LaunchUriForResults), protocolForResultsArgs);
                Window.Current.Content = rootFrame;

                Window.Current.Activate();
            }

            // 通过 toast 激活应用程序时(前台方式激活)
            if (args.Kind == ActivationKind.ToastNotification)
            {
                ToastNotificationActivatedEventArgs toastArgs = args as ToastNotificationActivatedEventArgs;

                Frame rootFrame = new Frame();
                rootFrame.Navigate(typeof(Windows10.Notification.Toast.Demo), toastArgs);
                Window.Current.Content = rootFrame;

                Window.Current.Activate();
            }
        }
예제 #22
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            Frame frame;

            try
            {
                await Initialisation;
            }
            catch
            {
                await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
                {
                    await AccessSetup();
                    InitializateSystems();
                });
            }
            switch (args.Kind)
            {
            case ActivationKind.Launch:
                frame = ConstructUI();
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            frame.Navigate(typeof(InCallUI));
                        }
                        else
                        {
                            frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                        }
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame = ConstructUI();
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                frame = ConstructUI();
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                frame = ConstructUI();
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
예제 #23
0
 /// <summary>
 /// Handles activations from toasts activations.
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 protected override bool OnActivation(ToastNotificationActivatedEventArgs e)
 {
     return this.HandleArgumentsActivation(e.Argument);
 }
예제 #24
0
 /// <summary>
 /// Handles activations from toasts activations.
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 private bool OnActivation(ToastNotificationActivatedEventArgs e)
 {
     return(this.HandleArgumentsActivation(e.Argument));
 }
예제 #25
0
 protected abstract bool OnActivation(ToastNotificationActivatedEventArgs e);
예제 #26
0
 protected abstract bool OnActivation(ToastNotificationActivatedEventArgs e);
예제 #27
0
 private bool ToastificationHandle(ToastNotificationActivatedEventArgs toastActivationArgs)
 {
     Frame rootFrame = Window.Current.Content as Frame;
     // Parse the query string
     QueryString args = QueryString.Parse(toastActivationArgs.Argument);
     // See what action is being requested 
     switch (args["action"])
     {
         case "HotNews":
             // The URL retrieved from the toast args
             string queryString = args["queryString"];
             News news = JsonSerializeHelper.Deserialize<News>(queryString);
             //二级Frame才显示该页
             if (NavigationService.DetailFrame.Content is NewsBodyPage &&
                 (NavigationService.DetailFrame.Content as NewsBodyPage).NewsBodyViewModel.News.Id.Equals(news.Id))
                 break;
             // Otherwise navigate to view it
             NavigationService.DetailFrameNavigate(typeof(NewsBodyPage), news);
             return true;
     }
     //导航失败
     return false;
 }
예제 #28
0
        protected override void OnActivated(IActivatedEventArgs e)
        {
            previousExecState = e.PreviousExecutionState;
            Debug.WriteLine("App OnActivated: previous state = " + e.PreviousExecutionState.ToString());

            appActivationDesc = "App OnActivated: previous state = " + e.PreviousExecutionState.ToString() + "\nkind=" + e.Kind.ToString();

            Type pageType = null;
            Uri  uri      = null;

            if (e.Kind == ActivationKind.ToastNotification)
            {
                //Get the pre-defined arguments and user inputs from the eventargs;
                ToastNotificationActivatedEventArgs toastArgs = e as ToastNotificationActivatedEventArgs;
                var arguments = toastArgs.Argument;
                pageType = typeof(MainPage);
                uri      = new Uri("ms-appx:///?" + arguments);

                appActivationDesc += toastArgs.Argument;
            }

            if (pageType == null)
            {
                Application.Current.Exit();
                return;
            }

            // TODO: Handle URI activation
            // The received URI is eventArgs.Uri.AbsoluteUri
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // 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;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                rootFrame.Navigate(pageType, uri.Query);

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            else
            {
                MainPage p = rootFrame.Content as MainPage;
                if (p != null && pageType == typeof(MainPage))
                {
                    p.NavigateToPageWithParameter(uri.Query);
                }
                else
                {
                    rootFrame.Navigate(pageType, uri.Query);
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
예제 #29
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            IsForeground = true;
            Frame frame = ConstructUI();

            Dispatcher = Window.Current.Dispatcher;
            if (!PermissionSystem.IsAllPermissionsObtained && !await ObtainingAccess)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    ObtainingAccess = PermissionSystem.RequestAllPermissions();
                });

                await ObtainingAccess;
            }
            if (Initializating == null)
            {
                Initializating = InitializateSystems();
            }
            await Initializating;

            UISystem.Initializate(Dispatcher);
            NotificationSystem.RemoveCallToastNotifications();
            switch (args.Kind)
            {
            case ActivationKind.Launch:
                LaunchActivatedEventArgs launchActivationArgs = args as LaunchActivatedEventArgs;
                if (launchActivationArgs.PrelaunchActivated == false)
                {
                    if (frame.Content == null)
                    {
                        if (PhoneCallManager.IsCallActive)
                        {
                            CompactOverlayId = await CallUIPage.ShowInCallUI();
                        }
                        frame.Navigate(typeof(MainPage), launchActivationArgs.Arguments);
                    }
                }
                break;

            case ActivationKind.LockScreen:
                LockApplicationHost            = LockApplicationHost.GetForCurrentView();
                LockApplicationHost.Unlocking += LockApplicationHost_Unlocking;
                frame.Navigate(typeof(MainPage));
                break;

            case ActivationKind.Protocol:
                ProtocolActivatedEventArgs protocolActivationArgs = args as ProtocolActivatedEventArgs;
                switch (protocolActivationArgs.Uri.Scheme)
                {
                case TEL:
                    frame.Navigate(typeof(MainPage), protocolActivationArgs.Uri.LocalPath);
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            case ActivationKind.ToastNotification:
                ToastNotificationActivatedEventArgs toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                OnToastNotificationActivated(ToastActivationType.Foreground, toastActivationArgs.Argument);
                break;

            default:
                throw new NotSupportedException();
            }
            Window.Current.Activate();
        }
예제 #30
0
 protected virtual Task HandleActivation(ToastNotificationActivatedEventArgs args)
 {
     return(Task.CompletedTask);
 }
예제 #31
0
 void HandleActivation(ToastNotificationActivatedEventArgs args, bool wait)
 {
     NotificationActivationHelper.HandleActivation(Helper.InstaApi, Helper.InstaApiList, args.Argument,
                                                   args.UserInput, wait, OpenProfile, OpenLive, OpenPendingThreadRequest, OpenPost, OpenTV);
 }