protected override async void OnNavigatedTo(NavigationEventArgs e) { if (string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsKey) || string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsApiKeyEndpoint)) { this.mainPage.IsEnabled = false; await new MessageDialog("Missing Text Analytics Key. Please enter the key in the Settings page.", "Missing API Key").ShowAsync(); } else { bool isNotAvailableRegion = TextAnalyticsHelper.NotAvailableAzureRegions.Any(r => SettingsHelper.Instance.TextAnalyticsApiKeyEndpoint.Contains(r, StringComparison.OrdinalIgnoreCase)); if (isNotAvailableRegion) { this.mainPage.IsEnabled = false; await new MessageDialog("Text Analytics API v3 is not available in the following regions: China North 2, China East. Please change your Text Analytics key and region in the Settings page to a supported region.", "API key not supported").ShowAsync(); } else { this.mainPage.IsEnabled = true; SampleTextList.AddRange(TextAnalyticsDataLoader.GetTextSamples()); if (SampleTextList.Any()) { this.sampleTextComboBox.SelectedIndex = 0; await AnalyzeTextAsync(); } } } base.OnNavigatedTo(e); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsKey) || string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsApiKeyEndpoint)) { this.mainPage.IsEnabled = false; await new MessageDialog("Missing Text Analytics Key. Please enter the key in the Settings page.", "Missing API Key").ShowAsync(); } else { this.mainPage.IsEnabled = true; SampleTextList.AddRange(TextAnalyticsDataLoader.GetTextSamples()); if (SampleTextList.Any()) { this.sampleTextComboBox.SelectedIndex = 0; await AnalyzeTextAsync(); } } base.OnNavigatedTo(e); }