protected CoordinateConversionDockpaneViewModel()
        {
            _coordinateConversionView   = new CoordinateConversionView();
            HasInputError               = false;
            IsHistoryUpdate             = true;
            IsToolGenerated             = false;
            AddNewOCCommand             = new CoordinateConversionLibrary.Helpers.RelayCommand(OnAddNewOCCommand);
            ActivatePointToolCommand    = new CoordinateConversionLibrary.Helpers.RelayCommand(OnMapToolCommand);
            FlashPointCommand           = new CoordinateConversionLibrary.Helpers.RelayCommand(OnFlashPointCommand);
            CopyAllCommand              = new CoordinateConversionLibrary.Helpers.RelayCommand(OnCopyAllCommand);
            EditPropertiesDialogCommand = new CoordinateConversionLibrary.Helpers.RelayCommand(OnEditPropertiesDialogCommand);
            Mediator.Register(CoordinateConversionLibrary.Constants.RequestCoordinateBroadcast, OnBCNeeded);
            InputCoordinateHistoryList = new ObservableCollection <string>();
            MapSelectionChangedEvent.Subscribe(OnSelectionChanged);

            var ctvm = CTView.Resources["CTViewModel"] as CoordinateConversionViewModel;

            if (ctvm != null)
            {
                ctvm.SetCoordinateGetter(proCoordGetter);
            }
            configObserver = new PropertyObserver <CoordinateConversionLibraryConfig>(CoordinateConversionViewModel.AddInConfig)
                             .RegisterHandler(n => n.DisplayCoordinateType, n => {
                if (proCoordGetter != null && proCoordGetter.Point != null)
                {
                    InputCoordinate = proCoordGetter.GetInputDisplayString();
                }
            });
        }
示例#2
0
 public NumSegmentsEditBox()
 {
     MapSelectionChangedEvent.Subscribe((MapSelectionChangedEventArgs args) =>
     {
         Text = Main.Current.SegmentsLayer.SelectionCount.ToString();
     });
 }
示例#3
0
 public AOI_Selected()
 {
     if (_eventToken == null)  //Subscribe to event when dockpane is visible
     {
         _eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
     }
 }
示例#4
0
        protected CoordinateConversionDockpaneViewModel()
        {
            ConvertTabView             = new CCConvertTabView();
            ConvertTabView.DataContext = new ProConvertTabViewModel();

            MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
        }
示例#5
0
        protected override Task OnToolActivateAsync(bool hasMapViewChanged)
        {
            _msg.VerboseDebug("OnToolActivateAsync");

            MapView.Active.Map.PropertyChanged += Map_PropertyChanged;

            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);

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

                    if (RequiresSelection)
                    {
                        ProcessSelection(SelectionUtils.GetSelectedFeatures(ActiveMapView));
                    }

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

            return(Task.CompletedTask);
        }
        protected override async Task InitializeAsync()
        {
            //Subscribe to MapSelectionChangedEvent
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
            //Subscribe to ActiveMapViewChangedEvent
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChangedEvent);
            await UpdateSymbolList();

            return;
        }
示例#7
0
        protected SceneCalcDockpaneViewModel()
        {
            _sketchPolygonCmd   = new RelayCommand(() => Module1.Current.RunPolygonTool(), () => true);
            _elevationToolCmd   = new RelayCommand(() => Module1.Current.RunElevationTool(), () => true);
            _calculateVolumeCmd = new RelayCommand(() => Module1.Current.CalculateVolume(), () => true);

            // Subscribe to the following events:
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
        }
 protected FeatureSelectionDockPaneViewModel()
 {
     System.Windows.Data.BindingOperations.EnableCollectionSynchronization(_layers, _lock);
     System.Windows.Data.BindingOperations.EnableCollectionSynchronization(_layerSelection, _lock);
     System.Windows.Data.BindingOperations.EnableCollectionSynchronization(_fieldAttributes, _lock);
     LayersAddedEvent.Subscribe(OnLayersAdded);
     LayersRemovedEvent.Subscribe(OnLayersRemoved);
     ActiveToolChangedEvent.Subscribe(OnActiveToolChanged);
     MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
     ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
     MapRemovedEvent.Subscribe(OnMapRemoved);
 }
        protected override void OnShow(bool isVisible)
        {
            if (isVisible && _eventToken == null) //Subscribe to event when dockpane is visible
            {
                _eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent);
            }

            if (!isVisible && _eventToken != null) //Unsubscribe as the dockpane closes.
            {
                MapSelectionChangedEvent.Unsubscribe(_eventToken);
                _eventToken = null;
            }
        }
        public override Task OpenAsync()
        {
            QueuedTask.Run(() =>
            {
                _okRelay = new RelayCommand(() => ConstructPoints(IsNumberOfPoints, Value), CanCreatePoints);
                NotifyPropertyChanged("OKCommand");

                if (_mscToken == null)
                {
                    _mscToken = MapSelectionChangedEvent.Subscribe(OnSelectionChangedAsync);
                }
                SetState(MapView.Active.Map.GetSelection());
            });
            return(Task.FromResult(true));
        }
        /// <summary>
        /// ドッキングウインドウの表示/非表示でイベントを登録/解除
        /// </summary>
        protected override void OnShow(bool isVisible)
        {
            if (isVisible && _mapSelectionChangedEvent == null)
            {
                // イベントの登録
                _mapSelectionChangedEvent = MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
            }

            if (!isVisible && _mapSelectionChangedEvent != null)
            {
                // イベントの解除
                MapSelectionChangedEvent.Unsubscribe(_mapSelectionChangedEvent);
                _mapSelectionChangedEvent = null;
            }
        }
        protected AttributeDockpaneViewModel()
        {
            // By default, WPF data bound collections must be modified on the thread where the bound WPF control was created.
            // This limitation becomes a problem when you want to fill the collection from a worker thread to produce a nice experience.
            // For example, a search result list should be gradually filled as more matches are found, without forcing the user to wait until the
            // whole search is complete.

            // To get around this limitation, WPF provides a static BindingOperations class that lets you establish an
            // association between a lock and a collection (e.g., ObservableCollection\<T>).
            // This association allows bound collections to be updated from threads outside the main GUI thread,
            // in a coordinated manner without generating the usual exception.

            // TODO: Step4: add synchronization for worker thread update
            BindingOperations.EnableCollectionSynchronization(_featureLayers, _lockFeaturelayers);

            // TODO: Step3: subscribe to events used to populate the dropdown list with feature layers
            //// subscribe to the map view changed event... that's when we update the list of feature layers
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
            // also when the pane is changing we will update the list of feature layers as well
            ActivePaneChangedEvent.Subscribe(OnActivePaneChanged);

            // TODO: Step5: fill the data grid with selected records - listen to the selection changed event
            //// subscribe to the selection changed event ... that's when we refresh our features
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);

            // TODO: Step2: hook ArcGIS Pro Button
            var toolWrapper = FrameworkApplication.GetPlugInWrapper(DAML.Tool.esri_mapping_selectByRectangleTool);
            var toolCmd     = toolWrapper as ICommand; // tool and command(Button) supports this

            if (toolCmd != null)
            {
                SelectionTool = new RelayCommand(func => toolCmd.Execute(null),
                                                 func => toolCmd.CanExecute(null));
            }
            var closeWrapper = FrameworkApplication.GetPlugInWrapper(DAML.Button.esri_core_exitApplicationButton);
            var closeCmd     = closeWrapper as ICommand; // tool and command(Button) supports this

            if (closeCmd != null)
            {
                CloseCommand = new RelayCommand(func => closeCmd.Execute(null),
                                                func => closeCmd.CanExecute(null));
            }

            // in case the active pane is already up before we could subscribe to the changed event
            OnActivePaneChanged(null);
        }
示例#13
0
        protected CoordinateToolDockpaneViewModel()
        {
            _coordinateToolView      = new CoordinateToolView();
            HasInputError            = false;
            AddNewOCCommand          = new CoordinateToolLibrary.Helpers.RelayCommand(OnAddNewOCCommand);
            ActivatePointToolCommand = new CoordinateToolLibrary.Helpers.RelayCommand(OnMapToolCommand);
            FlashPointCommand        = new CoordinateToolLibrary.Helpers.RelayCommand(OnFlashPointCommand);
            CopyAllCommand           = new CoordinateToolLibrary.Helpers.RelayCommand(OnCopyAllCommand);
            Mediator.Register(CoordinateToolLibrary.Constants.RequestCoordinateBroadcast, OnBCNeeded);
            InputCoordinateHistoryList = new ObservableCollection <string>();
            MapSelectionChangedEvent.Subscribe(OnSelectionChanged);

            var ctvm = CTView.Resources["CTViewModel"] as CoordinateToolViewModel;

            if (ctvm != null)
            {
                ctvm.SetCoordinateGetter(proCoordGetter);
            }
        }
        protected AttributeDockpaneViewModel()
        {
            // By default, WPF data bound collections must be modified on the thread where the bound WPF control was created.
            // This limitation becomes a problem when you want to fill the collection from a worker thread to produce a nice experience.
            // For example, a search result list should be gradually filled as more matches are found, without forcing the user to wait until the
            // whole search is complete.

            // To get around this limitation, WPF provides a static BindingOperations class that lets you establish an
            // association between a lock and a collection (e.g., ObservableCollection\<T>).
            // This association allows bound collections to be updated from threads outside the main GUI thread,
            // in a coordinated manner without generating the usual exception.

            _readOnlyFeatureLayers = new ReadOnlyObservableCollection <FeatureLayer>(_featureLayers);
            BindingOperations.EnableCollectionSynchronization(_readOnlyFeatureLayers, _lockCollections);

            // subscribe to the map view changed event... that's when we update the list of feature layers
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);

            // subscribe to the selection changed event ... that's when we refresh our features
            MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
        }
示例#15
0
文件: Main.cs 项目: agrc/TrailsAddin
        Main()
        {
            // get layer references
            SegmentsLayer             = GetLayer(TrailSegments);
            HeadsLayer                = GetLayer(Trailheads);
            TempSegmentsLayer         = GetLayer("Temporary Segments");
            USNGLayer                 = GetLayer("SGID10.INDICES.NationalGrid");
            RoutesStandaloneTable     = GetStandAloneTable(Routes);
            RouteToTrailSegmentsTable = GetStandAloneTable(RouteToTrailSegments);
            RouteToTrailheadsTable    = GetStandAloneTable(RouteToTrailheads);

            MapSelectionChangedEvent.Subscribe((MapSelectionChangedEventArgs args) =>
            {
                if (BuildOnSelect && args.Selection.Keys.Contains(SegmentsLayer as MapMember))
                {
                    AddSelectedToTemp();
                }

                if (args.Selection.Keys.Contains(RoutesStandaloneTable) && !BuildOnSelect)
                {
                    if (RoutesStandaloneTable.SelectionCount == 0)
                    {
                        SelectedRoute = null;
                        return;
                    }

                    if (RoutesStandaloneTable.SelectionCount > 1)
                    {
                        SelectedRoute = null;
                        return;
                    }

                    ShowRoute();
                }
                else
                {
                    SelectedRoute = null;
                }
            });
        }
        public async Task <bool> InitializeEventsAsync()
        {
            bool result = (Layer.ConnectionStatus == ConnectionStatus.Connected);

            if (result)
            {
                MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
                DrawCompleteEvent.Subscribe(OnDrawCompleted);

                await QueuedTask.Run(() =>
                {
                    var table   = Layer.GetTable();
                    _rowChanged = RowChangedEvent.Subscribe(OnRowChanged, table);
                    _rowDeleted = RowDeletedEvent.Subscribe(OnRowDeleted, table);
                    _rowCreated = RowCreatedEvent.Subscribe(OnRowCreated, table);
                });
            }

            await LoadMeasurementsAsync();

            return(result);
        }
示例#17
0
        public override async Task OpenAsync()
        {
            await base.OpenAsync();

            if (DesignMode)
            {
                return;
            }

            // Make sure tool is active (if not already).
            await FrameworkApplication.SetCurrentToolAsync("esri_sample_divideLinesTool");

            _okRelay = new RelayCommand(() => DivideLinesAsync(IsNumberOfParts, Value), CanDivideLines);
            NotifyPropertyChanged(() => OKCommand);

            MapSelectionChangedEvent.Subscribe(OnSelectionChanged);

            //Run on MCT
            _ = QueuedTask.Run(() =>
            {
                _polyLineFeatureSelected = CheckSelectionAsync(MapView.Active.Map.GetSelection());
            });
        }
 protected CreateResourceViewModel()
 {
     MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
     BindingOperations.EnableCollectionSynchronization(_resourceIdsCreated, _lockCollections);
 }
示例#19
0
 private Module1()
 {
     MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);
 }
示例#20
0
 protected WellAttributeEditorViewModel()
 {
     MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
 }
示例#21
0
 /// <summary>
 /// Override to implement custom initialization code for this dockpane
 /// </summary>
 /// <returns></returns>
 protected override Task InitializeAsync()
 {
     //Subscribe to the selection changed event.
     MapSelectionChangedEvent.Subscribe(FindLinkedFeatures);
     return(base.InitializeAsync());
 }
示例#22
0
        protected SetFromToViewModel()
        {
            //Subscribe to selection change in the map
            MapSelectionChangedEvent.Subscribe(OnSelectionChanged);

            //Relay Command executes set from/to measures function
            ApplyMeasures = new RelayCommand(() =>
            {
                //Get selected layer
                var map = MapView.Active.Map;
                FeatureLayer featurelayer = map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(l => l.ShapeType == ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolyline);

                QueuedTask.Run(() =>
                {
                    //Logic to check how many features are selected
                    if (featurelayer == null)
                    {
                        MessageBox.Show(string.Format("No Features Selected"));
                        return;
                    }
                    ;

                    var featCount = featurelayer.GetSelection().GetCount();
                    if (featCount > 1)
                    {
                        MessageBox.Show(string.Format("Please select a single feature."));
                        return;
                    }
                    ;

                    //Begin Edit operation
                    var editOp = new EditOperation
                    {
                        Name = "Set From To"
                    };

                    //Get selection and initiate cursor object
                    var cursor = featurelayer.GetSelection().Search();

                    while (cursor.MoveNext())
                    {
                        var feature      = cursor.Current as Feature;
                        var originalLine = feature.GetShape() as Polyline;

                        //This is the function that actually sets the measures and interpolates
                        Polyline outPolyline = GeometryEngine.Instance.SetAndInterpolateMsBetween(
                            originalLine,
                            Math.Round(Convert.ToDouble(_fromMeasure), 3),
                            Math.Round(Convert.ToDouble(_toMeasure), 3)
                            ) as Polyline;

                        //Use original polyline object and replace it with the new polyline object
                        editOp.Modify(featurelayer, feature.GetObjectID(), outPolyline);
                    }

                    //Execute edit operation and save the edits
                    editOp.Execute();
                    Project.Current.SaveEditsAsync();
                });
            });
        }