Esempio n. 1
0
        public BookmarkUIPlugin()
        {
            viewModel   = new BookmarkRibbonGroupViewModel();
            Description = GisEditor.LanguageManager.GetStringResource("ManageBookmarksPluginDescreption");
            Index       = UIPluginOrder.BookmarkPlugin;
            SmallIcon   = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/bookmarks.png", UriKind.RelativeOrAbsolute));
            LargeIcon   = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/bookmarks.png", UriKind.RelativeOrAbsolute));

            bookmarkGroup             = new BookmarkRibbonGroup();
            bookmarkGroup.DataContext = viewModel;

            bookmarkEntry                = new RibbonEntry();
            bookmarkEntry.RibbonGroup    = bookmarkGroup;
            bookmarkEntry.RibbonTabName  = "HomeRibbonTabHeader";
            bookmarkEntry.RibbonTabIndex = RibbonTabOrder.Home;

            bookMarkDockWindow         = new DockWindow();
            bookMarkDockWindow.Content = new BookmarkListUserControl()
            {
                DataContext = viewModel
            };
            bookMarkDockWindow.Title       = "BookmarksPluginTitle";
            bookMarkDockWindow.Name        = "Bookmarks";
            bookMarkDockWindow.StartupMode = DockWindowStartupMode.Hide;
        }
Esempio n. 2
0
        public void RegisterMessenger(BookmarkRibbonGroupViewModel viewModel)
        {
            Messenger.Default.Register <string>(this, viewModel, msg =>
            {
                switch (msg)
                {
                case BookmarkRibbonGroupViewModel.AddBookmarkMessage:
                    if (!viewModel.Bookmarks.ContainsKey(GisEditor.ActiveMap.Name))
                    {
                        viewModel.Bookmarks.Add(GisEditor.ActiveMap.Name, new ObservableCollection <BookmarkViewModel>());
                    }

                    var displayBookmarks = viewModel.DisaplayBookmarks;
                    BookmarkNamePromptWindow bookmarkNameWindow = new BookmarkNamePromptWindow(null, viewModel.Bookmarks[GisEditor.ActiveMap.Name].Select(tmpBookmark => tmpBookmark.Name));
                    if (bookmarkNameWindow.ShowDialog().GetValueOrDefault())
                    {
                        BookmarkViewModel bookmark = new BookmarkViewModel();
                        bookmark.Name     = bookmarkNameWindow.BookmarkName;
                        bookmark.IsGlobal = bookmarkNameWindow.IsGlobal;
                        if (bookmark.IsGlobal)
                        {
                            bookmark.ImageUri = "/GisEditorPluginCore;component/Images/bookmark_global.png";
                        }
                        else
                        {
                            bookmark.ImageUri = "/GisEditorPluginCore;component/Images/bookmark project.png";
                        }
                        bookmark.Center = GisEditor.ActiveMap.CurrentExtent.GetCenterPoint();
                        bookmark.Scale  = GisEditor.ActiveMap.CurrentScale;
                        bookmark.InternalProj4Projection = GisEditor.ActiveMap.DisplayProjectionParameters;
                        displayBookmarks.Add(bookmark);
                        if (bookmark.IsGlobal)
                        {
                            viewModel.SaveGlobalBookmarks();
                        }
                        viewModel.SyncBookmarkMenuItems();
                    }
                    break;

                case BookmarkRibbonGroupViewModel.OpenBookmarkMessage:
                    var dockWindow = GisEditor.DockWindowManager.DockWindows.FirstOrDefault(d => d.Title.Equals("BookmarksPluginTitle", StringComparison.Ordinal));
                    if (dockWindow != null)
                    {
                        dockWindow.Show(DockWindowPosition.Right);
                    }
                    break;

                case BookmarkRibbonGroupViewModel.DeleteBookmarkMessage:
                    if (viewModel.DisaplayBookmarks != null && viewModel.DisaplayBookmarks.Contains(viewModel.SelectedBookmark))
                    {
                        viewModel.DisaplayBookmarks.Remove(viewModel.SelectedBookmark);
                        viewModel.SyncBookmarkMenuItems();
                    }
                    break;

                case BookmarkRibbonGroupViewModel.GotoBookmarkMessage:
                    if (viewModel.DisaplayBookmarks != null && viewModel.DisaplayBookmarks.Contains(viewModel.SelectedBookmark))
                    {
                        var targetCenter = viewModel.SelectedBookmark.Center;
                        if (!viewModel.SelectedBookmark.InternalProj4Projection.Equals(GisEditor.ActiveMap.DisplayProjectionParameters))
                        {
                            Proj4Projection projection = new Proj4Projection();
                            projection.InternalProjectionParametersString = viewModel.SelectedBookmark.InternalProj4Projection;
                            projection.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters;
                            projection.Open();
                            targetCenter = (PointShape)projection.ConvertToExternalProjection(targetCenter);
                            projection.Close();
                        }
                        GisEditor.ActiveMap.ZoomTo(targetCenter, viewModel.SelectedBookmark.Scale);
                    }
                    break;
                }
            });
        }
 private void BookmarkListUserControl_Loaded(object sender, RoutedEventArgs e)
 {
     viewModel = this.DataContext as BookmarkRibbonGroupViewModel;
     viewModel.SyncBookmarkMenuItems();
 }