/// <summary>
        /// Backup function to load bookmarks from a cached mapx file in case the
        /// loaded project does not have any
        /// </summary>
        private static Task <IList <Bookmark> > LoadBookmarksFromMapxAsync()
        {
            return(QueuingTaskFactory.StartNew <IList <Bookmark> >(async() => {
                var assemblyPath = Assembly.GetExecutingAssembly().Location;
                var mapXPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(assemblyPath), "SamplesData", "World.mapx");

                var project = ProjectModule.CurrentProject;
                var types = new string[1] {
                    @"Map"
                };
                var paths = new string[1] {
                    mapXPath
                };
                Tuple <string[], string[]> importResult = await project.ImportProjectItemAsync(types, paths, CancelableProgressor.None);
                var mapPath = importResult.Item2[0];

                var map = await MappingModule.GetMapAsync(mapPath);
                var bookmarks = await map.QueryBookmarks();
                List <Bookmark> bookMarks = new List <Bookmark>();
                foreach (Bookmark bmk in bookmarks)
                {
                    bookMarks.Add(bmk);
                }
                return bookMarks;
            }));
        }
Exemple #2
0
        protected override void OnClick()
        {
            // get the first map item
            MapProjectItem item = ProjectModule.CurrentProject.GetMaps().FirstOrDefault();

            if (item == null)
            {
                return;
            }

            // fimd the map
            Map map = MappingModule.FindMap(item.Path);

            if (map == null)
            {
                return;
            }

            bool bAlreadyOpen = false;

            // see if its already open
            //IList<IMapPane> mapPanes = MappingModule.GetMapPanes(map);
            //if ((mapPanes != null) && (mapPanes.Count > 0))
            //    bAlreadyOpen = true;

            if (!bAlreadyOpen)
            {
                var mapPane = MappingModule.OpenMapView(item.Path, item.ViewingMode);
            }
        }
Exemple #3
0
        // STEP 3 - Add delete bookmark command

        /// <summary>
        /// method for deleting a bookmark
        /// </summary>
        private void DeleteBookmark()
        {
            if (SelectedBookmark == null)
            {
                return;
            }

            if (SelectedMap == null)
            {
                return;
            }

            // find the map
            Map map = MappingModule.FindMap(SelectedBookmark.MapPath);

            if (map == null)
            {
                return;
            }

            // remove the bookmark
            ArcGIS.Desktop.Framework.Threading.Tasks.QueuingTaskFactory.StartNew
                (async() =>
            {
                await map.RemoveBookmarkAsync(SelectedBookmark);
            });
        }
Exemple #4
0
        protected override async void OnClick()
        {
            Project       project = ProjectModule.CurrentProject;
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine("Unable to determine Bookmark count");
            MapProjectItem mapItem = project.GetMaps().FirstOrDefault(pi => pi.Name == Module1.MapSelected);

            if (mapItem != null)
            {
                var map = MappingModule.FindMap(mapItem.Path);
                if (map == null) //map has not been loaded yet
                {
                    return;
                }

                var bmks = await map.QueryBookmarksAsync(); //get the bookmarks for each map.

                if (bmks != null)
                {
                    sb.Clear();
                    sb.AppendLine(mapItem.Name + " map has " + bmks.Count + " bookmarks\n");
                }
            }

            System.Windows.MessageBox.Show(sb.ToString(), "Bookmark Count");
        }
Exemple #5
0
        /// <summary>
        /// The OnProjectCollectionChanged event handler is called each time there is a change
        /// in the projectItem collection (either adding or deleting a project item).
        /// </summary>
        /// <param name="projectItemEventArgs"></param>
        private void OnProjectCollectionChanged(ArcGISProjectItemsChangedEventArgs projectItemEventArgs)
        {
            try {
                System.Diagnostics.Debug.WriteLine("In ArcGISProjectItemsChangedEvents");
                if (projectItemEventArgs.ProjectItem is MapProjectItem) //it is a Map
                {
                    var mapProjectItem = projectItemEventArgs.ProjectItem as MapProjectItem;
                    switch (projectItemEventArgs.Action)
                    {
                    case System.Collections.Specialized.NotifyCollectionChangedAction.Add:     //New item has been added to project
                        System.Diagnostics.Debug.WriteLine(string.Format("New map {0} Path {1}", mapProjectItem.Name, mapProjectItem.Path));
                        Map map = MappingModule.FindMap(mapProjectItem.Path);
                        Add(new ComboBoxItem(map.Name));
                        break;

                    case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:            //item has been removed
                        var x = ItemCollection.FirstOrDefault(i => i.ToString() == mapProjectItem.Name); //find in the ComboBox that matches the Map being removed
                        if (x != null)
                        {
                            Remove(x);     //remove the item
                        }
                        break;

                    default:
                        System.Diagnostics.Debug.WriteLine(string.Format("Unknown action item: {0}", projectItemEventArgs.Action.ToString()));
                        break;
                    }
                }
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// Updates the combo box with all the maps in the current project.
        /// </summary>
        ///
        private void UpdateCombo()
        {
            MapContainer _mapContainer;

            // we are only interested in map project items therefore we specify the "Map" selection parameter
            _mapContainer = ProjectModule.CurrentProject.GetProjectItemContainer <MapContainer>("Map");

            if (_mapContainer != null)                                 //check if the MapContainer is null first
            {
                foreach (var projectItem in _mapContainer)             //iterate through the map container to get all the maps.
                {
                    Map map = MappingModule.FindMap(projectItem.Path); // Get the "Map"  from the MapProjectItem
                    if (map != null)
                    {
                        Add(new ComboBoxItem(map.Name));
                    }
                    else
                    {
                        Add(new ComboBoxItem(String.Empty));
                    }
                }
                var selectedItem = ItemCollection.FirstOrDefault();
                Enabled = true;           //enables the ComboBox

                if (selectedItem != null) //Setting the Selected item.
                {
                    SelectedItem = selectedItem;
                }
                else
                {
                    SelectedItem = null;
                }
            }
        }
Exemple #7
0
 public static void AssemblyInit(TestContext context)
 {
     IInitializingModule bytecode        = new BytecodeModule();
     IInitializingModule cacheBytecode   = new CacheBytecodeModule();
     IInitializingModule cacheDataChange = new CacheDataChangeModule();
     IInitializingModule mapping         = new MappingModule();
     IInitializingModule mergeBytecode   = new MergeBytecodeModule();
 }
Exemple #8
0
        public Startup(IConfiguration configuration)
        {
            Configuration    = configuration;
            _injectionModule = new InjectionModule();
            _mappingModule   = new MappingModule();

            Console.WriteLine("--- CONFIGURATION ---");
            Configuration.AsEnumerable().ToList().ForEach(i => Console.WriteLine("{0}", i));
            Console.WriteLine("--- CONFIGURATION ---");
        }
Exemple #9
0
        public static void Main(string[] args)
        {
            MappingModule mappingModule = new MappingModule();
            var url = "http://localhost:1212";

            var host = new NancyHost(new Uri("http://localhost:1212"));
            host.Start();
            Console.WriteLine ("Mapper API running at: " + url);
            Console.WriteLine ("Press the any key to abort");
            Console.ReadKey();
            host.Stop();
            Console.WriteLine ("Host aborted");
        }
Exemple #10
0
        /// <summary>
        /// utility function to open and activate a map given the map url.
        /// </summary>
        /// <param name="url">unique map identifier</param>
        internal static async void OpenAndActivateMap(string url)
        {
            // find the map; returns null if map has never been opened in the Pro session
            Map map = MappingModule.FindMap(url);

            // default viewing mode
            MapViewingMode mode         = MapViewingMode.Item2D;
            bool           bAlreadyOpen = false;

            // if returns null - it has never been opened
            if (map == null)
            {
                // find the map mode (2d / 3d from the project items)
                MapProjectItem mapPI = ProjectModule.CurrentProject.GetMaps().FirstOrDefault(m => m.Path == url);
                if (mapPI != null)
                {
                    mode = mapPI.ViewingMode;
                }
            }
            else
            {
                mode = map.ViewingMode;

                // see if its already open
                IList <IMapPane> mapPanes = MappingModule.GetMapPanes(map);
                if ((mapPanes != null) && (mapPanes.Count > 0))
                {
                    bAlreadyOpen = true;

                    // activate the first one
                    Pane pane = mapPanes[0] as Pane;
                    if (pane != FrameworkApplication.Panes.ActivePane)
                    {
                        pane.Activate();
                    }
                }
            }

            // open it with the correct mode
            if (!bAlreadyOpen)
            {
                var mapPane = MappingModule.OpenMapView(url, mode);
                await Utils.BlockUntil(() => mapPane.MapView != null && mapPane.MapView.ViewerID >= 0);
            }
        }
Exemple #11
0
        protected override async void OnClick()
        {
            // get the map container
            var container = ProjectModule.CurrentProject.GetProjectItemContainer <MapContainer>("Map");

            if (container == null)
            {
                return;
            }

            // get the first item
            MapProjectItem item = container.GetProjectItems().FirstOrDefault();

            if (item == null)
            {
                return;
            }

            // fimd the map
            Map map = MappingModule.FindMap(item.Path);

            if (map == null)
            {
                return;
            }

            // close if already open
            IList <IMapPane> mapPanes = MappingModule.GetMapPanes(map);

            if ((mapPanes != null) && (mapPanes.Count > 0))
            {
                for (int idx = mapPanes.Count - 1; idx >= 0; idx--)
                {
                    Pane pane = mapPanes[idx] as Pane;
                    pane.Close();
                }
            }

            // remove it from project
            await(ProjectModule.CurrentProject as IInternalGISProjectItem).RemoveProjectItemAsync("Map", item.Path);
        }
Exemple #12
0
        /// <summary>
        /// Gets all the bookmarks from a Map Porject item
        /// </summary>
        /// <param name="mpi"></param>
        /// <returns></returns>
        private static async Task <IList <Bookmark> > GetBookmarksAsync(MapProjectItem mpi)
        {
            Map map = null;

            //use the map path to get the actual map (related to the item)
            map = MappingModule.FindMap(mpi.Path);
            if (map == null)
            {
                return(null);
            }
            //get the bookmarks associated with the map
            var bookmarks = await map.QueryBookmarksAsync();

            if (bookmarks == null)
            {
                return(null);
            }
            else
            {
                return(bookmarks);
            }
        }
Exemple #13
0
 /// <summary>
 /// Loads all the bookmarks found in the project
 /// </summary>
 /// <param name="currentProject">Current project</param>
 /// <returns></returns>
 public static Task <IList <Bookmark> > LoadBookmarksAsync(this Project currentProject)
 {
     return(QueuingTaskFactory.StartNew <IList <Bookmark> >(async() => {
         var mc = currentProject.ProjectItemContainers.OfType <MapContainer>().FirstOrDefault();
         List <Bookmark> bookMarks = new List <Bookmark>();
         foreach (var mapItem in mc)
         {
             var map = await MappingModule.GetMapAsync(mapItem.Path);
             if (map != null)
             {
                 var bmks = await map.QueryBookmarksAsync();
                 if (null != bmks && bmks.Count() > 0)
                 {
                     foreach (var bmk in bmks)
                     {
                         bookMarks.Add(bmk);
                     }
                 }
             }
         }
         return bookMarks;
     }));
 }
Exemple #14
0
        protected override async void OnClick()
        {
            // find the first map item
            MapProjectItem item = ProjectModule.CurrentProject.GetMaps().FirstOrDefault();

            if (item == null)
            {
                return;
            }

            // alternate example - find the map item using Name
            //IEnumerable<MapProjectItem> maps = ProjectModule.CurrentProject.GetMaps();
            //item = ProjectModule.CurrentProject.GetMaps().FirstOrDefault(m => m.Name == "Layers");

            // fimd the map
            Map map = MappingModule.FindMap(item.Path);

            if (map == null)
            {
                return;
            }

            // close if already open
            IList <IMapPane> mapPanes = MappingModule.GetMapPanes(map);

            if ((mapPanes != null) && (mapPanes.Count > 0))
            {
                for (int idx = mapPanes.Count - 1; idx >= 0; idx--)
                {
                    Pane pane = mapPanes[idx] as Pane;
                    pane.Close();
                }
            }

            // remove it from project
            await(ProjectModule.CurrentProject as IInternalGISProjectItem).RemoveProjectItemAsync("Map", item.Path);
        }