Beispiel #1
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    await CreateAndActivateFrame(typeof(NavigationRoot));
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs) && _authenticationService.IsLoggedIn)
            {
                var defaultHandler = new DefaultLaunchActivationHandler(typeof(NewsFeedList), _navigationService);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #2
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                await InitializeAsync();

                if (Window.Current.Content == null)
                {
                    Window.Current.Content = _shell?.Value ?? new Frame();
                }
            }

            ActivationHandler activationHandler = GetActivationHandlers()
                                                  .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                DefaultLaunchActivationHandler defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                Window.Current.Activate();

                await StartupAsync();
            }
        }
Beispiel #3
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += Frame_Navigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += ActivationService_BackRequested;

                        // Stuff for popping a confirmation dialog before closing
                        SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += App_CloseRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                // Set custom stuff
                SetTitlebar();
                SetMinimalWindowSize();
                // Maximize UI on Xbox (Disabled, only here for testing)
                //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);

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

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #4
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    if (_shell?.Value == null)
                    {
                        var frame = new Frame();
                        NavigationService      = _container.RegisterNavigationService(frame);
                        Window.Current.Content = frame;
                    }
                    else
                    {
                        var viewModel = ViewModelLocator.LocateForView(_shell.Value);

                        ViewModelBinder.Bind(viewModel, _shell.Value, null);

                        ScreenExtensions.TryActivate(viewModel);

                        NavigationService      = _container.GetInstance <INavigationService>();
                        Window.Current.Content = _shell?.Value;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem, NavigationService);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #5
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

//#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    _app.DebugSettings.EnableFrameRateCounter = false;
                }
//#endif

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = _shell;
                    NavigationService.Frame.NavigationFailed += (sender, e) =>
                    {
                        throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                    };
                    NavigationService.Frame.Navigated += OnFrameNavigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #6
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += Frame_Navigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += ActivationService_BackRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                Edi.UWP.Helpers.UI.SetWindowLaunchSize(720, 920);

                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #7
0
 private async Task HandleActivationAsync(object activationArgs)
 {
     if (IsInteractive(activationArgs))
     {
         var defaultHandler = new DefaultLaunchActivationHandler(defaultNavItem);
         if (defaultHandler.CanHandle(activationArgs))
         {
             await defaultHandler.HandleAsync(activationArgs);
         }
     }
 }
Beispiel #8
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Retrieve current user if available
                if (activationArgs is IActivatedEventArgsWithUser argsWithUser)
                {
                    CurrentUser = argsWithUser.User;
                    await ContactHelper.CreateContactFromCurrentUserAsync();
                }
                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += OnNavigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += ActivationService_BackRequested;
                    }
                }
            }
            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
 private async Task HandleActivationAsync(object activationArgs)
 {
     if (IsInteractive(activationArgs))
     {
         string arguments      = (activationArgs as LaunchActivatedEventArgs)?.Arguments ?? "";
         var    defaultHandler = new DefaultLaunchActivationHandler(GetStartupView(arguments, defaultNavItem));
         if (defaultHandler.CanHandle(activationArgs))
         {
             await defaultHandler.HandleAsync(activationArgs);
         }
     }
 }
Beispiel #10
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = _shell;
                    NavigationService.Frame.NavigationFailed += (sender, e) => throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                    NavigationService.Frame.Navigated        += OnFrameNavigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers().FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                DispatcherHelper.Initialize();

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

                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                UI.SetWindowLaunchSize(3000, 2000);

                // Tasks after activation
                await StartupAsync();
            }
        }
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += Frame_Navigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += ActivationService_BackRequested;
                    }
                }
            }

#pragma warning disable IDE0008 // Use explicit type
            var activationHandler = GetActivationHandlers()
#pragma warning restore IDE0008 // Use explicit type
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
#pragma warning disable IDE0008 // Use explicit type
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
#pragma warning restore IDE0008 // Use explicit type
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #12
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (this.IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await this.InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = this._shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += this.Frame_Navigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += this.ActivationService_BackRequested;
                    }
                }
            }

            var activationHandler = this.GetActivationHandlers().FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (this.IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(this._defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await this.StartupAsync();
            }

            DispatcherHelper.Initialize();
            Messenger.Default.Register <NotificationMessageAction <string> >(this, this.HandleNotificationMessage);
        }
Beispiel #13
0
        private async Task HandleActivationAsync(object activationArgs)
        {
            var activationHandler = GetActivationHandlers().FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }
            }
        }
        public async Task ActivateAsync(object activationArgs)
        {
            _backgroundTaskService.RegisterBackgroundTask("BingNewImageTrigger", new TimeTrigger(15, false), false);

            if (IsInteractive(activationArgs))
            {
                await InitializeAsync();

                if (Window.Current.Content == null)
                {
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    NavigationService.Navigated += Frame_Navigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += ActivationService_BackRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                Window.Current.Activate();

                await StartupAsync();
            }
        }
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content              = _shell?.Value ?? new Frame();
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync().ConfigureAwait(false);

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = shell?.Value ?? new Frame();
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs).ConfigureAwait(false);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs).ConfigureAwait(false);
                }

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

                // Tasks after activation
                await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => StartupAsync().ConfigureAwait(false));
            }
        }
Beispiel #17
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                /* inizializzare elementi come la registrazione dell'attività
                 * in background prima del caricamento dell'app */
                await InitializeAsync();

                /* non ripetere l'inizializzazione dell'app quando la finestra ha già contenuto,
                 * basta assicurarsi che la finestra è attiva */
                if (Window.Current.Content == null)
                {
                    // crea un frame che funge da contesto di navigazione e passa alla prima pagina
                    Window.Current.Content = _shell?.Value ?? new Frame();
                }
            }
            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }
            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }
                // assicurarsi che la finestra corrente sia attiva
                Window.Current.Activate();
                // tasks dopo l'attivazione
                await StartupAsync();
            }
        }
Beispiel #18
0
        /// <summary>
        /// Метод: Активировать Сервиса активации
        /// </summary>
        /// <param name="activationArgs">Аргументы активации</param>
        /// <returns>Нет</returns>
        public async Task ActivateAsync(object activationArgs)
        {
            // Если запуск интерактивный, то ...
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                // Инициализирует такие вещи, как регистрация фоновых задач,
                // перед тем как приложение загружно
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                // Если текущее окно ещё не инициализировано, то выполнить инициализацию
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to
                    // the first page
                    Window.Current.Content = _shell?.Value ?? new Frame();
                    // Задать обработчик ошибок навигации
                    NavigationService.NavigationFailed += (sender, e) =>
                    {
                        throw e.Exception;
                    };
                    // Задать обработчик события "после выполнения навигации"
                    NavigationService.Navigated += Frame_Navigated;
                    // Если задано текущее представление, то ...
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        // Задать обработчик события "Запрос возврата назад"
                        SystemNavigationManager.GetForCurrentView().BackRequested +=
                            ActivationService_BackRequested;
                    }
                }
            }

            // Получает обработчик Сервиса "сохранить и восстановить"
            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            /// Если обработчик Сервиса "сохранить и восстановить" существует, то ...
            if (activationHandler != null)
            {
                // Обработать
                await activationHandler.HandleAsync(activationArgs);
            }

            // Если запуск интерактивный, то ...
            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                // Ensure the current window is active
                // Активировать текущее окно
                Window.Current.Activate();

                // Tasks after activation
                // Выполнить задачи после активации
                await StartupAsync();
            }
        }
Beispiel #19
0
        public async Task ActivateAsync(object activationArgs)
        {
            long iD = -1;

            if (IsInteractive(activationArgs))
            {
                if (((IActivatedEventArgs)activationArgs).Kind == ActivationKind.Protocol)
                {
                    var    targetUrl = Uri.UnescapeDataString(((ProtocolActivatedEventArgs)activationArgs).Uri.Query.Substring(1));
                    Uri    uri       = new Uri(targetUrl);
                    string Name      = uri.Host;
                    iD = await WebsiteDataSource.AddNewAsync(Name, uri);
                }

                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();


                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = _shell;
                    NavigationService.Frame.NavigationFailed += (sender, e) =>
                    {
                        throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                    };
                    NavigationService.Frame.Navigated += OnFrameNavigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }
                else
                {
                    var protocolHandler = new ProtocolActivationHandler(_defaultNavItem, iD);
                    if (protocolHandler.CanHandle(activationArgs))
                    {
                        await protocolHandler.HandleAsync(activationArgs);
                    }
                }

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

                // Tasks after activation
                await StartupAsync();

                if (iD != -1) //If the app has been launched via protocol
                {
                    await((Views.WebViewPage)NavigationService.Frame.Content).EnterMiniView();
                }
            }
        }
Beispiel #20
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = _shell?.Value ?? new Frame();
                }
            }

            //var activationHandler = GetActivationHandlers().FirstOrDefault(h => h.CanHandle(activationArgs));

            //if (activationHandler != null)
            //{
            //    await activationHandler.HandleAsync(activationArgs);
            //}

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }

            // var stopWatch= new Stopwatch();
            // stopWatch.Start();
            var addonData = await Task.Run(() => Storage.LoadAddonData());

            if (addonData != null)
            {
                Singleton <Session> .Instance.AddonData.AddRange(addonData);

                Debug.WriteLine("AddonData count: " + Singleton <Session> .Instance.AddonData.Count);

                Singleton <Session> .Instance.StoreAddons = new ObservableCollection <StoreAddon>(await Task.Run(() => Parse.LoadStoreAddons(Singleton <Session> .Instance.AddonData)));
                Debug.WriteLine("StoreAddons count: " + Singleton <Session> .Instance.StoreAddons.Count);
            }
            // stopWatch.Stop();
            // Debug.WriteLine("Time: "+stopWatch.ElapsedMilliseconds);



            var userKnownSubFolders = await Task.Run(() => Storage.LoadKnownSubFoldersFromUser());

            if (userKnownSubFolders != null)
            {
                Singleton <Session> .Instance.KnownSubFolders.UnionWith(userKnownSubFolders);

                Debug.WriteLine("Subfolders count: " + Singleton <Session> .Instance.KnownSubFolders.Count);
            }

            Application.Current.Suspending += new SuspendingEventHandler(App_Suspending);

            //var addonData = await Task.Run(() => Storage.LoadAddonData());

            // Singleton<Session>.Instance.AddonData.AddRange(addonData);

            // Debug.WriteLine("Addondata count: " + Singleton<Session>.Instance.AddonData.Count);

            var settings = Singleton <SettingsViewModel> .Instance;
            await settings.EnsureInstanceInitializedAsync();

            bool autoRefresh = settings.IsAutoRefreshVersions ?? false;

            if (autoRefresh)
            {
                await Tasks.FindProjectUrlAndDownLoadVersionsFor(Singleton <Session> .Instance.SelectedGame.Addons);

                await Tasks.AutoUpdate(Singleton <Session> .Instance.SelectedGame.Addons);
            }
        }
Beispiel #21
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsInteractive(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (Window.Current.Content == null)
                {
                    var accentColor   = Edi.UWP.Helpers.UI.GetAccentColor();
                    var btnHoverColor = Color.FromArgb(128,
                                                       (byte)(accentColor.R + 30),
                                                       (byte)(accentColor.G + 30),
                                                       (byte)(accentColor.B + 30));

                    Edi.UWP.Helpers.UI.ApplyColorToTitleBar(
                        accentColor,
                        Colors.White,
                        Colors.LightGray,
                        Colors.Gray);

                    Edi.UWP.Helpers.UI.ApplyColorToTitleButton(
                        accentColor, Colors.White,
                        btnHoverColor, Colors.White,
                        accentColor, Colors.White,
                        Colors.LightGray, Colors.Gray);

                    // Create a Frame to act as the navigation context and navigate to the first page
                    Window.Current.Content = _shell;
                    NavigationService.Frame.NavigationFailed += (sender, e) => throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                    NavigationService.Frame.Navigated        += OnFrameNavigated;
                    if (SystemNavigationManager.GetForCurrentView() != null)
                    {
                        SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                    }
                }
            }

            var activationHandler = GetActivationHandlers()
                                    .FirstOrDefault(h => h.CanHandle(activationArgs));

            if (activationHandler != null)
            {
                await activationHandler.HandleAsync(activationArgs);
            }

            if (IsInteractive(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                // Tasks after activation
                await StartupAsync();
            }
        }
Beispiel #22
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsActivation(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // We spawn a separate Window for files.
                if (activationArgs is FileActivatedEventArgs fileArgs)
                {
                    bool mainView = Window.Current.Content == null;
                    void CreateView()
                    {
                        FontMapView map = new FontMapView
                        {
                            IsStandalone = true,
                        };

                        _ = map.ViewModel.LoadFromFileArgsAsync(fileArgs);

                        // You have to activate the window in order to show it later.
                        Window.Current.Content = map;
                        Window.Current.Activate();
                    }

                    var view = await WindowService.CreateViewAsync(CreateView, false);

                    await WindowService.TrySwitchToWindowAsync(view, mainView);

                    return;
                }

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (WindowService.MainWindow == null)
                {
                    void CreateMainView()
                    {
                        // Create a Frame to act as the navigation context and navigate to the first page
                        Window.Current.Content = new Frame();
                        NavigationService.Frame.NavigationFailed += (sender, e) => throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                        NavigationService.Frame.Navigated        += OnFrameNavigated;

                        if (SystemNavigationManager.GetForCurrentView() != null)
                        {
                            SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                        }
                    }

                    var view = await WindowService.CreateViewAsync(CreateMainView, true);

                    await WindowService.TrySwitchToWindowAsync(view, true);
                }
                else
                {
                    /* Main Window exists, make it show */
                    _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(WindowService.MainWindow.View.Id);
                    WindowService.MainWindow.CoreView.CoreWindow.Activate();
                }
            }



            try
            {
                var activationHandler = GetActivationHandlers()?.FirstOrDefault(h => h.CanHandle(activationArgs));
                if (activationHandler != null)
                {
                    await activationHandler.HandleAsync(activationArgs);
                }
            }
            catch
            {
            }

            if (IsActivation(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

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

                ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;

                // Tasks after activation
                await StartupAsync();
            }
        }