public IAsyncResult BeginSendPageAdd(Page page, AsyncCallback callback, object state) { if (disposed) { throw new ObjectDisposedException("RTDocumentHelper has been disposed"); } RTPageAdd pa = new RTPageAdd(page); AddTOCNodeToRTDocument(pa.TOCNode); AddPageToRTDocument(pa.Page); return(capability.BeginSendObjectBackground(pa, callback, state)); }
public void SendPageAdd(Page page) { if (disposed) { throw new ObjectDisposedException("RTDocumentHelper has been disposed"); } RTPageAdd pa = new RTPageAdd(page); AddTOCNodeToRTDocument(pa.TOCNode); AddPageToRTDocument(pa.Page); capability.SendObjectBackground(pa); }
public void ReceiveRTPageAdd(RTPageAdd rtpa, Guid docId) { if (!decksStored.ContainsKey(docId)) { ArrayList titles = new ArrayList(); titles.Add(rtpa.TOCNode.Title); decksStored.Add(docId, titles); } else { ((ArrayList)decksStored[docId]).Add(rtpa.TOCNode.Title); } if (!deckTitles.ContainsKey(docId)) { deckTitles.Add(docId, "RTDocument Deck"); } }
//Pri2: This does not follow pattern because it doesn't return IAsyncResult -- needed to get the TOCNode out ASAP due to UI logic public TOCNode BeginSendPageInsert(Page page, string title, int index, AsyncCallback callback, object state) { if (disposed) { throw new ObjectDisposedException("RTDocumentHelper has been disposed"); } RTPageAdd pa = new RTPageAdd(page); pa.TOCNode.Title = title; pa.PreviousSiblingIdentifier = rtDocument.Organization.TableOfContents[index].Identifier; AddTOCNodeToRTDocument(index, pa.TOCNode); AddPageToRTDocument(pa.Page); capability.BeginSendObjectBackground(pa, callback, state); return(pa.TOCNode); }
public TOCNode SendPageInsert(Page page, string title, int index) { if (disposed) { throw new ObjectDisposedException("RTDocumentHelper has been disposed"); } //Pri2: There is a lot of code duplication with BeginSendPageInsert, we might want //to add a commun method for SendPageInsert and BeginSendPageInsert RTPageAdd pa = new RTPageAdd(page); pa.TOCNode.Title = title; pa.PreviousSiblingIdentifier = rtDocument.Organization.TableOfContents[index].Identifier; AddTOCNodeToRTDocument(index, pa.TOCNode); AddPageToRTDocument(pa.Page); capability.SendObject(pa); return(pa.TOCNode); }
/// <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); }
public TOCNode SendPageInsert ( Page page, string title, int index ) { if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed); //Pri2: There is a lot of code duplication with BeginSendPageInsert, we might want //to add a commun method for SendPageInsert and BeginSendPageInsert RTPageAdd pa = new RTPageAdd( page ); pa.TOCNode.Title = title; pa.PreviousSiblingIdentifier = rtDocument.Organization.TableOfContents[index].Identifier; AddTOCNodeToRTDocument( index, pa.TOCNode ); AddPageToRTDocument( pa.Page ); capability.SendObject(pa); return pa.TOCNode; }
//Pri2: This does not follow pattern because it doesn't return IAsyncResult -- needed to get the TOCNode out ASAP due to UI logic public TOCNode BeginSendPageInsert ( Page page, string title, int index, AsyncCallback callback, object state ) { if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed); RTPageAdd pa = new RTPageAdd( page ); pa.TOCNode.Title = title; pa.PreviousSiblingIdentifier = rtDocument.Organization.TableOfContents[index].Identifier; AddTOCNodeToRTDocument( index, pa.TOCNode ); AddPageToRTDocument( pa.Page ); capability.BeginSendObjectBackground(pa, callback, state); return pa.TOCNode; }
public IAsyncResult BeginSendPageAdd ( Page page, AsyncCallback callback, object state ) { if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed); RTPageAdd pa = new RTPageAdd( page ); AddTOCNodeToRTDocument( pa.TOCNode ); AddPageToRTDocument( pa.Page ); return capability.BeginSendObjectBackground(pa, callback, state); }
public void SendPageAdd ( Page page ) { if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed); RTPageAdd pa = new RTPageAdd( page ); AddTOCNodeToRTDocument( pa.TOCNode ); AddPageToRTDocument( pa.Page ); capability.SendObjectBackground(pa); }
public static bool AddRTPageAddToRTDocument(RTDocument rtDocument, RTPageAdd rtpa) { rtDocument.Organization.TableOfContents.Add(rtpa.TOCNode); return(AddPageToRTDocument(rtDocument, rtpa.Page)); }
/// <summary> /// Handle frames from a native RTDocument generator such as the CXP presentation tool /// </summary> /// <param name="rtobj"></param> private void acceptRTDocFrame(object rtobj) { ///Notes about RTDocuments: /// /// RTDocuments have Resources and Organizations. Resources contain Pages/Images etc while Organizations /// contain the TOC/titles, etc. The TOC Nodes contain references to the resources and resource IDs. /// The navigation message RTNodeChanged just tells us the organization node ID, while /// Page and ink messages only contain the Resource ID. RTDocument messages contain the TOC which maps pages and org nodes. /// PageAdds will not have an existing TocNode in the RTDocument map, but they carry their own TocNode property. /// /// For this application, we only care about having one unique page identifier. We take the strategy of storing /// SlideImages under the resource Identifier, and maintaining a lookup table of Organization identifier to /// resource identifier. We use this table to resolve Organization identifiers when navigation messages are received. if (rtobj is RTDocument) { RTDocument rtd = (RTDocument)rtobj; //Keep the mapping of TocNode.Identifier to TocNode.ResourceIdentifier foreach (TOCNode tn in rtd.Organization.TableOfContents) { if (!orgToResource.ContainsKey(tn.Identifier)) { orgToResource.Add(tn.Identifier, tn.ResourceIdentifier); } else { orgToResource[tn.Identifier] = tn.ResourceIdentifier; } } //There is an implicit navigation to the first slide here. this.currentSlide.SetRTDocReference(rtd.Organization.TableOfContents[0].ResourceIdentifier); } else if (rtobj is Page) { //These are slide deck pages //p.Identifier is a Resource Identifier. Store the image under that Identifier. Page p = (Page)rtobj; if (!slideImages.ContainsKey(p.Identifier.ToString())) { slideImages.Add(p.Identifier.ToString(), new SlideImage()); } ((SlideImage)slideImages[p.Identifier.ToString()]).SetImage(p.Image, false); } else if (rtobj is RTPageAdd) { //These are dynamically added pages such as WB and screenshots RTPageAdd rtpa = (RTPageAdd)rtobj; //RTPageAdd comes with a TocNode. Store the mapping of resource ID to TocNode.Identifier if (!orgToResource.ContainsKey(rtpa.TOCNode.Identifier)) { orgToResource.Add(rtpa.TOCNode.Identifier, rtpa.Page.Identifier); } else { orgToResource[rtpa.TOCNode.Identifier] = rtpa.Page.Identifier; } //Store the page Image under the resource ID. if (!slideImages.ContainsKey(rtpa.Page.Identifier.ToString())) { slideImages.Add(rtpa.Page.Identifier.ToString(), new SlideImage()); } ((SlideImage)slideImages[rtpa.Page.Identifier.ToString()]).SetImage(rtpa.Page.Image, false); } else if (rtobj is RTNodeChanged) { RTNodeChanged rtnc = (RTNodeChanged)rtobj; //Look up the resource ID and update curent page. if (orgToResource.ContainsKey(rtnc.OrganizationNodeIdentifier)) { currentSlide.SetRTDocReference(((Guid)orgToResource[rtnc.OrganizationNodeIdentifier])); } else { //Indicate slide missing by setting currentSlide reference to Guid.Empty currentSlide.SetRTDocReference(Guid.Empty); } } else if (rtobj is RTStroke) { RTStroke rts = (RTStroke)rtobj; //apply the ink to the given Page Identifier. Create a new SlideImage if necessary. if (!slideImages.ContainsKey(rts.PageIdentifier.ToString())) { slideImages.Add(rts.PageIdentifier.ToString(), new SlideImage()); } Microsoft.Ink.Ink ink = rts.Stroke.Ink.Clone(); for (int i = 0; i < ink.Strokes.Count; i++) { ink.Strokes[i].Scale(500f / 960f, 500f / 720f); } ((SlideImage)slideImages[rts.PageIdentifier.ToString()]).AddInk(ink, rts.StrokeIdentifier); //There appears to be an implicit navigation here. currentSlide.SetRTDocReference(rts.PageIdentifier); } else if (rtobj is RTStrokeRemove) { RTStrokeRemove rtsr = (RTStrokeRemove)rtobj; //Use the PageIdentifer to identify the page from which to remove the stroke. if (slideImages.ContainsKey(rtsr.PageIdentifier.ToString())) { ((SlideImage)slideImages[rtsr.PageIdentifier.ToString()]).RemoveInk(rtsr.StrokeIdentifier); } } else if (rtobj is RTFrame) { RTFrame rtf = (RTFrame)rtobj; if (rtf.ObjectTypeIdentifier == Constants.RTDocEraseAllGuid) { //Erase all ink on the current slide. if ((currentSlide.IsSet) && (slideImages.ContainsKey(currentSlide.GetStringHashCode()))) { ((SlideImage)slideImages[currentSlide.GetStringHashCode()]).RemoveAllInk(); } } else { Debug.WriteLine("Unhandled RTFrame type."); } } else { Debug.WriteLine("Unhandled RT obj:" + rtobj.ToString()); } }