Пример #1
0
        protected override Task OnToolActivateAsync(bool hasMapViewChanged)
        {
            _msg.VerboseDebug("OnToolActivateAsync");

            MapPropertyChangedEvent.Subscribe(OnPropertyChanged);
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
            EditCompletedEvent.Subscribe(OnEditCompleted);

            PressedKeys.Clear();

            try
            {
                return(QueuedTask.Run(
                           () =>
                {
                    OnToolActivatingCore();

                    if (RequiresSelection)
                    {
                        ProcessSelection(ActiveMapView);
                    }

                    return OnToolActivatedCore(hasMapViewChanged);
                }));
            }
            catch (Exception e)
            {
                HandleError($"Error in tool activation ({Caption}): {e.Message}", e);
            }

            return(Task.CompletedTask);
        }
        protected override bool Initialize()
        {
            // subscribe to the completed edit operation event
            EditCompletedEvent.Subscribe(ReportNumberOfRowsChanged);

            return(true);
        }
        private void onProjectOpened(ProjectEventArgs obj)
        {
            //subscribe to edit completed event
            //this is across all maps and layers in the project
            EditCompletedEvent.Subscribe(onEditCompleted);

            //subscribe to row events for a certain layer in a certain map
            //look for a map named 'Layers' in the project
            var mapProjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name == "Layers");

            if (mapProjItem == null)
            {
                return;
            }

            //run on MCT
            QueuedTask.Run(() =>
            {
                var theMap = mapProjItem.GetMap();

                //look for a layer named 'Parcels' in the map
                var featLayer = theMap.FindLayers("Parcels").FirstOrDefault() as FeatureLayer;
                if (featLayer == null)
                {
                    return;
                }
                var layerTable = featLayer.GetTable();

                //setup row events
                _rowCreateToken  = RowCreatedEvent.Subscribe(onRowCreateEvent, layerTable);
                _rowDeleteToken  = RowDeletedEvent.Subscribe(onRowDeleteEvent, layerTable);
                _rowChangedToken = RowChangedEvent.Subscribe(onRowChangedEvent, layerTable);
            });
        }
 private void AddEvents()
 {
     LayersAddedEvent.Subscribe(OnLayersAdded);
     LayersMovedEvent.Subscribe(OnLayersMoved);
     LayersRemovedEvent.Subscribe(OnLayersRemoved);
     MapMemberPropertiesChangedEvent.Subscribe(OnMapMemberPropertiesChanged);
     TOCSelectionChangedEvent.Subscribe(OnTocSelectionChanged);
     DrawStartedEvent.Subscribe(OnDrawStarted);
     DrawCompleteEvent.Subscribe(OnDrawCompleted);
     ActiveToolChangedEvent.Subscribe(OnActiveToolChangedEvent);
     EditCompletedEvent.Subscribe(OnEditCompleted);
 }
Пример #5
0
        protected void SetupEvents()
        {
            QueuedTask.Run(() =>
            {
                var featLayer  = MapView.Active.GetSelectedLayers().First() as FeatureLayer;
                var layerTable = featLayer.GetTable();

                //subscribe to row events for a layer
                var rowCreateToken = RowCreatedEvent.Subscribe(onRowEvent, layerTable);
                var rowChangeToken = RowChangedEvent.Subscribe(onRowEvent, layerTable);
                var rowDeleteToken = RowDeletedEvent.Subscribe(onRowEvent, layerTable);
            });

            //subscribe to editevents
            var editComplete = EditCompletedEvent.Subscribe(onEditComplete);
        }
        private bool Register()
        {
            var layers = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>();

            QueuedTask.Run(() => {
                foreach (var fl in layers)
                {
                    var fc     = fl.GetFeatureClass();
                    var tokens = new List <SubscriptionToken>();
                    //These events are fired once ~per feature~,
                    //per table
                    tokens.Add(RowCreatedEvent.Subscribe((rc) => RowEventHandler(rc), fc));
                    tokens.Add(RowChangedEvent.Subscribe((rc) => RowEventHandler(rc), fc));
                    tokens.Add(RowDeletedEvent.Subscribe((rc) => RowEventHandler(rc), fc));
                    _rowevents[fl.Name] = tokens;
                }

                //This event is fired once per edit execute
                //Note: This event won't fire if the edits were cancelled
                _editevents.Add(EditCompletingEvent.Subscribe((ec) =>
                {
                    RecordEvent("EditCompletingEvent", "");
                    //can also cancel edit in the completing event...
                    //cancels everything (that is cancealable)
                    //
                    //you'll need to modify the RowEventHandler() to prevent if
                    //from doing the cancel or this will never get called
                    if (_cancelEdit)
                    {
                        ec.CancelEdit($"EditCompletingEvent, edit cancelled");
                        AddEntry("*** edits cancelled");
                        AddEntry("---------------------------------");
                    }
                }));
                //This event is fired after all the edits are completed (and on
                //save, discard, undo, redo) and is fired once
                _editevents.Add(EditCompletedEvent.Subscribe((ec) => {
                    HandleEditCompletedEvent(ec);
                    return(Task.FromResult(0));
                }));
            });
            return(true);
        }
Пример #7
0
 protected void subEditEvents()
 {
     //subscribe to editcompleted
     var eceToken = EditCompletedEvent.Subscribe(onEce);
 }
Пример #8
0
 private void WireEvents()
 {
     _eventToken = EditCompletedEvent.Subscribe(OnEditCompleted);
 }
 protected override void OnClick()
 {
     EditCompletedEvent.Subscribe(OnEditCompleted);
     Dockpane1ViewModel.Show();
 }