/// <summary> /// Handle the reception of a RTPageAdd object. The /// RTPageAdd allows to dynamically add pages on a document /// on client(s). /// </summary> /// <param name="pa">Page to add</param> private void RTPageAddReceived(RTPageAdd pa) { // Add to stroke hash strokesPerPage.Add(pa.Page.Identifier, new ArrayList()); Guid prevPageID = Guid.Empty; // Add TOCNode to rtDoc if( pa.PreviousSiblingIdentifier != Guid.Empty ) { TOCNode prevSib = rtDoc.Organization.TableOfContents[pa.PreviousSiblingIdentifier]; int prevSibIndex = rtDoc.Organization.TableOfContents.IndexOf( prevSib ); if( prevSib == null ) { // If we can't find the page, just use the last one prevSibIndex = rtDoc.Organization.TableOfContents.Count-1; if( prevSibIndex != -1 ) { prevSib = rtDoc.Organization.TableOfContents[prevSibIndex]; } } rtDoc.Organization.TableOfContents.Insert( prevSibIndex+1, pa.TOCNode ); prevPageID = (prevSib == null) ? Guid.Empty : prevSib.ResourceIdentifier; } else { rtDoc.Organization.TableOfContents.Add(pa.TOCNode); } // Add page to rtDoc pa.TOCNode.Resource = pa.Page; pa.TOCNode.ResourceIdentifier = pa.Page.Identifier; rtDoc.Resources.Pages.Add(pa.Page.Identifier, pa.Page); // Insert Page in ON this.InsertPageInON( pa.Page, pa.TOCNode.Title, prevPageID ); }
/// <summary> /// Handle the reception of a RTPageAdd object. The /// RTPageAdd allows to dynamically add pages on a document /// on client(s). /// </summary> /// <param name="pa">Page to add</param> private void RTPageAddReceived(RTPageAdd pa) { Log("It's a RTPageAdd object,"); // Pri2: verify that this new page belongs to this document if (rtDocumentHelper == null) { // Pri3: Send an RTDocumentRequest return; } pa.TOCNode.Resource = pa.Page; if( pa.PreviousSiblingIdentifier != Guid.Empty ) { TOCNode prevSib = rtDocument.Organization.TableOfContents[pa.PreviousSiblingIdentifier]; int prevSibIndex = rtDocument.Organization.TableOfContents.IndexOf( prevSib ); rtDocument.Organization.TableOfContents.Insert( prevSibIndex+1, pa.TOCNode ); } else { rtDocument.Organization.TableOfContents.Add( pa.TOCNode ); } rtDocument.Resources.Pages.Add( pa.Page.Identifier, pa.Page ); int pageIndex = rtDocument.Organization.TableOfContents.IndexOf( pa.TOCNode ); thumbnailsView.InsertThumbnail( pa.Page.Image, pa.TOCNode.Title, pageIndex, pa.TOCNode.Identifier ); statusBar.SetMaxPage( index+1, rtDocument.Organization.TableOfContents.Count ); UpdateNavigationButtonState(); return; }