Ejemplo n.º 1
0
        /// <summary>
        /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、
        /// アプリケーションが特定のファイルを開くために起動されたときなどに使用されます。
        /// </summary>
        /// <param name="e">起動の要求とプロセスの詳細を表示します。</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            await JumpListCreator.CreateDefaultList();

            if (_localSettings.Values.ContainsKey(Constants.ThemeDefault))
            {
                var themeType = (ThemeTypes)_localSettings.Values[Constants.ThemeDefault];
                switch (themeType)
                {
                case ThemeTypes.YOSPOS:
                    ThemeManager.SetThemeManager(ElementTheme.Dark);
                    ThemeManager.ChangeTheme(new Uri("ms-appx:///Themes/Yospos.xaml"));
                    break;
                }
            }
            SystemNavigationManager.GetForCurrentView().BackRequested += BackPressed;
            RootFrame = Window.Current.Content as Frame;
            if (_localSettings.Values.ContainsKey(Constants.NavigateBack) &&
                (bool)_localSettings.Values[Constants.NavigateBack])
            {
                if (RootFrame != null)
                {
                    return;
                }
            }
            var isIoT = ApiInformation.IsTypePresent("Windows.Devices.Gpio.GpioController");

            if (!isIoT)
            {
                TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
            }

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (RootFrame == null)
            {
                CreateRootFrame();
            }
            if (!isIoT)
            {
                BackgroundTaskUtils.UnregisterBackgroundTasks(BackgroundTaskUtils.ToastBackgroundTaskName);
                var task2 = await
                            BackgroundTaskUtils.RegisterBackgroundTask(BackgroundTaskUtils.ToastBackgroundTaskEntryPoint,
                                                                       BackgroundTaskUtils.ToastBackgroundTaskName, new ToastNotificationActionTrigger(),
                                                                       null);

                if (_localSettings.Values.ContainsKey(Constants.BackgroundEnable) && (bool)_localSettings.Values[Constants.BackgroundEnable])
                {
                    BackgroundTaskUtils.UnregisterBackgroundTasks(BackgroundTaskUtils.BackgroundTaskName);
                    var task = await
                               BackgroundTaskUtils.RegisterBackgroundTask(BackgroundTaskUtils.BackgroundTaskEntryPoint,
                                                                          BackgroundTaskUtils.BackgroundTaskName,
                                                                          new TimeTrigger(15, false),
                                                                          null);
                }
            }

            var             localStorageManager = new LocalStorageManager();
            CookieContainer cookieContainer     = await localStorageManager.LoadCookie("SACookies2.txt");

            bool cookieTest = true;
            foreach (Cookie cookie in cookieContainer.GetCookies(new Uri(Constants.CookieDomainUrl)))
            {
                if (cookie.Expired)
                {
                    cookieTest = false;
                }
            }

            if (cookieContainer.Count <= 0)
            {
                if (!RootFrame.Navigate(typeof(LoginPage)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            else
            {
                if (!cookieTest)
                {
                    if (!RootFrame.Navigate(typeof(LoginPage)))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }

                if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();

            try
            {
                // Install the main VCD. Since there's no simple way to test that the VCD has been imported, or that it's your most recent
                // version, it's not unreasonable to do this upon app load.
                StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"SomethingAwfulCommands.xml");

                await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }
        }
Ejemplo n.º 2
0
 public override async void Execute(object parameter)
 {
     await JumpListCreator.CreateDefaultList(true);
 }