Пример #1
0
        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);
        }