private async void EditBookmark(object sender, EventArgs e) { if (lsvBookmarks.SelectedItems.Count != 0) { var item = lsvBookmarks.SelectedItems[0]; if (item != null && item.Tag != null) { using (var edit = new EditBookmark()) { edit.BeginTime = item.SubItems[1].Text; edit.EndTime = item.SubItems[2].Text; edit.Header = item.SubItems[3].Text; edit.Description = item.SubItems[4].Text; edit.ShowDialog(this); if (edit.saved) { if (await BookmarksFinder.UpdateBookmark(item.Tag as FQID, edit.Header, edit.Description)) { item.SubItems[3].Text = edit.Header; item.SubItems[4].Text = edit.Description; } } } } } }
private async void EditBookmark(object sender, EventArgs e) { if (lsvBookmarks.SelectedItems.Count != 0) { ListViewItem item = lsvBookmarks.SelectedItems[0]; if (item != null && item.Tag != null) { using (EditBookmark edit = new EditBookmark()) { edit.BeginTime = item.SubItems[1].Text; edit.EndTime = item.SubItems[2].Text; edit.Header = item.SubItems[3].Text; edit.Description = item.SubItems[4].Text; edit.Plate = item.SubItems[5].Text; edit.Vehicle = item.SubItems[6].Text; edit.Timestamp = item.SubItems[7].Text; //edit.SiteName = item.SubItems[8].Text; edit.ShowDialog(this); if (edit.saved) { if (await BookmarksFinder.UpdateBookmark(item.Tag as FQID, edit.Header, edit.Description)) { item.SubItems[3].Text = edit.Header; item.SubItems[4].Text = edit.Description; item.SubItems[5].Text = edit.Plate; item.SubItems[6].Text = edit.Vehicle; item.SubItems[7].Text = edit.Timestamp; //item.SubItems[8].Text = edit.SiteName; } } } } } }
private void OnBookmarkEditing(object sender, BookmarkViewModel bookmarkViewModel) { var editable = bookmarkViewModel.Clone(); var dialog = new EditBookmark(editable); if (dialog.ShowDialog() == true) { bookmarkViewModel.FillFrom(editable); _storage.Save(); } }
public MainWindowViewModel( BrowserUrl browserUrl) { _browserUrl = browserUrl ?? throw new ArgumentNullException(nameof(browserUrl)); ExitCommand = new RelayCommand( (arg) => Application.Current.Shutdown() ); Bookmarks = _bookmarksViewModel.Bookmarks; _addressCompletionProvider.RegisterProvider(new BookmarksUriProvider(() => _bookmarksViewModel.Bookmarks.Select(b => b.Bookmark))); _addressCompletionProvider.RegisterProvider(new AllowedUrisProvider(_browserUrl)); AddBookmarkCommand = new RelayCommand( (arg) => { var viewModel = new BookmarkViewModel() { Title = SelectedBrowser.Browser.DocumentTitle, Address = SelectedBrowser.Browser.Source.ToString() }; var dialog = new EditBookmark(viewModel); if (dialog.ShowDialog() == true) { _bookmarksViewModel.AddBookmarkCommand.Execute(viewModel); } } ); AddNewTabCommand = new RelayCommand(arg => { var viewModel = new BrowserViewModel(_browserUrl); viewModel.Closing += OnBrowserTabClosing; viewModel.NewWindowRequested += OnNewWindowRequested; Browsers.Add(viewModel); SelectedBrowser = viewModel; }); SetLanguageCommand = new RelayCommand(arg => { var language = (string)arg; if (string.IsNullOrWhiteSpace(language) || CultureInfo.GetCultureInfo(language) == null) { Configuration.Language = null; } else { Configuration.Language = language; } NotifyPropertyChanged(nameof(Language)); Configuration.SetCurrentCulture(); }); _selectedBrowser = new BrowserViewModel(_browserUrl); _selectedBrowser.Closing += OnBrowserTabClosing; _selectedBrowser.NewWindowRequested += OnNewWindowRequested; Browsers.Add(_selectedBrowser); }