private async void TraceTypeButtonPressed(object sender, EventArgs e) { try { // Prompt the user to select a type of trace. string choice = await((Page)Parent).DisplayActionSheet("Choose type of trace", "Cancel", null, Enum.GetNames(typeof(UtilityTraceType))); // Set the selected trace type. _selectedTraceType = (UtilityTraceType)Enum.Parse(typeof(UtilityTraceType), choice); TracePickerButton.Text = $"Trace type: {_selectedTraceType}"; } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private async void TraceTypeButtonPressed(object sender, EventArgs e) { try { // Prompt the user to select a type of trace. var traceTypes = new string[] { "Connected", "Subnetwork", "Upstream", "Downstream" }; string choice = await((Page)Parent).DisplayActionSheet("Choose type of trace", "Cancel", null, traceTypes); // Set the selected trace type. _selectedTraceType = (UtilityTraceType)Enum.Parse(typeof(UtilityTraceType), choice); TracePickerButton.Text = $"Trace type: {_selectedTraceType}"; } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void TraceTypeClick(UIAlertAction action) { _utilityTraceType = (UtilityTraceType)Enum.Parse(typeof(UtilityTraceType), action.Title); _tracePickerButton.SetTitle($"Trace type: {_utilityTraceType}", UIControlState.Normal); }
private async void OnTrace(object sender, RoutedEventArgs e) { try { // Get the selected trace type. UtilityTraceType traceType = (UtilityTraceType)TraceTypes.SelectedItem; // Update the UI. MainUI.IsEnabled = false; IsBusy.Visibility = Visibility.Visible; Status.Text = $"Running {traceType.ToString().ToLower()} trace..."; // Clear previous selection from the layers. MyMapView.Map.OperationalLayers.OfType <FeatureLayer>().ToList().ForEach(layer => layer.ClearSelection()); // Build trace parameters. UtilityTraceParameters parameters = new UtilityTraceParameters(traceType, _startingLocations); foreach (UtilityElement barrier in _barriers) { parameters.Barriers.Add(barrier); } // Set the trace configuration using the tier from the utility domain network. parameters.TraceConfiguration = _mediumVoltageTier.TraceConfiguration; // Get the trace result from the utility network. IEnumerable <UtilityTraceResult> traceResult = await _utilityNetwork.TraceAsync(parameters); UtilityElementTraceResult elementTraceResult = traceResult?.FirstOrDefault() as UtilityElementTraceResult; // Check if there are any elements in the result. if (elementTraceResult?.Elements?.Count > 0) { foreach (FeatureLayer layer in MyMapView.Map.OperationalLayers.OfType <FeatureLayer>()) { IEnumerable <UtilityElement> elements = elementTraceResult.Elements.Where(element => element.NetworkSource.Name == layer.FeatureTable.TableName); IEnumerable <Feature> features = await _utilityNetwork.GetFeaturesForElementsAsync(elements); layer.SelectFeatures(features); } } Status.Text = "Trace completed."; } catch (Exception ex) { Status.Text = "Trace failed..."; if (ex is ArcGISWebException && ex.Message == null) { MessageBox.Show("Trace failed.", ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } } finally { MainUI.IsEnabled = true; IsBusy.Visibility = Visibility.Hidden; } }
private void ChangeTraceType(object sender, DialogClickEventArgs e) { _utilityTraceType = (UtilityTraceType)Enum.GetValues(typeof(UtilityTraceType)).GetValue(e.Which); _traceTypeButton.Text = $"Trace type: {_utilityTraceType}"; }