private void _deletePageButton_Click_1(object sender, EventArgs e) { if (ConfirmRemovePageDialog.Confirm()) { _deletePageCommand.Execute(); } }
public void RegisterWithApiHandler(BloomApiHandler apiHandler) { apiHandler.RegisterEndpointHandler(kApiUrlPart + "requestState", request => { if (request.HttpMethod == HttpMethods.Get) { request.ReplyWithJson(CurrentStateString); } else // post { Debug.Fail("We shouldn't ever be using the 'post' version."); request.PostSucceeded(); } }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "addPage", request => { AddPageButton_Click(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "duplicatePage", request => { _editingModel.OnDuplicatePage(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "deletePage", request => { if (ConfirmRemovePageDialog.Confirm()) { _editingModel.OnDeletePage(); } request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "lockBook", request => { _editingModel.SaveNow(); // BL-5421 lock and unlock lose typing _editingModel.CurrentBook.TemporarilyUnlocked = false; request.PostSucceeded(); UpdateState(); // because we aren't selecting a new page _editingModel.RefreshDisplayOfCurrentPage(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "unlockBook", request => { _editingModel.SaveNow(); // BL-5421 lock and unlock lose typing _editingModel.CurrentBook.TemporarilyUnlocked = true; request.PostSucceeded(); UpdateState(); // because we aren't selecting a new page _editingModel.RefreshDisplayOfCurrentPage(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "cleanup", request => { SendCleanupState(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "zoomMinus", request => { _editingModel.AdjustPageZoom(-10); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "zoomPlus", request => { _editingModel.AdjustPageZoom(10); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "requestVideoPlaceHolder", request => { _editingModel.RequestVideoPlaceHolder(); request.PostSucceeded(); }, true); apiHandler.RegisterEndpointHandler(kApiUrlPart + "requestWidgetPlaceHolder", request => { _editingModel.RequestWidgetPlaceHolder(); request.PostSucceeded(); }, true); }
public PageListView(PageSelection pageSelection, RelocatePageEvent relocatePageEvent, EditingModel model, HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent, PageListApi pageListApi, BloomWebSocketServer webSocketServer) { _pageSelection = pageSelection; _model = model; this.Font = SystemFonts.MessageBoxFont; InitializeComponent(); _thumbNailList.PageListApi = pageListApi; _thumbNailList.WebSocketServer = webSocketServer; this.BackColor = Palette.SidePanelBackgroundColor; _thumbNailList.Thumbnailer = thumbnailProvider; _thumbNailList.RelocatePageEvent = relocatePageEvent; _thumbNailList.PageSelectedChanged += new EventHandler(OnPageSelectedChanged); _thumbNailList.ControlKeyEvent = controlKeyEvent; _thumbNailList.Model = model; _thumbNailList.BringToFront(); // needed to get DockStyle.Fill to work right. // First action determines whether the menu item is enabled, second performs it. var menuItems = new List <WebThumbNailList.MenuItemSpec>(); menuItems.Add( new WebThumbNailList.MenuItemSpec() { Label = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"), EnableFunction = (page) => page != null && _model.CanDuplicatePage, ExecuteCommand = (page) => _model.DuplicatePage(page) }); menuItems.Add( new WebThumbNailList.MenuItemSpec() { Label = LocalizationManager.GetString("EditTab.CopyPage", "Copy Page"), EnableFunction = (page) => page != null && _model.CanCopyPage, ExecuteCommand = (page) => _model.CopyPage(page) }); menuItems.Add( new WebThumbNailList.MenuItemSpec() { Label = LocalizationManager.GetString("EditTab.PastePage", "Paste Page"), EnableFunction = (page) => page != null && _model.CanAddPages && _model.GetClipboardHasPage(), ExecuteCommand = (page) => _model.PastePage(page) }); menuItems.Add( new WebThumbNailList.MenuItemSpec() { Label = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"), EnableFunction = (page) => page != null && _model.CanDeletePage, ExecuteCommand = (page) => { if (ConfirmRemovePageDialog.Confirm()) { _model.DeletePage(page); } } }); menuItems.Add( new WebThumbNailList.MenuItemSpec() { Label = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"), EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown, ExecuteCommand = (page) => _model.ChangePageLayout(page) }); // This adds the desired menu items to the Gecko context menu that happens when we right-click _thumbNailList.ContextMenuProvider = args => { var page = _thumbNailList.GetPageContaining(args.TargetNode); if (page == null) { return(true); // no page-related commands if we didn't click on one. } if (page != _pageSelection.CurrentSelection) { return(true); //it's too dangerous to let users do thing to a page they aren't seeing } foreach (var item in menuItems) { var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page)); args.ContextMenu.MenuItems.Add(menuItem); menuItem.Enabled = item.EnableFunction(page); } return(true); }; // This sets up the context menu items that will be shown when the user clicks the // arrow in the thumbnail list. _thumbNailList.ContextMenuItems = menuItems; }