public bool RelocatePage(IPage page, int indexOfItemAfterRelocation)
{
Guard.Against(Type != BookType.Publication, "Tried to edit a non-editable book.");
if(!CanRelocatePageAsRequested(indexOfItemAfterRelocation))
{
return false;
}
ClearPagesCache();
var pages = GetPageElements();
var pageDiv = FindPageDiv(page);
var body = pageDiv.ParentNode;
body.RemoveChild(pageDiv);
if(indexOfItemAfterRelocation == 0)
{
body.InsertBefore(pageDiv, body.FirstChild);
}
else
{
body.InsertAfter(pageDiv, pages[indexOfItemAfterRelocation-1]);
}
BuildPageCache();
Save();
InvokeContentsChanged(null);
return true;
}