/// <summary>
        /// Flash the selected features
        /// </summary>
        /// <param name="flashFeatures"></param>
        private async void FlashFeaturesAsync(IReadOnlyDictionary <BasicFeatureLayer, List <long> > flashFeatures)
        {
            //Get the active map view.
            var mapView = MapView.Active;

            if (mapView == null)
            {
                return;
            }
            var selectionDictionary = new Dictionary <MapMember, List <long> >();

            foreach (var item in flashFeatures)
            {
                selectionDictionary.Add(item.Key, item.Value);
            }
            await QueuedTask.Run(() =>
            {
                //Flash the collection of features.
                mapView.FlashFeature(SelectionSet.FromDictionary(selectionDictionary));
            });
        }
Exemple #2
0
        private async Task <string> CopyParcelsToLotAsync(CancelableProgressorSource cps)
        {
            var error = await QueuedTask.Run <string>(() =>
            {
                // copy tax parcels to lot
                try
                {
                    if (_parcelFabricLayer == null)
                    {
                        return("There is no parcel fabric in the map.");
                    }
                    var theActiveRecord = _parcelFabricLayer.GetActiveRecord();
                    if (theActiveRecord == null)
                    {
                        return("There is no Active Record for the Parcel Fabric");
                    }
                }
                catch (Exception ex)
                {
                    return($@"Error [Exception]: {ex.Message}");
                }
                try
                {
                    // use CopyParcelLinesToParcelType to copy the tax parcels to the lot parcel type
                    var editOper = new EditOperation()
                    {
                        Name            = "Copy Lines To Lot Parcel Type",
                        ProgressMessage = "Copy Lines To Lot Parcel Type ...",
                        ShowModalMessageAfterFailure = false,
                        SelectNewFeatures            = false,
                        SelectModifiedFeatures       = false
                    };
                    var qry = $@"{FieldNameZone} = {_selectedZone} and {FieldNameSect} = {_selectedSection} and {FieldNamePlat} = '{_selectedPlat}'";
                    SelectSetAndZoomAsync(_taxLayerPolys, qry);
                    var ids = new List <long>(_taxLayerPolys.GetSelection().GetObjectIDs());
                    if (ids.Count == 0)
                    {
                        return("No selected parcels found. Please select parcels and try again.");
                    }
                    //add the standard feature line layers source, and their feature ids to a new KeyValuePair
                    //var kvp = new KeyValuePair<MapMember, List<long>>(_taxLayerPolys, ids);
                    //var sourceParcelFeatures = new List<KeyValuePair<MapMember, List<long>>> { kvp };

                    var selectionDictionary = new Dictionary <MapMember, List <long> >();
                    selectionDictionary.Add(_taxLayerPolys, ids);

                    editOper.CopyParcelLinesToParcelType(_parcelFabricLayer, SelectionSet.FromDictionary(selectionDictionary), _lotLayerLines, _lotLayerPolys, false, true, true);
                    if (!editOper.Execute())
                    {
                        return(editOper.ErrorMessage);
                    }
                }
                catch (Exception ex)
                {
                    return($@"Error [Exception]: {ex.Message}");
                }
                try
                {
                    // Build all Parcels for the Active record in the parcel fabric (set in step one)
                    var theActiveRecord = _parcelFabricLayer.GetActiveRecord();
                    var guid            = theActiveRecord.Guid;
                    var editOper        = new EditOperation()
                    {
                        Name            = "Build Parcels",
                        ProgressMessage = "Build Parcels...",
                        ShowModalMessageAfterFailure = true,
                        SelectNewFeatures            = true,
                        SelectModifiedFeatures       = true
                    };
                    cps.Progressor.Value += 1;
                    if (cps.Progressor.CancellationToken.IsCancellationRequested)
                    {
                        editOper.Abort();
                        return("Canceled");
                    }
                    cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                    cps.Progressor.Message = editOper.ProgressMessage;
                    editOper.BuildParcelsByRecord(_parcelFabricLayer, guid);
                    if (!editOper.Execute())
                    {
                        return($@"Error [{editOper.Name}]: {editOper.ErrorMessage}");
                    }
                }
                catch (Exception ex)
                {
                    return($@"Error [Exception]: {ex.Message}");
                }
                return(string.Empty);
            }, cps.Progressor);

            return(error);
        }