private void DeleteKey(object sender, EventArgs e) { ApiKeyManager.ArcGISDeveloperApiKey = null; _currentKeyText.Text = string.Empty; ApiKeyManager.StoreCurrentKey(); _statusText.Text = "API key removed"; }
private void DeleteKeyButton_Click(object sender, RoutedEventArgs e) { ApiKeyManager.ArcGISDeveloperApiKey = null; CurrentKeyText.Text = string.Empty; ApiKeyManager.StoreCurrentKey(); Status.Text = "API key removed"; }
private void SetKey(object sender, EventArgs e) { // Set the developer Api key. ApiKeyManager.ArcGISDeveloperApiKey = _keyEntry.Text; ApiKeyManager.StoreCurrentKey(); _ = UpdateValidityText(); }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Add event handler for when this sample is unloaded. Unloaded += SampleUnloaded; // Create new Map with basemap Map myMap = new Map(Basemap.CreateStreets()); // Subscribe to location changed event so that map can zoom to location MyMapView.LocationDisplay.LocationChanged += LocationDisplay_LocationChanged; // Enable location display MyMapView.LocationDisplay.IsEnabled = true; // Enable tap-for-info pattern on results MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView MyMapView.Map = myMap; // Initialize the LocatorTask with the provided service Uri _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable all controls now that the locator task is ready SearchEntry.IsEnabled = true; LocationEntry.IsEnabled = true; SearchButton.IsEnabled = true; SearchViewButton.IsEnabled = true; }
private void SetKeyButton_Click(object sender, RoutedEventArgs e) { // Set the developer Api key. ApiKeyManager.ArcGISDeveloperApiKey = KeyEntryBox.Text; ApiKeyManager.StoreCurrentKey(); _ = UpdateValidityText(); }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Assign the map to the MapView. MyMapView.Map = myMap; try { // Initialize the LocatorTask with the provided service Uri. _geocoder = await LocatorTask.CreateAsync(_serviceUri); // Enable UI controls now that the geocoder is ready. AutoSuggestBox.IsEnabled = true; AutoSuggestBox.IsSuggestionListOpen = true; } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error").ShowAsync(); } }
protected override void OnDestroy() { base.OnDestroy(); // Restore API key if leaving sample. ApiKeyManager.EnableKey(); }
private async void Initialize() { if (await ApiKeyManager.CheckKeyValidity() != ApiKeyStatus.Valid) { await new MessageDialog2("Please use the settings dialog to configure an API Key.", "Error").ShowAsync(); return; } // Create new Map with basemap. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Provide used Map to the MapView. MyMapView.Map = myMap; // Add a graphics overlay to the map for showing where the user tapped. MyMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Enable tap-for-info pattern on results. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Initialize the LocatorTask with the provided service Uri. try { _geocoder = await LocatorTask.CreateAsync(_serviceUri); } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error configuring geocoder").ShowAsync(); } // Set the initial viewpoint. await MyMapView.SetViewpointCenterAsync(34.058, -117.195, 5e4); }
private void Initialize() { // Remove the API key. ApiKeyManager.DisableKey(); // Show a light gray canvas basemap by default. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); }
public void ApiKeyManagerRead() { var key = ApiKeyManager.FindBySecretKey("abc1234"); Assert.NotNull(key); Assert.Equal("dev-local", key.keyID); Assert.Equal("127.0.0.1", key.authorizedIP); }
/// <summary> /// Logout from Server /// </summary> public static void Logout() { // Remove apikey and authorizations to cut connection with server client.DefaultRequestHeaders.Remove("Authorization"); DownloadClient.DefaultRequestHeaders.Remove("Authorization"); client.DefaultRequestHeaders.Add("Authorization", "Basic " + encodedLogout); ApiKeyManager.DeleteApiKey(ApiKey.id); client.DefaultRequestHeaders.Remove("Authorization"); ApiKey = null; }
private void Initialize() { // Remove API key. ApiKeyManager.DisableKey(); // Create new Map with basemap Map myMap = new Map(Basemap.CreateLightGrayCanvas()); // Provide used Map to the MapView _myMapView.Map = myMap; }
private async Task SelectSample(SampleInfo selectedSample) { // The following code removes the API key when using the Create and save map sample. if (nameof(SampleManager.Current.SelectedSample) != nameof(selectedSample)) { // Remove API key if opening Create and save map sample. if (selectedSample.FormalName == "AuthorMap") { ApiKeyManager.DisableKey(); } // Restore API key if leaving Create and save map sample. else if (SampleManager.Current?.SelectedSample?.FormalName == "AuthorMap") { ApiKeyManager.EnableKey(); } } // Call a function to clear existing credentials ClearCredentials(); SampleManager.Current.SelectedSample = selectedSample; try { if (selectedSample.OfflineDataItems != null) { CancellationTokenSource cancellationSource = new CancellationTokenSource(); // Show the waiting page SamplePageContainer.Content = new WaitPage(cancellationSource); SamplePageContainer.Visibility = Visibility.Visible; SampleSelectionGrid.Visibility = Visibility.Collapsed; // Wait for offline data to complete await DataManager.EnsureSampleDataPresent(selectedSample, cancellationSource.Token); } // Show the sample SamplePageContainer.Content = new SamplePage(); SamplePageContainer.Visibility = Visibility.Visible; SampleSelectionGrid.Visibility = Visibility.Collapsed; } catch (Exception exception) { // Failed to create new instance of the sample. SamplePageContainer.Visibility = Visibility.Collapsed; SampleSelectionGrid.Visibility = Visibility.Visible; CategoriesTree.SelectionMode = muxc.TreeViewSelectionMode.None; await new MessageDialog2(exception.Message).ShowAsync(); CategoriesTree.SelectionMode = muxc.TreeViewSelectionMode.Single; } }
private async Task CheckApiKey() { // Attempt to load a locally stored API key. await ApiKeyManager.TrySetLocalKey(); // Check that the current API key is valid. ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity(); if (status != ApiKeyStatus.Valid) { NavigationController.PushViewController(new ApiKeyPrompt(), true); } }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); // Unsubscribe from events, per best practice. _newMapButton.Clicked -= NewMapClicked; _basemapButton.Clicked -= ShowBasemapClicked; _layersButton.Clicked -= ShowLayerListClicked; _saveButton.Clicked -= SaveMapClicked; // Restore API key if leaving Create and save map sample. ApiKeyManager.EnableKey(); }
private async Task CheckApiKey() { // Attempt to load a locally stored API key. await ApiKeyManager.TrySetLocalKey(); // Check that the current API key is valid. ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity(); if (status != ApiKeyStatus.Valid) { PromptForKey(); } }
private async Task UpdateValidityText() { ApiKeyStatus status = await ApiKeyManager.CheckKeyValidity(); if (status == ApiKeyStatus.Valid) { Status.Text = "API key is valid"; } else { Status.Text = "API key is invalid"; } CurrentKeyText.Text = Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey; }
public WelcomePageViewModel() { _navigationManager = NavigationManager.GetInstance(); _apiKeyManager = ApiKeyManager.GetInstance(); if (IsTenFootExperience) { LinkCodeWebsite = new Uri("https://www.giantbomb.com/app/" + EncodedAppNameForXboxVersion); } else { LinkCodeWebsite = new Uri("https://www.giantbomb.com/app/" + EncodedAppNameForPcVersion); } }
/// <summary> /// Login to Server /// </summary> /// <param name="username"></param> /// <param name="password"></param> public static void Login(string username, string password) { // Encoding to Base64 for server authorization var plainTextBytes = Encoding.UTF8.GetBytes(username + ":" + password); string encoded = Convert.ToBase64String(plainTextBytes); encodedLogout = encoded; // Add basic authorization client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded); client.BaseAddress = new Uri(baseUrl); ApiKey = ApiKeyManager.GetApiKey(); // Remove basic authorization client.DefaultRequestHeaders.Remove("Authorization"); // Use authorization with apikey instead of username and password initializeNetworkHandler(); }
private void DeleteKey(object sender, EventArgs e) { _currentKeyLabel.Text = ApiKeyManager.ArcGISDeveloperApiKey = null; ApiKeyManager.StoreCurrentKey(); _statusLabel.Text = "API key removed"; }
private async void OnItemTapped(object sender, ItemTappedEventArgs e) { // Call a function to clear existing credentials. ClearCredentials(); try { // Get the selected sample. SampleInfo item = (SampleInfo)e.Item; if (item.FormalName == "AuthorMap") { // Remove API key if opening Create and save map sample. ApiKeyManager.DisableKey(); } else { // Ensure API key is set in ArcGIS Runtime environment. ApiKeyManager.EnableKey(); } // Load offline data before showing the sample. if (item.OfflineDataItems != null) { CancellationTokenSource cancellationSource = new CancellationTokenSource(); // Show the wait page. await Navigation.PushModalAsync(new WaitPage(cancellationSource) { Title = item.SampleName }, false); #if WINDOWS_UWP // Workaround for bug with Xamarin Forms UWP. await Task.WhenAll( Task.Delay(100), DataManager.EnsureSampleDataPresent(item, cancellationSource.Token) ); #else // Wait for the sample data download. await DataManager.EnsureSampleDataPresent(item, cancellationSource.Token); #endif // Remove the waiting page. await Navigation.PopModalAsync(false); } // Get the sample control from the selected sample. ContentPage sampleControl = (ContentPage)SampleManager.Current.SampleToControl(item); // Create the sample display page to show the sample and the metadata. SamplePage page = new SamplePage(sampleControl, item); // Show the sample. await Navigation.PushAsync(page, true); } catch (OperationCanceledException) { // Remove the waiting page. await Navigation.PopModalAsync(false); await Application.Current.MainPage.DisplayAlert("", "Download cancelled", "OK"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception occurred on OnItemTapped. Exception = " + ex); } }
public async Task InitializeAsync() { _navigationManager = NavigationManager.GetInstance(); _apiKey = ApiKeyManager.GetInstance().GetSavedApiKey(); await LoadVideosAsync(true); }
private async Task SelectSample(SampleInfo selectedSample) { if (selectedSample == null) { return; } // The following code removes the API key when using the Create and save map sample. if (nameof(SampleManager.Current.SelectedSample) != nameof(selectedSample)) { // Remove API key if opening Create and save map sample. if (selectedSample.FormalName == "AuthorMap") { ApiKeyManager.DisableKey(); } // Restore API key if leaving Create and save map sample. else if (SampleManager.Current?.SelectedSample?.FormalName == "AuthorMap") { ApiKeyManager.EnableKey(); } } SampleTitleBlock.Text = selectedSample.SampleName; SampleManager.Current.SelectedSample = selectedSample; DescriptionContainer.SetSample(selectedSample); ShowSampleTab(); // Call a function to clear any existing credentials from AuthenticationManager ClearCredentials(); try { if (selectedSample.OfflineDataItems != null) { CancellationTokenSource cancellationSource = new CancellationTokenSource(); // Show waiting page SampleContainer.Content = new WPF.Viewer.WaitPage(cancellationSource); // Wait for offline data to complete await DataManager.EnsureSampleDataPresent(selectedSample, cancellationSource.Token); } // Show the sample SampleContainer.Content = SampleManager.Current.SampleToControl(selectedSample); SourceCodeContainer.LoadSourceCode(); } catch (OperationCanceledException) { CategoriesRegion.Visibility = Visibility.Visible; SampleContainer.Visibility = Visibility.Collapsed; return; } catch (Exception exception) { // failed to create new instance of the sample SampleContainer.Content = new WPF.Viewer.ErrorPage(exception); } CategoriesRegion.Visibility = Visibility.Collapsed; SampleContainer.Visibility = Visibility.Visible; }
private void Initialize() { CurrentKeyText.Text = Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ApiKey; ApiKeyManager.StoreCurrentKey(); _ = UpdateValidityText(); }