示例#1
0
文件: Application.cs 项目: Venzz/Venz
        //
        // Activation.
        //

        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PrelaunchActivated)
            {
                Prelaunch = PrelaunchStage.ApplicationPrelaunched;
            }
            else if (Prelaunch == PrelaunchStage.ApplicationPrelaunched)
            {
                Prelaunch = PrelaunchStage.ApplicationActivated;
            }
            else
            {
                Prelaunch = PrelaunchStage.None;
            }

            if (args.IsNewInstance())
            {
                var frame = new Frame();
                Window.Current.Content = frame;
                Window.Current.Activate();
                Window.Current.CoreWindow.KeyUp += OnCoreWindowKeyUp;
                Dispatcher = new ApplicationDispatcher();
                await StartAsync(frame, args.Kind, args.PreviousExecutionState, Prelaunch);

                await InitializationTask;
                await OnManuallyActivatedAsync(frame, true, Prelaunch, args.Arguments);
                await OnStartedAsync();
            }
            else
            {
                Window.Current.Activate();
                await OnManuallyActivatedAsync((Frame)Window.Current.Content, false, Prelaunch, args.Arguments);
            }
        }
示例#2
0
文件: Application.cs 项目: Venzz/Venz
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            Prelaunch = (Prelaunch == PrelaunchStage.ApplicationPrelaunched) ? PrelaunchStage.ApplicationActivated : PrelaunchStage.None;
            if (args.IsNewInstance())
            {
                var frame = new Frame();
                Window.Current.Content = frame;
                Window.Current.Activate();
                Window.Current.CoreWindow.KeyUp += OnCoreWindowKeyUp;
                Dispatcher = new ApplicationDispatcher();
                await StartAsync(frame, args.Kind, args.PreviousExecutionState, Prelaunch);

                await InitializationTask;
                if (args is FileActivatedEventArgs)
                {
                    await OnFileActivatedAsync(frame, true, Prelaunch, (FileActivatedEventArgs)args);
                }
                else if (args is ProtocolActivatedEventArgs)
                {
                    await OnUriActivatedAsync(frame, true, Prelaunch, (ProtocolActivatedEventArgs)args);
                }
                else if (args is VoiceCommandActivatedEventArgs)
                {
                    await OnVoiceActivatedAsync(frame, true, Prelaunch, (VoiceCommandActivatedEventArgs)args);
                }
                await OnStartedAsync();
            }
            else
            {
                Window.Current.Activate();
                if (args is FileActivatedEventArgs)
                {
                    await OnFileActivatedAsync((Frame)Window.Current.Content, false, Prelaunch, (FileActivatedEventArgs)args);
                }
                else if (args is ProtocolActivatedEventArgs)
                {
                    await OnUriActivatedAsync((Frame)Window.Current.Content, false, Prelaunch, (ProtocolActivatedEventArgs)args);
                }
                else if (args is VoiceCommandActivatedEventArgs)
                {
                    await OnVoiceActivatedAsync((Frame)Window.Current.Content, false, Prelaunch, (VoiceCommandActivatedEventArgs)args);
                }
            }
        }