private async Task LaunchApplicationAsync(object launchArgs) { try { var commandFile = await Package.Current.InstalledLocation.GetFileAsync("VoiceCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(commandFile); } catch (Exception ex) { EventLogger.Current.WriteError(ex.Message); } var rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); await this.InitializeServicesAsync(); Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(InitializingPage), launchArgs); } Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { //Install Cortana command definitions: var storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommands.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; rootFrame.Navigated += RootFrame_Navigated; }
private async void Page_Loaded(object sender, RoutedEventArgs e) { StorageFile storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///VoiceCommands.xml", UriKind.Absolute)); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); }
public override async Task OnInitializeAsync(IActivatedEventArgs args) { var url = new Uri("ms-appx:///Cortana.xml"); var file = await StorageFile.GetFileFromApplicationUriAsync(url); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(file); }
public static async void InstallVoiceCommandService(IEnumerable <string> deviceDisplayNames) { try { string countryCode = CultureInfo.CurrentCulture.Name.ToLower(); if (countryCode.Length == 0) { countryCode = "en-us"; } // 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(@"Resources\" + countryCode + @"\VoiceCommandService.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); VoiceCommandDefinition commandDefinitions; if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("CommandSet_" + countryCode, out commandDefinitions)) { await commandDefinitions.SetPhraseListAsync("device", deviceDisplayNames); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString()); } }
private async void BackGround_Title() { try { await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommand.xml"))); var status = await BackgroundExecutionManager.RequestAccessAsync(); foreach (var cur in BackgroundTaskRegistration.AllTasks) { if (cur.Value.Name == "TitleTask") { return; } } var builder = new BackgroundTaskBuilder(); builder.Name = "TitleTask"; builder.TaskEntryPoint = "mediaservice.TitleUpdateTask"; builder.SetTrigger(StorageLibraryContentChangedTrigger.Create(await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music))); builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable)); var task = builder.Register(); } catch (Exception e) { Debug.WriteLine(e.Message); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { if (!e.PrelaunchActivated) { await ActivationService.ActivateAsync(e); } try { var voiceCommandDefinition = await Package.Current.InstalledLocation.GetFileAsync(@"VoiceCommandDefinition.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(voiceCommandDefinition); if (Current.Resources["Locator"] is ViewModelLocator locator) { await locator.ShellViewModel.UpdateCatalogTypePhraseList(); } } catch (Exception) { Debug.WriteLine("Voice Command Definition (VCD) file not installed."); } Window.Current.Activate(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(960, 670)); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; #region Register Voice Commands try { System.Diagnostics.Debug.WriteLine("Loading VCD..."); StorageFile vcdFile = await Package.Current.InstalledLocation. GetFileAsync(@"VoiceCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync( vcdFile); System.Diagnostics.Debug.WriteLine("successfully loaded VCD..."); } catch (Exception err) { System.Diagnostics.Debug.WriteLine( "Failed to install VCD - " + err.Message); } #endregion // 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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
private async void OnStartSync() { //#if DEBUG await VoIPConnection.Current.ConnectAsync(); //#endif await Toast.RegisterBackgroundTasks(); BadgeUpdateManager.CreateBadgeUpdaterForApplication("App").Clear(); TileUpdateManager.CreateTileUpdaterForApplication("App").Clear(); ToastNotificationManager.History.Clear("App"); #if !DEBUG && !PREVIEW Execute.BeginOnThreadPool(async() => { await new AppUpdateService().CheckForUpdatesAsync(); }); #endif //if (ApiInformation.IsTypePresent("Windows.ApplicationModel.FullTrustProcessLauncher")) //{ // await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); //} try { // Prepare stuff for Cortana var localVoiceCommands = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///VoiceCommands/VoiceCommands.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(localVoiceCommands); } catch { } }
/// <summary> /// Updates Cortana with new commands and phrases from a VCD file /// </summary> public static async Task InstallVoiceCommands() { StorageFile file = await StorageFolders.FlawlessCowboy.GetFileAsync(vcdFilename); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(file); Task.Delay(500); //HACK }
/* * Register Custom Cortana Commands from VCD file */ public static async void RegisterVCD() { StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync( @"CustomVoiceCommandDefinitions.xml"); await VoiceCommandDefinitionManager .InstallCommandDefinitionsFromStorageFileAsync(vcd); }
async private void OnServiceThroughCortana(object sender, RoutedEventArgs e) { var vcd_path = "ms-appx:///voicecommands_advanced.xml"; var vcd_uri = new Uri(vcd_path); var vcd_file = await StorageFile.GetFileFromApplicationUriAsync(vcd_uri); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcd_file); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { //Live Tile, Cortana Commands & IAP Data Setup try { //Live Tile LiveTileService.SetLiveTile(); //Cortana VCD file install StorageFile voiceCommandsFile = await Package.Current.InstalledLocation.GetFileAsync(@"CortanaVoiceCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(voiceCommandsFile); //LicenseInfo for In-App Purchase #if DEBUG LicenseInformation = CurrentAppSimulator.LicenseInformation; #else LicenseInformation = CurrentApp.LicenseInformation; #endif } catch (Exception ex) { } //Set up navigation parameter model //INavigationParameterModel navigationParameterModel = new NavigationParameterModel(new DatabaseService(), LicenseInformation); 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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
private async Task PerformAsyncWork(string path) { LoggingService.Log(LoggingService.LogType.Debug, "Page loaded, performing async work"); // Set the app language ApplicationLanguages.PrimaryLanguageOverride = string.IsNullOrEmpty(SettingsService.Instance.CurrentAppLanguage) ? ApplicationLanguages.Languages[0] : SettingsService.Instance.CurrentAppLanguage; // Set the on back requested event SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; // Navigate to the first page await HandleProtocolAsync(path); // Run on the background thread await Task.Run(async() => { try { // Get the store and check for app updates var updates = await StoreContext.GetDefault().GetAppAndOptionalStorePackageUpdatesAsync(); // If we have updates navigate to the update page where we // ask the user if they would like to update or not (depending // if the update is mandatory or not). if (updates.Count > 0) { await NavigationService.Current.CallDialogAsync <PendingUpdateDialog>(); } // Test Version and tell user app upgraded HandleNewAppVersion(); // Clear the unread badge BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); // Handle donation logic await MonitizeService.Instance.InitProductInfoAsync(); // Register notifications // var engagementManager = StoreServicesEngagementManager.GetDefault(); // await engagementManager.RegisterNotificationChannelAsync(); //Todo: Implement this when fix is ready (UWP .NET CORE) //https://developercommunity.visualstudio.com/content/problem/130643/cant-build-release-when-i-use-microsoftservicessto.html // Install Cortana Voice Commands var vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"SoundByteCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch { // Ignore } }); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #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) { appState = await Startup.LoadAppStateInitial(); } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (appState == null) { appState = await Startup.LoadAppStateInitial(); } //rootFrame.Navigate(typeof(MainPage), e.Arguments); rootFrame.Navigate(typeof(MainPage), appState); } // Ensure the current window is active Window.Current.Activate(); try { StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync("CustomVoiceCommandDefinitions.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcd); } catch (Exception ex) { Debug.Write("Failed to register voice commands, because: " + ex); } }
static async Task RegisterVoiceCommandsAsync() { var storageFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///CortanaCommands.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync( storageFile); }
public async void RegisterVoiceCommands() { VoiceHandler = new DefaultVoiceCommandHandler(); var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///HeyCortanaMyWife.xml")); var doc = await XmlDocument.LoadFromFileAsync(storageFile); WriteAutoCommandsToHandler(doc); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); }
public static async Task Initialize() { try { var vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"VLCCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch { } }
/// <summary> /// Se invoca cuando el usuario final inicia la aplicación normalmente. Se usarán otros puntos /// de entrada cuando la aplicación se inicie para abrir un archivo específico, por ejemplo. /// </summary> /// <param name="e">Información detallada acerca de la solicitud y el proceso de inicio.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // No repetir la inicialización de la aplicación si la ventana tiene contenido todavía, // solo asegurarse de que la ventana está activa. if (rootFrame == null) { // Crear un marco para que actúe como contexto de navegación y navegar a la primera página. rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Cargar el estado de la aplicación suspendida previamente } // Poner el marco en la ventana actual. Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // Cuando no se restaura la pila de navegación, navegar a la primera página, // configurando la nueva página pasándole la información requerida como //parámetro de navegación rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Asegurarse de que la ventana actual está activa. Window.Current.Activate(); } try { StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"CommandamentsVeu.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); VoiceCommandDefinition comandSetEsES; VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("commSet_esES", out comandSetEsES); if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.Any()) { var w = VoiceCommandDefinitionManager.InstalledCommandDefinitions[comandSetEsES.Name]; string txt = w.ToString(); System.Diagnostics.Debug.WriteLine("Commandos instalados correctamente: " + txt); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed:" + ex); } }
protected async override void OnLaunched(LaunchActivatedEventArgs e) { var storageFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///commands.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync( storageFile); EnsureUICreated(e.PrelaunchActivated); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // 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("CortanaCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch (Exception ex) { Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString()); } } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { 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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); // Cortana voice commands. // Install Voice Command Definition (VCD) file. try { // Install the main VCD on launch to ensure // most recent version is installed. StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync( @"VoiceCommandObjects\VoiceCommandDefinitions.xml"); await VoiceCommandDefinitionManager .InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine( "Installing Voice Commands Failed: " + ex.ToString()); } } }
/// <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 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 (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // ナビゲーション スタックが復元されない場合は、最初のページに移動します。 // このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを //構成します rootFrame.Navigate(typeof(MainPage), e.Arguments); } // 現在のウィンドウがアクティブであることを確認します Window.Current.Activate(); try { // 俺コマンドの登録 StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"MyCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("ボイスコマンドの定義でエラーが発生しました", ex); } } }
private async Task ActivateWindowAsync(IActivatedEventArgs e, Type page) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); //以前のアプリ状態が中断で終了した場合 if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //以前中断したアプリケーションから状態を読み込む } Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { /* * var themeBrush = Resources["SplitViewBackgroundBrush"] as SolidColorBrush; * var view = ApplicationView.GetForCurrentView(); * view.TitleBar.BackgroundColor = themeBrush.Color; * view.TitleBar.ButtonForegroundColor = Colors.White; * view.TitleBar.ButtonBackgroundColor = themeBrush.Color; */ //アプリの最小幅を設定 ApplicationView.GetForCurrentView().SetPreferredMinSize(_appMinimumSize); //ウインドウのサイズ変更がされたとき Window.Current.SizeChanged += (s, ex) => { OnWindowSizeChanged(ex.Size); }; //MainPageへNavigate rootFrame.Navigate(page); OnWindowSizeChanged(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height)); } if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("Initialize")) { var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/VcdFile.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(file); ApplicationData.Current.LocalSettings.Values["Initialize"] = true; } await LoadAllDataAsync(); Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { 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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync( @"CustomVoiceCommand.xml"); await VoiceCommandDefinitionManager .InstallCommandDefinitionsFromStorageFileAsync(vcd); /* * try * { * StorageFile vcd = await Package.Current.InstalledLocation.GetFileAsync(@"CustomVoiceCommand.xml"); * await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcd); * } * catch (Exception exc) * { * Debug.Write("FAilded to register custom voice command " + exc.Message ) ; * }*/ }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { try { StorageFile commandsFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"SharePointSearchVoiceCommands.xml"); try { await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(commandsFile); } catch (Exception ex) { } } catch (Exception ex) { } 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 } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
public async void InstallCommandSets(string packageFilePath) { try { var storageFile = await _localStorageService.GetFileFromApplicationAsync(packageFilePath); var installAsyncAction = VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile as StorageFile); } catch (Exception e) { Logger.WriteLine(e, "Voice Commands failed to install"); } }
/// <summary> /// Installs the Voice Command Definitions. /// </summary> /// <returns> /// A <see cref="Task"/> that represents the operation. /// </returns> /// <remarks> /// Since there's no way to test that the VCD has been imported or that it's the current version it's okay to do this on application load. /// </remarks> private async Task InstallVoiceCommandsAsync() { try { StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"VoiceCommands.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString()); } }
private static async Task AsyncTryToRegistVoiceCommands(string fileNameOrPath) { try { var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileNameOrPath)); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(file); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public static async void InstallVCDFile() { try { StorageFile vcdFile = await Package.Current.InstalledLocation.GetFileAsync("BaozouVoiceCommand.xml"); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdFile); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString()); } }