Esempio n. 1
0
        private void EditBookmark(BookmarkViewModel bookmarkViewModel)
        {
            var bookmarkClone =
                _tempApplicationData.Bookmarks.First(b => b.Name.Equals(bookmarkViewModel.BookmarkName)).Clone();
            var viewModelCopy = new BookmarkViewModel(bookmarkClone);

            _bookmarkWindow = new BookmarkSettingsWindow();

            //TODO: validate settings
            viewModelCopy.BrowseCommand = new RelayCommand <string>(s =>
            {
                var newPath = ShowVagrantFolderBrowser(_bookmarkWindow, s);
                if (!newPath.Equals(String.Empty))
                {
                    viewModelCopy.VagrantInstanceLocation = newPath;
                }
            });
            viewModelCopy.SaveCommand = new RelayCommand(() =>
            {
                bookmarkViewModel.BookmarkName            = viewModelCopy.BookmarkName;
                bookmarkViewModel.VagrantInstanceLocation = viewModelCopy.VagrantInstanceLocation;
                DestroyBookmarkWindow();
            });
            viewModelCopy.CancelCommand = new RelayCommand(DestroyBookmarkWindow);

            _bookmarkWindow.DataContext = viewModelCopy;

            _bookmarkWindow.Show();
            _bookmarkWindow.Activate();
        }
Esempio n. 2
0
        private void AddNewBookmark()
        {
            var path = ShowVagrantFolderBrowser(_settingsWindow);

            if (path.Equals(String.Empty))
            {
                return;
            }

            //See if we can reuse another vagrant instance, since multiple bookmarks might share the same vagrant instance.
            var matchingBookmark =
                _applicationData.Bookmarks.FirstOrDefault(b => b.VagrantInstance.Directory.Equals(path));

            var newBookmark = new Bookmark
            {
                VagrantInstance =
                    matchingBookmark != null
                        ? matchingBookmark.VagrantInstance
                        : new VagrantInstance {
                    Directory = path
                },
                Name = Directory.GetParent(path).Name
            };

            _bookmarkWindow = new BookmarkSettingsWindow();

            var bookmarkViewModel = new BookmarkViewModel(newBookmark)
            {
                SaveCommand = new RelayCommand(() =>
                {
                    _tempApplicationData.Bookmarks.Add(newBookmark);
                    DestroyBookmarkWindow();
                }),
                CancelCommand = new RelayCommand(DestroyBookmarkWindow)
            };

            _bookmarkWindow.DataContext = bookmarkViewModel;

            _bookmarkWindow.Show();
            _bookmarkWindow.Activate();
        }