private void SelectBook(BookInfo bookInfo) { try { _bookSelection.SelectBook(_model.GetBookFromBookInfo(bookInfo)); _bookContextMenu.Enabled = true; //Debug.WriteLine("before selecting " + SelectedBook.Title); _model.SelectBook(SelectedBook); //Debug.WriteLine("after selecting " + SelectedBook.Title); //didn't help: _listView.Focus();//hack we were losing clicks SelectedBook.ContentsChanged -= new EventHandler(OnContentsOfSelectedBookChanged); //in case we're already subscribed SelectedBook.ContentsChanged += new EventHandler(OnContentsOfSelectedBookChanged); deleteMenuItem.Enabled = _model.CanDeleteSelection; _updateThumbnailMenu.Visible = _model.CanUpdateSelection; _updateFrontMatterToolStripMenu.Visible = _model.CanUpdateSelection; } catch (Exception error) { //skip over the dependency injection layer if (error.Source == "Autofac" && error.InnerException != null) { error = error.InnerException; } Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Bloom cannot display that book."); } }
private void OnClickBook(object sender, EventArgs e) { try { BookInfo bookInfo = ((Button)sender).Tag as BookInfo; if (bookInfo == null) { return; } if (SelectedBook != null && bookInfo == SelectedBook.BookInfo) { //I couldn't get the DoubleClick event to work, so I rolled my own if (Control.MouseButtons == MouseButtons.Left && DateTime.Now.Subtract(_lastClickTime).TotalMilliseconds < SystemInformation.DoubleClickTime) { _model.DoubleClickedBook(); return; } } else { _bookSelection.SelectBook(_model.GetBookFromBookInfo(bookInfo)); } _lastClickTime = DateTime.Now; _bookContextMenu.Enabled = true; //Debug.WriteLine("before selecting " + SelectedBook.Title); _model.SelectBook(SelectedBook); //Debug.WriteLine("after selecting " + SelectedBook.Title); //didn't help: _listView.Focus();//hack we were losing clicks SelectedBook.ContentsChanged -= new EventHandler(OnContentsOfSelectedBookChanged); //in case we're already subscribed SelectedBook.ContentsChanged += new EventHandler(OnContentsOfSelectedBookChanged); deleteMenuItem.Enabled = _model.CanDeleteSelection; _updateThumbnailMenu.Visible = _model.CanUpdateSelection; _updateFrontMatterToolStripMenu.Visible = _model.CanUpdateSelection; } catch (Exception error) { //skip over the dependency injection layer if (error.Source == "Autofac" && error.InnerException != null) { error = error.InnerException; } Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Bloom cannot display that book."); } }