Example #1
0
        /// <summary>
        /// Override to implement custom initialization code for this dockpane
        /// </summary>
        /// <returns></returns>
        protected override Task InitializeAsync()
        {
            // TODO Step 2 - make sure that AllMaps can be updated from work threads as well as the UI thread
            BindingOperations.EnableCollectionSynchronization(_allMaps, _lockMapCollection);
            // TODO Step 2 - subscribe to the ProjectItemsChangedEvent
            ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged, false);

            return(base.InitializeAsync());
        }
Example #2
0
        protected override Task InitializeAsync()
        {
            ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged);
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChangedEvent);

            LayersAddedEvent.Subscribe(OnLayersAddedEvent);
            LayersRemovedEvent.Subscribe(OnLayersRemovedEvent);

            return(base.InitializeAsync());
        }
 protected JoinsDockpaneViewModel()
 {
     BindingOperations.EnableCollectionSynchronization(_leftGdbProjectItems, _lockCollection);
     BindingOperations.EnableCollectionSynchronization(_leftTables, _lockCollection);
     BindingOperations.EnableCollectionSynchronization(_leftFields, _lockCollection);
     BindingOperations.EnableCollectionSynchronization(_rightGdbProjectItems, _lockCollection);
     BindingOperations.EnableCollectionSynchronization(_rightTables, _lockCollection);
     BindingOperations.EnableCollectionSynchronization(_rightFields, _lockCollection);
     ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged, false);
     RefreshDatabaseItems();
 }
Example #4
0
        protected override bool OnRename(string newName)
        {
            Assert.ArgumentNotNullOrEmpty(newName, nameof(newName));

            var result = false;

            ViewUtils.Try(() =>
            {
                if (string.IsNullOrWhiteSpace(System.IO.Path.GetFileNameWithoutExtension(newName)))
                {
                    result = false;
                }
                else
                {
                    string extension = System.IO.Path.GetExtension(newName);

                    if (string.IsNullOrEmpty(extension))
                    {
                        extension = System.IO.Path.GetExtension(Path);
                        newName   = System.IO.Path.ChangeExtension(newName, extension);
                        Assert.NotNullOrEmpty(newName);
                    }

                    string directoryName = System.IO.Path.GetDirectoryName(Path);
                    Assert.NotNullOrEmpty(directoryName);

                    string fullName = System.IO.Path.Combine(directoryName, newName);
                    File.Move(Path, fullName);

                    // todo daro is it necessary to update Path?
                    Path = fullName;
                    // don't forget to update WorklistName

                    result = base.OnRename(newName);

                    // todo daro inline
                    var eventArgs =
                        new ProjectItemsChangedEventArgs(NotifyCollectionChangedAction.Replace,
                                                         new List <Item> {
                        this
                    }, false);

                    ProjectItemsChangedEvent.Publish(eventArgs);

                    // necessary?
                    NotifyPropertyChanged();
                }
            }, _msg);

            return(result);
        }
Example #5
0
        private void UnwireEvents()
        {
            //MapViewInitializedEvent.Unsubscribe(OnMapViewInitialized);
            LayersRemovingEvent.Unsubscribe(OnLayerRemovingAsync);
            DrawCompleteEvent.Unsubscribe(OnDrawCompleted);

            ProjectOpenedAsyncEvent.Unsubscribe(OnProjectOpendedAsync);
            ProjectSavingEvent.Unsubscribe(OnProjectSavingAsync);

            ProjectItemsChangedEvent.Unsubscribe(OnProjectItemsChanged);
            ProjectItemRemovingEvent.Unsubscribe(OnProjectItemRemoving);

            MapMemberPropertiesChangedEvent.Unsubscribe(OnMapMemberPropertiesChanged);
        }
        /// <summary>
        /// constructor.
        /// </summary>
        protected BookmarkViewModel()
        {
            // set up the command to retrieve the maps
            _retrieveMapsCommand = new RelayCommand(() => RetrieveMaps(), () => true);

            _delBookmarkCommand = new RelayCommand(() => DeleteBookmark(), () => true);

            _readOnlyBookmarks = new ReadOnlyObservableCollection <Bookmark>(_bookmarks);
            _readOnlyMaps      = new ReadOnlyObservableCollection <Map>(_maps);

            Utils.RunOnUiThread(() =>
            {
                BindingOperations.EnableCollectionSynchronization(_readOnlyMaps, _lockCollection);
                BindingOperations.EnableCollectionSynchronization(_readOnlyBookmarks, _lockCollection);
            });
            ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged, false);
        }
Example #7
0
 protected SymbolsViewModel()
 {
     SearchPauseSearching = true;
     #region Events
     //Subscribe to ProjectItemsChangedEvent to update ProjecyStyles
     ProjectItemsChangedEvent.Subscribe(OnProjectItemsChanged);
     ProjectClosedEvent.Subscribe(OnProjectClosed);
     //Subscribe to ActiveMapViewChangedEvent in order to get the layers in the map
     ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
     LayersAddedEvent.Subscribe(OnLayersAdded);
     LayersRemovedEvent.Subscribe(OnLayersemoved);
     //Subscribe to Graphic Elements selection changed event
     ElementSelectionChangedEvent.Subscribe(OnGraphicsElementSelectionChanged);
     #endregion
     BindingOperations.EnableCollectionSynchronization(_layersInMap, _layersInMapLock);
     _           = GetLayersInMapAsync();
     _patchTypes = new Dictionary <StyleItemType, SymbolPatchType>
     {
         { StyleItemType.LineSymbol, SymbolPatchType.ZigzagLine },
         { StyleItemType.PolygonSymbol, SymbolPatchType.BoundaryPoly }
     };
     //Get the Styles in the project
     ProjectFilterStyles.Add(new SymbolSearcherSearchFilter(true));
     ProjectFilterStyles.Add(new SymbolSearcherSearchFilter());
     foreach (var pi in Project.Current.GetItems <StyleProjectItem>())
     {
         ProjectFilterStyles.Add(new SymbolSearcherSearchFilter(false, pi));
     }
     if (SelectedProjectFilterStyle == null && ProjectFilterStyles.Count > 0)
     {
         SelectedProjectFilterStyle = ProjectFilterStyles[0];
     }
     //Get the various StyleItemTypes in Pro.
     foreach (StyleItemType sit in Enum.GetValues(typeof(StyleItemType)))
     {
         if (sit == 0)
         {
             continue;
         }
         StyleItemTypeValues.Add(sit);
     }
     SelectedStyleItemType = StyleItemTypeValues.FirstOrDefault();
     SearchPauseSearching  = false;
 }
Example #8
0
        //public void RemoveWorkListLayer(IWorkList workList)
        //{
        //	if (_layersByWorklistName.ContainsKey(workList.Name))
        //	{

        //	}
        //	if (_layerByWorkList.ContainsKey(workList))
        //	{
        //		_layerByWorkList.Remove(workList);
        //		Layer layer = MapView.Active.Map.GetLayersAsFlattenedList()
        //							 .First(l => l.Name == workList.Name);
        //		QueuedTask.Run(() => MapView.Active.Map.RemoveLayer(layer));
        //	}
        //}

        #region Events

        private void WireEvents()
        {
            // creating a project
            // 1. OnProjectOpened
            // 2. OnWriteSettings
            // 3. OnMapViewInitialized
            // 4. OnDrawCompleted

            //MapViewInitializedEvent.Subscribe(OnMapViewInitialized);
            LayersRemovingEvent.Subscribe(OnLayerRemovingAsync);
            DrawCompleteEvent.Subscribe(OnDrawCompleted);

            ProjectOpenedAsyncEvent.Subscribe(OnProjectOpendedAsync);
            ProjectSavingEvent.Subscribe(OnProjectSavingAsync);

            ProjectItemsChangedEvent.Subscribe(OnProjectItemsChanged);
            ProjectItemRemovingEvent.Subscribe(OnProjectItemRemoving);

            MapMemberPropertiesChangedEvent.Subscribe(OnMapMemberPropertiesChanged);
        }
        protected SymbolSearcherDockpaneViewModel()
        {
            System.Diagnostics.Debug.WriteLine($@"==== SymbolPicker constructor start");
            //Subscribe to ProjectItemsChangedEvent to update ProjecyStyles
            ProjectItemsChangedEvent.Subscribe(OnProjectItemsChanged);
            ProjectClosedEvent.Subscribe(OnProjectClosed);
            //Subscribe to ActiveMapViewChangedEvent in order to get the layers in the map
            ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged);
            _           = GetLayersInMapAsync();
            _patchTypes = new Dictionary <StyleItemType, SymbolPatchType>
            {
                { StyleItemType.LineSymbol, SymbolPatchType.ZigzagLine },
                { StyleItemType.PolygonSymbol, SymbolPatchType.BoundaryPoly }
            };
            BindingOperations.EnableCollectionSynchronization(_filterStyleItems, _StyleProjectItemsLock);
            BindingOperations.EnableCollectionSynchronization(_layersInMap, _layersInMapLock);

            // if current project is null the OnProjectItemsChanged event will take care of FilterStyles
            if (Project.Current != null)
            {
                // setting up the search filter StyleItem list for the combo happens in OnProjectItemsChanged unless the project is already open
                FilterStyles.Add(new SymbolSearcherSearchFilter(true));
                FilterStyles.Add(new SymbolSearcherSearchFilter());
                foreach (var pi in Project.Current.GetItems <StyleProjectItem>())
                {
                    FilterStyles.Add(new SymbolSearcherSearchFilter(false, pi));
                }
                if (SelectedFilterStyle == null && FilterStyles.Count > 0)
                {
                    // select the default search type
                    SelectedFilterStyle = FilterStyles[1];
                }
                SearchPauseSearching = false;
                System.Diagnostics.Debug.WriteLine($@"==== SearchPauseSearching false");
            }
            System.Diagnostics.Debug.WriteLine($@"==== SymbolPicker constructor end");

            // set the start value to line type
            SelectedSearchType = SearchTypes[3];
        }
Example #10
0
        /// <summary>
        /// constructor.
        /// </summary>
        protected BookmarkViewModel()
        {
            // set up the command to retrieve the maps
            _retrieveMapsCommand = new RelayCommand(() => RetrieveMaps(), () => true);

            _delBookmarkCommand = new RelayCommand(() => DeleteBookmark(), () => true);

            _readOnlyBookmarks = new ReadOnlyObservableCollection <Bookmark>(_bookmarks);
            _readOnlyMaps      = new ReadOnlyObservableCollection <Map>(_maps);

            Utils.RunOnUiThread(() =>
            {
                BindingOperations.EnableCollectionSynchronization(_readOnlyMaps, _lockCollection);
                BindingOperations.EnableCollectionSynchronization(_readOnlyBookmarks, _lockCollection);
            });
            ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged, false);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            CheckBookmarks(_selectedMap);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            IsShowCircularAnimation = Visibility.Collapsed;
            IsNoBookmarkExists      = Visibility.Collapsed;
        }
 /// <summary>
 /// Override to implement custom initialization code for this dockpane
 /// </summary>
 /// <returns></returns>
 protected override Task InitializeAsync()
 {
     ProjectItemsChangedEvent.Subscribe(OnProjectCollectionChanged, false);
     return(base.InitializeAsync());
 }