C# Class Bloom.Edit.EditingModel

Show file Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Properties

Property Type Description
Visible bool

Public Methods

Method Description
BrowserFocusChanged ( ) : void
CanChangeImages ( ) : bool
ChangeBookLicenseMetaData ( Palaso.UI.WindowsForms.ClearShare.Metadata metadata ) : void
ChangePicture ( GeckoHtmlElement img, Palaso.UI.WindowsForms.ImageToolbox.PalasoImage imageInfo, IProgress progress ) : void
ContentLanguagesSelectionChanged ( ) : void

user has selected or de-selected a content language

CopyImageMetadataToWholeBook ( Palaso.UI.WindowsForms.ClearShare.Metadata metadata ) : void
DeterminePageWhichWouldPrecedeNextInsertion ( ) : IPage
EditingModel ( BookSelection bookSelection, PageSelection pageSelection, Bloom.Edit.TemplateInsertionCommand templateInsertionCommand, PageListChangedEvent pageListChangedEvent, RelocatePageEvent relocatePageEvent, BookRefreshEvent bookRefreshEvent, PageRefreshEvent pageRefreshEvent, DuplicatePageCommand duplicatePageCommand, DeletePageCommand deletePageCommand, SelectedTabChangedEvent selectedTabChangedEvent, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, LibraryClosing libraryClosingEvent, LocalizationChangedEvent localizationChangedEvent, CollectionSettings collectionSettings, EnhancedImageServer server, BloomWebSocketServer webSocketServer ) : System
GetBookHasChanged ( ) : bool
GetCurrentLayout ( ) : Layout
GetFontAvailabilityMessage ( ) : string
GetLayoutChoices ( ) : IEnumerable
GetXmlDocumentForCurrentPage ( ) : HtmlDom

Return the DOM that represents the content of the current page. Note that this is typically not the top-level thing displayed by the browser; rather, it is embedded in an iframe.

GetXmlDocumentForEditScreenWebPage ( ) : HtmlDom

Return the top-level document that should be displayed in the browser for the current page.

OnIdleAfterDocumentSupposedlyCompleted ( object sender, EventArgs e ) : void

For some reason, we need to call this code OnIdle. We couldn't figure out the timing any other way.

OnPageSelectionChanged ( object sender, EventArgs e ) : void
RefreshDisplayOfCurrentPage ( ) : void
SaveNow ( ) : void
SavePageFrameState ( ) : void

Save anything we want to persist from page to page but which is not part of the book from the page's current state. Currently this is just the zoom level.

SetLayout ( Layout layout ) : void
SetView ( EditingView view ) : void
SetupServerWithCurrentPageIframeContents ( ) : void
ShowAddPageDialog ( ) : void

Although browsers are happy to let you manipulate the DOM, in most cases gecko/xulrunner does not expect that we, the host process, are going to need access to those changes. For example, if we have a control that adds a class to some element based on a user choice, the user will see the choice take effect, but then when they come back to the page later, their choice will be lost. This is because that new class just isn't in the html that gets returned to us, if we do, for example, _browser.Document.GetElementsByTagName("body").outerHtml. (Other things changes *are* returned, like the new contents of an editable div). /// Anyhow this method, triggered by javascript that knows it did something that will be lost, is here in order to work around this. The Javascript does something like: var origin = window.location.protocol + '//' + window.location.host; event.initMessageEvent ('PreserveClassAttributeOfElement', true, true, theHTML, origin, 1234, window, null); document.dispatchEvent (event); /// The hard part here is knowing which element gets this html

ViewVisibleNowDoSlowStuff ( ) : void

Private Methods

Method Description
AddMessageEventListener ( string name, Action listener ) : void
AddStandardEventListeners ( ) : void

listen for these events raised by javascript.

CannotSavePage ( ) : bool
ChangePageLayout ( IPage page ) : void
CheckForBL2364 ( string when ) : void
DeletePage ( IPage page ) : void
DocumentCompleted ( ) : void

View calls this once the main document has completed loading. But this is not really reliable. Also see comments in EditingView.UpdateSingleDisplayedPage. TODO really need a more reliable way of determining when the document really is complete

DuplicatePage ( IPage page ) : void
FinishSavingPage ( string ignored = null ) : void

Called from a JavaScript event after it has done everything appropriate in JS land towards saving a page, in the process of wrapping up this page before moving to another. The main point is that any changes on this page get saved back to the main document. In case it is an origami page, there is some special stuff to do as commented below. (Argument is required for JS callback, not used).

OnBookSelectionChanged ( object sender, EventArgs e ) : void
OnDeletePage ( ) : void
OnDuplicatePage ( ) : void
OnInsertTemplatePage ( object sender, EventArgs e ) : void
OnPageSelectionChanging ( object sender, EventArgs eventArgs ) : void
OnRelocatePage ( RelocatePageInfo info ) : void
OnTabAboutToChange ( TabChangedDetails details ) : void

we need to guarantee that we save *before* any other tabs try to update, hence this "about to change" event

OnTabChanged ( TabChangedDetails details ) : void
PageSelectionFinished ( ) : void

Flag that the current (former) page selection has finished, so it's safe to select another page.

PageSelectionStarted ( ) : void

Flag that a page selection is currently under way.

ReactivateFormOnIdle ( object sender, EventArgs eventArgs ) : void
RemoveStandardEventListeners ( ) : void

stop listening for these events raised by javascript.

RethinkPageAndReloadIt ( string obj ) : void
SaveToolboxSettings ( string data ) : void
SetPageZoom ( ) : void

Set a style on the body of the main content page that will zoom it to the extent the user currently prefers.

SetTopic ( string englishTopicAsKey ) : void

When the user types ctrl+n, we do this: 1) If the user is on a page that is xmatter, or a singleton, then we just add the first page in the template 2) Else, make a new page of the same type as the current one

Method Details

BrowserFocusChanged() public method

public BrowserFocusChanged ( ) : void
return void

CanChangeImages() public method

public CanChangeImages ( ) : bool
return bool

ChangeBookLicenseMetaData() public method

public ChangeBookLicenseMetaData ( Palaso.UI.WindowsForms.ClearShare.Metadata metadata ) : void
metadata Palaso.UI.WindowsForms.ClearShare.Metadata
return void

ChangePicture() public method

public ChangePicture ( GeckoHtmlElement img, Palaso.UI.WindowsForms.ImageToolbox.PalasoImage imageInfo, IProgress progress ) : void
img GeckoHtmlElement
imageInfo Palaso.UI.WindowsForms.ImageToolbox.PalasoImage
progress IProgress
return void

ContentLanguagesSelectionChanged() public method

user has selected or de-selected a content language
public ContentLanguagesSelectionChanged ( ) : void
return void

CopyImageMetadataToWholeBook() public method

public CopyImageMetadataToWholeBook ( Palaso.UI.WindowsForms.ClearShare.Metadata metadata ) : void
metadata Palaso.UI.WindowsForms.ClearShare.Metadata
return void

DeterminePageWhichWouldPrecedeNextInsertion() public method

public DeterminePageWhichWouldPrecedeNextInsertion ( ) : IPage
return IPage

EditingModel() public method

public EditingModel ( BookSelection bookSelection, PageSelection pageSelection, Bloom.Edit.TemplateInsertionCommand templateInsertionCommand, PageListChangedEvent pageListChangedEvent, RelocatePageEvent relocatePageEvent, BookRefreshEvent bookRefreshEvent, PageRefreshEvent pageRefreshEvent, DuplicatePageCommand duplicatePageCommand, DeletePageCommand deletePageCommand, SelectedTabChangedEvent selectedTabChangedEvent, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, LibraryClosing libraryClosingEvent, LocalizationChangedEvent localizationChangedEvent, CollectionSettings collectionSettings, EnhancedImageServer server, BloomWebSocketServer webSocketServer ) : System
bookSelection Bloom.Book.BookSelection
pageSelection PageSelection
templateInsertionCommand Bloom.Edit.TemplateInsertionCommand
pageListChangedEvent PageListChangedEvent
relocatePageEvent RelocatePageEvent
bookRefreshEvent BookRefreshEvent
pageRefreshEvent PageRefreshEvent
duplicatePageCommand DuplicatePageCommand
deletePageCommand DeletePageCommand
selectedTabChangedEvent SelectedTabChangedEvent
selectedTabAboutToChangeEvent SelectedTabAboutToChangeEvent
libraryClosingEvent LibraryClosing
localizationChangedEvent LocalizationChangedEvent
collectionSettings Bloom.Collection.CollectionSettings
server EnhancedImageServer
webSocketServer BloomWebSocketServer
return System

GetBookHasChanged() public method

public GetBookHasChanged ( ) : bool
return bool

GetCurrentLayout() public method

public GetCurrentLayout ( ) : Layout
return Bloom.Book.Layout

GetFontAvailabilityMessage() public method

public GetFontAvailabilityMessage ( ) : string
return string

GetLayoutChoices() public method

public GetLayoutChoices ( ) : IEnumerable
return IEnumerable

GetXmlDocumentForCurrentPage() public method

Return the DOM that represents the content of the current page. Note that this is typically not the top-level thing displayed by the browser; rather, it is embedded in an iframe.
public GetXmlDocumentForCurrentPage ( ) : HtmlDom
return Bloom.Book.HtmlDom

GetXmlDocumentForEditScreenWebPage() public method

Return the top-level document that should be displayed in the browser for the current page.
public GetXmlDocumentForEditScreenWebPage ( ) : HtmlDom
return Bloom.Book.HtmlDom

OnIdleAfterDocumentSupposedlyCompleted() public method

For some reason, we need to call this code OnIdle. We couldn't figure out the timing any other way.
public OnIdleAfterDocumentSupposedlyCompleted ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void

OnPageSelectionChanged() public method

public OnPageSelectionChanged ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void

RefreshDisplayOfCurrentPage() public method

public RefreshDisplayOfCurrentPage ( ) : void
return void

SaveNow() public method

public SaveNow ( ) : void
return void

SavePageFrameState() public method

Save anything we want to persist from page to page but which is not part of the book from the page's current state. Currently this is just the zoom level.
public SavePageFrameState ( ) : void
return void

SetLayout() public method

public SetLayout ( Layout layout ) : void
layout Bloom.Book.Layout
return void

SetView() public method

public SetView ( EditingView view ) : void
view EditingView
return void

SetupServerWithCurrentPageIframeContents() public method

public SetupServerWithCurrentPageIframeContents ( ) : void
return void

ShowAddPageDialog() public method

Although browsers are happy to let you manipulate the DOM, in most cases gecko/xulrunner does not expect that we, the host process, are going to need access to those changes. For example, if we have a control that adds a class to some element based on a user choice, the user will see the choice take effect, but then when they come back to the page later, their choice will be lost. This is because that new class just isn't in the html that gets returned to us, if we do, for example, _browser.Document.GetElementsByTagName("body").outerHtml. (Other things changes *are* returned, like the new contents of an editable div). /// Anyhow this method, triggered by javascript that knows it did something that will be lost, is here in order to work around this. The Javascript does something like: var origin = window.location.protocol + '//' + window.location.host; event.initMessageEvent ('PreserveClassAttributeOfElement', true, true, theHTML, origin, 1234, window, null); document.dispatchEvent (event); /// The hard part here is knowing which element gets this html
public ShowAddPageDialog ( ) : void
return void

ViewVisibleNowDoSlowStuff() public method

public ViewVisibleNowDoSlowStuff ( ) : void
return void

Property Details

Visible public property

public bool Visible
return bool