public AttachmentsTableSource(AttachmentsTableView controller, ArcGISFeature selectedFeature, IReadOnlyList <Attachment> attachments) { _attachments = attachments.Where(attachment => attachment.ContentType == "image/jpeg").ToList(); _selectedFeature = selectedFeature; _viewController = controller; }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Check if a feature is selected and the service geodatabase is not on the default version. if (_selectedFeature is ArcGISFeature && _serviceGeodatabase.VersionName != _serviceGeodatabase.DefaultVersionName) { try { // Load the feature. await _selectedFeature.LoadAsync(); // Update the feature geometry. _selectedFeature.Geometry = e.Location; // Update the table. await _selectedFeature.FeatureTable.UpdateFeatureAsync(_selectedFeature); // Update the service. await((ServiceFeatureTable)_selectedFeature.FeatureTable).ApplyEditsAsync(); ShowAlert("Moved feature " + _selectedFeature.Attributes["objectid"]); } catch (Exception ex) { ShowAlert(ex.Message, ex.GetType().Name); } } else { try { // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_featureLayer, e.Position, 2, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { return; } // Get the tapped feature. _selectedFeature = (ArcGISFeature)identifyResult.GeoElements.First(); // Select the feature. _featureLayer.SelectFeature(_selectedFeature); // Get the current value. string currentAttributeValue = _selectedFeature.Attributes[_attributeFieldName].ToString(); // Update the combobox selection without triggering the event. DamageBox.SelectionChanged -= DamageBox_SelectionChanged; DamageBox.SelectedValue = currentAttributeValue; DamageBox.SelectionChanged += DamageBox_SelectionChanged; // Update the UI for the selection. AttributePicker.Visibility = Visibility.Visible; DamageBox.IsEnabled = _serviceGeodatabase.VersionName != _serviceGeodatabase.DefaultVersionName; } catch (Exception ex) { ShowAlert(ex.Message, ex.GetType().Name); } } }
public AttachmentsTableView(ArcGISFeature feature) { _feature = feature; Title = $"Attachments for #{feature.Attributes["objectid"]}"; }
private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e) { try { // Clear any existing feature selection and results list _myFeatureLayer.ClearSelection(); MyResultsView.ItemsSource = null; // Identify the tapped feature IdentifyLayerResult results = await MyMapView.IdentifyLayerAsync(_myFeatureLayer, e.Position, 10, false); // Return if there are no results if (results.GeoElements.Count < 1) { return; } Status.Text = "Loading..."; // Get the first result ArcGISFeature myFeature = (ArcGISFeature)results.GeoElements.First(); // Select the feature _myFeatureLayer.SelectFeature(myFeature); // Get the feature table for the feature ArcGISFeatureTable myFeatureTable = (ArcGISFeatureTable)myFeature.FeatureTable; // Query related features IReadOnlyList <RelatedFeatureQueryResult> relatedFeaturesResult = await myFeatureTable.QueryRelatedFeaturesAsync(myFeature); // Create a list to hold the formatted results of the query List <String> queryResultsForUi = new List <string>(); // For each query result foreach (RelatedFeatureQueryResult result in relatedFeaturesResult) { // And then for each feature in the result foreach (Feature resultFeature in result) { // Get a reference to the feature's table ArcGISFeatureTable relatedTable = (ArcGISFeatureTable)resultFeature.FeatureTable; // Get the display field name - this is the name of the field that is intended for display string displayFieldName = relatedTable.LayerInfo.DisplayFieldName; // Get the name of the feature's table string tableName = relatedTable.TableName; // Get the display name for the feature string featureDisplayname = resultFeature.Attributes[displayFieldName].ToString(); // Create a formatted result string string formattedResult = $"{tableName} - {featureDisplayname}"; // Add the result to the list queryResultsForUi.Add(formattedResult); } } // Update the UI with the result list MyResultsView.ItemsSource = queryResultsForUi; Status.Text = "Tap a park (green) to see related features."; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
// Handle a new selected comment record in the table view. private async void CommentsListBox_SelectionChanged(object sender, SelectedItemChangedEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // Get the selected comment feature. If there is no selection, return. ArcGISFeature selectedComment = e.SelectedItem as ArcGISFeature; if (selectedComment == null) { return; } // Get the map image layer that contains the service request sublayer and the service request comments table. ArcGISMapImageLayer serviceRequestsMapImageLayer = (ArcGISMapImageLayer)MyMapView.Map.OperationalLayers[0]; // Get the (non-spatial) table that contains the service request comments. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Get the relationship that defines related service request features for features in the comments table (this is the first and only relationship). RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault(); // Create query parameters to get the related service request for features in the comments table. RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo) { ReturnGeometry = true }; try { // Query the comments table to get the related service request feature for the selected comment. IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams); // Get the first result. RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault(); // Get the first feature from the result. If it's null, warn the user and return. ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { await((Page)Parent).DisplayAlert("No Feature", "Related feature not found.", "OK"); return; } // Load the related service request feature (so its geometry is available). await serviceRequestFeature.LoadAsync(); // Get the service request geometry (point). MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint; // Create a cyan marker symbol to display the related feature. Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Cyan, 14); // Create a graphic using the service request point and marker symbol. Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol); // Add the graphic to the graphics overlay and zoom the map view to its extent. _selectedFeaturesOverlay.Graphics.Add(requestGraphic); await MyMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing feature selection and results list. _myFeatureLayer.ClearSelection(); _myDisplayList.Source = null; _myDisplayList.ReloadData(); // Identify the tapped feature. IdentifyLayerResult results = await _myMapView.IdentifyLayerAsync(_myFeatureLayer, e.Position, 10, false); // Return if there are no results. if (results.GeoElements.Count < 1) { return; } // Get the first result. ArcGISFeature myFeature = (ArcGISFeature)results.GeoElements.First(); // Select the feature. _myFeatureLayer.SelectFeature(myFeature); // Get the feature table for the feature. ArcGISFeatureTable myFeatureTable = (ArcGISFeatureTable)myFeature.FeatureTable; // Query related features. IReadOnlyList <RelatedFeatureQueryResult> relatedFeaturesResult = await myFeatureTable.QueryRelatedFeaturesAsync(myFeature); // Create a list to hold the formatted results of the query. List <string> queryResultsForUi = new List <string>(); // For each query result. foreach (RelatedFeatureQueryResult result in relatedFeaturesResult) { // And then for each feature in the result. foreach (Feature resultFeature in result) { // Get a reference to the feature's table. ArcGISFeatureTable relatedTable = (ArcGISFeatureTable)resultFeature.FeatureTable; // Get the display field name - this is the name of the field that is intended for display. string displayFieldName = relatedTable.LayerInfo.DisplayFieldName; // Get the name of the feature's table. string tableName = relatedTable.TableName; // Get the display name for the feature. string featureDisplayname = resultFeature.Attributes[displayFieldName].ToString(); // Create a formatted result string. string formattedResult = $"{tableName} - {featureDisplayname}"; // Add the result to the list. queryResultsForUi.Add(formattedResult); } } // Create the source for the display list. _layerListSource = new LayerListSource(queryResultsForUi); // Assign the source to the display view. _myDisplayList.Source = _layerListSource; // Force the table view to refresh its data. _myDisplayList.ReloadData(); }
private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing feature selection and results list _myFeatureLayer.ClearSelection(); _myDisplayList.Adapter = null; // Identify the tapped feature IdentifyLayerResult results = await _myMapView.IdentifyLayerAsync(_myFeatureLayer, e.Position, 10, false); // Return if there are no results if (results.GeoElements.Count < 1) { return; } // Get the first result ArcGISFeature myFeature = (ArcGISFeature)results.GeoElements.First(); // Select the feature _myFeatureLayer.SelectFeature(myFeature); // Get the feature table for the feature ArcGISFeatureTable myFeatureTable = (ArcGISFeatureTable)myFeature.FeatureTable; // Query related features IReadOnlyList <RelatedFeatureQueryResult> relatedFeaturesResult = await myFeatureTable.QueryRelatedFeaturesAsync(myFeature); // Create a list to hold the formatted results of the query List <String> queryResultsForUi = new List <string>(); // For each query result foreach (RelatedFeatureQueryResult result in relatedFeaturesResult) { // And then for each feature in the result foreach (Feature resultFeature in result) { // Get a reference to the feature's table ArcGISFeatureTable relatedTable = (ArcGISFeatureTable)resultFeature.FeatureTable; // Get the display field name - this is the name of the field that is intended for display string displayFieldName = relatedTable.LayerInfo.DisplayFieldName; // Get the name of the feature's table string tableName = relatedTable.TableName; // Get the display name for the feature string featureDisplayname = resultFeature.Attributes[displayFieldName].ToString(); // Create a formatted result string string formattedResult = String.Format("{0} - {1}", tableName, featureDisplayname); // Add the result to the list queryResultsForUi.Add(formattedResult); } } // Create an array adapter for the layer display ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, queryResultsForUi); // Apply the adapter to show the results in the UI _myDisplayList.Adapter = adapter; }
// When a comment is clicked, get the related feature (service request) and select it on the map. private async void CommentsListBox_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // Get the clicked record (ArcGISFeature) using the list position. If one is not found, return. ArcGISFeature selectedComment = _commentFeatures[e.Position] as ArcGISFeature; if (selectedComment == null) { return; } // Get the map image layer that contains the service request sublayer and the service request comments table. ArcGISMapImageLayer serviceRequestsMapImageLayer = _myMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer; // Get the (non-spatial) table that contains the service request comments. ServiceFeatureTable commentsTable = serviceRequestsMapImageLayer.Tables[0]; // Get the relationship that defines related service request features to features in the comments table (this is the first and only relationship). RelationshipInfo commentsRelationshipInfo = commentsTable.LayerInfo.RelationshipInfos.FirstOrDefault(); // Create query parameters to get the related service request for features in the comments table. RelatedQueryParameters relatedQueryParams = new RelatedQueryParameters(commentsRelationshipInfo) { ReturnGeometry = true }; // Query the comments table to get the related service request feature for the selected comment. IReadOnlyList <RelatedFeatureQueryResult> relatedRequestsResult = await commentsTable.QueryRelatedFeaturesAsync(selectedComment, relatedQueryParams); // Get the first result. RelatedFeatureQueryResult result = relatedRequestsResult.FirstOrDefault(); // Get the first feature from the result. If it's null, warn the user and return. ArcGISFeature serviceRequestFeature = result.FirstOrDefault() as ArcGISFeature; if (serviceRequestFeature == null) { // Report to the user that a related feature was not found, then return. AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); AlertDialog alert = alertBuilder.Create(); alert.SetMessage("Related feature not found."); alert.Show(); return; } // Load the related service request feature (so its geometry is available). await serviceRequestFeature.LoadAsync(); // Get the service request geometry (point). MapPoint serviceRequestPoint = serviceRequestFeature.Geometry as MapPoint; // Create a cyan marker symbol to display the related feature. Symbol selectedRequestSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Cyan, 14); // Create a graphic using the service request point and marker symbol. Graphic requestGraphic = new Graphic(serviceRequestPoint, selectedRequestSymbol); // Add the graphic to the graphics overlay and zoom the map view to its extent. _selectedFeaturesOverlay.Graphics.Add(requestGraphic); await _myMapView.SetViewpointCenterAsync(serviceRequestPoint, 150000); }
private async void OnGeoViewTapped(object sender, GeoViewInputEventArgs e) { try { IsBusy.Visibility = Visibility.Visible; Status.Text = "Identifying trace locations..."; // Identify the feature to be used. IEnumerable <IdentifyLayerResult> identifyResult = await MyMapView.IdentifyLayersAsync(e.Position, 10.0, false); ArcGISFeature feature = identifyResult?.FirstOrDefault()?.GeoElements?.FirstOrDefault() as ArcGISFeature; if (feature == null) { return; } // Create element from the identified feature. UtilityElement element = _utilityNetwork.CreateElement(feature); if (element.NetworkSource.SourceType == UtilityNetworkSourceType.Junction) { // Select terminal for junction feature. IEnumerable <UtilityTerminal> terminals = element.AssetType.TerminalConfiguration?.Terminals; if (terminals?.Count() > 1) { element.Terminal = await GetTerminalAsync(terminals); } Status.Text = $"Terminal: {element.Terminal?.Name ?? "default"}"; } else if (element.NetworkSource.SourceType == UtilityNetworkSourceType.Edge) { // Compute how far tapped location is along the edge feature. if (feature.Geometry is Polyline line) { line = GeometryEngine.RemoveZ(line) as Polyline; double fraction = GeometryEngine.FractionAlong(line, e.Location, -1); if (double.IsNaN(fraction)) { return; } element.FractionAlongEdge = fraction; Status.Text = $"Fraction along edge: {element.FractionAlongEdge}"; } } // Check whether starting location or barrier is added to update the right collection and symbology. Symbol symbol = null; if (IsAddingStartingLocations.IsChecked.Value == true) { _startingLocations.Add(element); symbol = _startingPointSymbol; } else { _barriers.Add(element); symbol = _barrierPointSymbol; } // Add a graphic for the new utility element. Graphic traceLocationGraphic = new Graphic(feature.Geometry as MapPoint ?? e.Location, symbol); MyMapView.GraphicsOverlays.FirstOrDefault()?.Graphics.Add(traceLocationGraphic); } catch (Exception ex) { Status.Text = "Identifying locations failed."; MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (Status.Text.Equals("Identifying trace locations...")) { Status.Text = "Could not identify location."; } IsBusy.Visibility = Visibility.Hidden; } }
// Constructor takes the service request comment feature that was selected. public ServiceRequestCommentSelectedEventArgs(ArcGISFeature selectedComment) { SelectedComment = selectedComment; }
private async void OnGeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { BusyIndicator.IsVisible = false; Status.Text = "Identifying trace locations..."; // Set whether the user is adding a starting point or a barrier. bool isAddingStart = !IsAddingStartingLocations.IsEnabled; // Identify the feature to be used. IEnumerable <IdentifyLayerResult> identifyResult = await MyMapView.IdentifyLayersAsync(e.Position, 10.0, false); // Check that a results from a layer were identified from the user input. if (!identifyResult.Any()) { return; } // Identify the selected feature. IdentifyLayerResult layerResult = identifyResult?.FirstOrDefault(); ArcGISFeature feature = layerResult?.GeoElements?.FirstOrDefault() as ArcGISFeature; // Check that a feature was identified from the layer. if (feature == null) { return; } // Create element with `terminal` for junction feature or with `fractionAlong` for edge feature. UtilityElement element = null; // Select default terminal or display possible terminals for the junction feature. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(feature.FeatureTable.TableName); // Check if the network source is a junction or an edge. if (networkSource.SourceType == UtilityNetworkSourceType.Junction) { // Get the UtilityAssetGroup from the feature. string assetGroupFieldName = ((ArcGISFeatureTable)feature.FeatureTable).SubtypeField ?? "ASSETGROUP"; int assetGroupCode = Convert.ToInt32(feature.Attributes[assetGroupFieldName]); UtilityAssetGroup assetGroup = networkSource?.AssetGroups?.FirstOrDefault(g => g.Code == assetGroupCode); // Get the UtilityAssetType from the feature. int assetTypeCode = Convert.ToInt32(feature.Attributes["ASSETTYPE"]); UtilityAssetType assetType = assetGroup?.AssetTypes?.FirstOrDefault(t => t.Code == assetTypeCode); // Get the list of terminals for the feature. IEnumerable <UtilityTerminal> terminals = assetType?.TerminalConfiguration?.Terminals; // If there is more than one terminal, prompt the user to select a terminal. if (terminals.Count() > 1) { // Ask the user to choose the terminal. UtilityTerminal terminal = await WaitForTerminal(terminals); // Create a UtilityElement with the terminal. element = _utilityNetwork.CreateElement(feature, terminal); Status.Text = $"Terminal: {terminal?.Name ?? "default"}"; } else { element = _utilityNetwork.CreateElement(feature, terminals.FirstOrDefault()); Status.Text = $"Terminal: {element.Terminal?.Name ?? "default"}"; } } else if (networkSource.SourceType == UtilityNetworkSourceType.Edge) { element = _utilityNetwork.CreateElement(feature); // Compute how far tapped location is along the edge feature. if (feature.Geometry is Polyline line) { line = GeometryEngine.RemoveZ(line) as Polyline; // Set how far the element is along the edge. element.FractionAlongEdge = GeometryEngine.FractionAlong(line, e.Location, -1); Status.Text = $"Fraction along edge: {element.FractionAlongEdge}"; } } // Check that the element can be added to the parameters. if (element == null) { return; } // Build the utility trace parameters. if (_parameters == null) { IEnumerable <UtilityElement> startingLocations = Enumerable.Empty <UtilityElement>(); _parameters = new UtilityTraceParameters(UtilityTraceType.Connected, startingLocations); } if (isAddingStart) { _parameters.StartingLocations.Add(element); } else { _parameters.Barriers.Add(element); } // Add a graphic for the new utility element. Graphic traceLocationGraphic = new Graphic(feature.Geometry as MapPoint ?? e.Location, isAddingStart ? _startingPointSymbol : _barrierPointSymbol); MyMapView.GraphicsOverlays.FirstOrDefault()?.Graphics.Add(traceLocationGraphic); } catch (Exception ex) { Status.Text = "Identifying locations failed..."; await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { if (Status.Text.Equals("Identifying trace locations...")) { Status.Text = "Could not identify location."; } BusyIndicator.IsVisible = false; } }
// When the selected row changes, raise the ServiceRequestCommentSelected event to return the selected feature. public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { _selectedCommentRecord = _comments[indexPath.Row]; ServiceRequestCommentSelected?.Invoke(this, new ServiceRequestCommentSelectedEventArgs(_selectedCommentRecord)); }
private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing feature selection and results list. _myFeatureLayer.ClearSelection(); MyResultsView.ItemsSource = null; try { // Identify the tapped feature. IdentifyLayerResult results = await MyMapView.IdentifyLayerAsync(_myFeatureLayer, e.Position, 10, false); // Return if there are no results. if (results.GeoElements.Count < 1) { return; } // Show the loading indicator (this can take a while). LoadingProgress.Visibility = Visibility.Visible; // Get the first result. ArcGISFeature myFeature = (ArcGISFeature)results.GeoElements.First(); // Select the feature. _myFeatureLayer.SelectFeature(myFeature); // Get the feature table for the feature. ArcGISFeatureTable myFeatureTable = (ArcGISFeatureTable)myFeature.FeatureTable; // Query related features. IReadOnlyList <RelatedFeatureQueryResult> relatedFeaturesResult = await myFeatureTable.QueryRelatedFeaturesAsync(myFeature); // Create a list to hold the formatted results of the query. List <string> queryResultsForUi = new List <string>(); // For each query result. foreach (RelatedFeatureQueryResult result in relatedFeaturesResult) { // And then for each feature in the result. foreach (Feature resultFeature in result) { // Get a reference to the feature's table. ArcGISFeatureTable relatedTable = (ArcGISFeatureTable)resultFeature.FeatureTable; // Get the display field name - this is the name of the field that is intended for display. string displayFieldName = relatedTable.LayerInfo.DisplayFieldName; // Get the name of the feature's table. string tableName = relatedTable.TableName; // Get the display name for the feature. string featureDisplayname = resultFeature.Attributes[displayFieldName].ToString(); // Create a formatted result string. string formattedResult = string.Format("{0} - {1}", tableName, featureDisplayname); // Add the result to the list. queryResultsForUi.Add(formattedResult); } } // Update the UI with the result list. MyResultsView.ItemsSource = queryResultsForUi; // Hide the loading indicator. LoadingProgress.Visibility = Visibility.Collapsed; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
public BinViewModel(ArcGISFeature feature) { Title = "View Bin"; New = false; Edit = false; ArcGISFeature = feature; Binstance = ArcGISFeature.MapToBin(); FeatureMapBinType(); //display contents information //SetYTY(); //if (Binstance.YTYDatas.Count > 0) //{ // YTYData = Binstance.YTYDatas[0]; //foreach (var year in dateRange) //{ // if (year == YTYData.CropYear) // { // CropYear = year; // break; // } //} //Crop = YTYData.Crop; //GrainHeight = YTYData.GrainHeight.ToString(); //GrainHopperHeight = YTYData.GrainHopperHeight.ToString(); //GrainConeHeight = YTYData.ConeHeight.ToString(); //MoisturePercent = YTYData.MoistureOfGrain.ToString(); //MoistureFactor = YTYData.MoistureFactor.ToString(); //TestWeight = YTYData.TestWeight.ToString(); //PackFactor = YTYData.PackFactor.ToString(); //DockagePercent = YTYData.DockagePercent.ToString(); //DockageFactor = YTYData.DockageFactor.ToString(); ////GrainVolume = YTYData.TotalVolume.ToString(); //switch (YTYData.ConversionFactor) //{ // case 0.4: // ConversionFactor = 0; // break; // case 0.8: // ConversionFactor = 1; // break; // default: // ConversionFactor = -1; // break; //} //ShellFactor = YTYData.ShellFactor.ToString(); //TotalDeductionVolume = YTYData.TotalDeductionVolume.ToString(); //ContentsNotes = YTYData.Notes; //} //dsiplay general information YearCollected = Binstance.YearCollected; CreatedBy = Binstance.CreatedBy; ModifiedBy = Binstance.ModifiedBy; Identifier = Binstance.Identifier; switch (Binstance.IsLeased) { case true: Owned = 0; break; case false: Owned = 1; break; default: Owned = -1; break; } switch (Binstance.HasDryingDevice) { case true: HasDryingDevice = 0; break; case false: HasDryingDevice = 1; break; default: HasDryingDevice = -1; break; } switch (Binstance.HasGrainHeightIndicator) { case true: HasGrainHeightIndicator = 0; break; case false: HasGrainHeightIndicator = 1; break; default: HasGrainHeightIndicator = -1; break; } switch (Binstance.LadderType) { case Ladder.None: LadderType = 0; break; case Ladder.Stairs: LadderType = 1; break; case Ladder.Ladder: LadderType = 2; break; } Notes = Binstance.Notes; //display capacity information Type t; switch (Binstance.BinType) { case BinTypeEnum.FlatStructure: BinType = 0; t = Binstance.GetType(); if (t.Equals(typeof(FlatBin))) { FlatBin fbin = (FlatBin)Binstance; CribWidth = fbin.CribWidth.ToString(); CribLength = fbin.CribLength.ToString(); } break; case BinTypeEnum.GravityWagon: BinType = 1; t = Binstance.GetType(); if (t.Equals(typeof(GravityBin))) { GravityBin gbin = (GravityBin)Binstance; RectangleHeight = gbin.RectangleHeight.ToString(); RectangleLength = gbin.RectangleLength.ToString(); RectangleWidth = gbin.RectangleWidth.ToString(); ChuteLength = gbin.ChuteLength.ToString(); HopperHeight = gbin.HopperHeight.ToString(); } break; case BinTypeEnum.PolygonStructure: BinType = 2; t = Binstance.GetType(); if (t.Equals(typeof(PolygonBin))) { PolygonBin pbin = (PolygonBin)Binstance; SideHeight = pbin.SideHeight.ToString(); SideWidth = pbin.SideWidth.ToString(); numberOfSides = pbin.NumberOfSides.ToString(); } break; case BinTypeEnum.RoundStorage: BinType = 3; t = Binstance.GetType(); if (t.Equals(typeof(RoundBin))) { RoundBin rbin = (RoundBin)Binstance; Radius = rbin.Radius.ToString(); RoofHeight = rbin.RoofHeight.ToString(); WallHeight = rbin.WallHeight.ToString(); RoundHopperHeight = rbin.HopperHeight.ToString(); } break; case BinTypeEnum.NotFound: BinType = -1; break; } }
/// <summary> /// Gets relationship information for the identified feature and creates the corresponding viewmodels /// </summary> internal async Task GetRelationshipInfoForFeature(ArcGISFeature feature) { // clear related records from previous searches DestinationRelationships.Clear(); OriginRelationships.Clear(); // get RelationshipInfos from the table var relationshipInfos = feature.FeatureTable.GetRelationshipInfos(); // query only the related tables which match the application rules // save destination and origin type relationships separately as origin relates features are editable in the app foreach (var relationshipInfo in relationshipInfos) { var parameters = new RelatedQueryParameters(relationshipInfo); // only one related table should return given the specific relationship info passed as parameter var relatedTable = feature.FeatureTable.GetRelatedFeatureTable(relationshipInfo); var relationships = await feature.FeatureTable.GetRelatedRecords(feature, relationshipInfo); if (relationshipInfo.IsValidDestinationRelationship()) { try { // this is a one to many relationship so it will never return more than one result var relatedFeatureQueryResult = relationships.Where(r => r.IsValidRelationship()).First(); var destinationRelationshipViewModel = new DestinationRelationshipViewModel(relationshipInfo, relatedTable, ConnectivityMode); await destinationRelationshipViewModel.InitializeAsync(relatedFeatureQueryResult); DestinationRelationships.Add(destinationRelationshipViewModel); } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged(null, Resources.GetString("QueryRelatedFeaturesError_Message"), true, ex.StackTrace); } } else if (relationshipInfo.IsValidOriginRelationship()) { try { foreach (var relatedFeatureQueryResult in relationships.Where(r => r.IsValidRelationship())) { var originRelationshipsCollection = new ObservableCollection <OriginRelationshipViewModel>(); foreach (var relatedFeature in relatedFeatureQueryResult) { var originRelatedFeature = new OriginRelationshipViewModel(relationshipInfo, ConnectivityMode); await originRelatedFeature.LoadViewModel(relatedFeature).ContinueWith(t => { originRelationshipsCollection.Add(originRelatedFeature); }); } //sort collection SortCollection(originRelationshipsCollection); OriginRelationships.Add(new OriginRelationship(relatedTable, relationshipInfo, originRelationshipsCollection)); } } catch (Exception ex) { UserPromptMessenger.Instance.RaiseMessageValueChanged(null, Resources.GetString("GetFeatureRelationshipError_Message"), true, ex.StackTrace); } } } }
private async void MapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Check if a feature is selected and the service geodatabase is not on the default version. if (_selectedFeature is ArcGISFeature && _serviceGeodatabase.VersionName != _serviceGeodatabase.DefaultVersionName) { try { // Load the feature. await _selectedFeature.LoadAsync(); // Update the feature geometry. _selectedFeature.Geometry = e.Location; // Update the table. await _selectedFeature.FeatureTable.UpdateFeatureAsync(_selectedFeature); // Update the service. await((ServiceFeatureTable)_selectedFeature.FeatureTable).ApplyEditsAsync(); ShowAlert("Moved feature " + _selectedFeature.Attributes["objectid"]); } catch (Exception ex) { ShowAlert(ex.Message, "Failed to edit feature"); } } else { try { // Clear the selection. _featureLayer.ClearSelection(); _selectedFeature = null; // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_featureLayer, e.Position, 2, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { SwitchView(_defaultView); return; } // Get the tapped feature. _selectedFeature = (ArcGISFeature)identifyResult.GeoElements.First(); // Select the feature. _featureLayer.SelectFeature(_selectedFeature); // Get the current value. string currentAttributeValue = _selectedFeature.Attributes[_attributeFieldName].ToString(); bool editable = _serviceGeodatabase.VersionName != _serviceGeodatabase.DefaultVersionName; _moveLabel.Visibility = editable ? ViewStates.Visible : ViewStates.Invisible; _damageSpinner.Enabled = editable; // Update the UI for the selection. SwitchView(_damageView); } catch (Exception ex) { ShowAlert(ex.Message, ex.GetType().Name); } } }