Example #1
0
        /// <summary>
        /// A hack for the BillG review.
        /// </summary>
        // TODO: Delete this.
        private void RemoteFileOpenReceived(string filename)
        {
            try
            {
                // Open a RTD file
                BinaryFormatter myBinaryFormat = new BinaryFormatter();
                FileStream      myInputStream  = System.IO.File.OpenRead(filename);
                RTDocument      rtDocNew       = (RTDocument)myBinaryFormat.Deserialize(myInputStream);

                this.RTDocumentReceived(rtDocNew);

                foreach (TOCNode node in rtDoc.Organization.TableOfContents)
                {
                    this.InsertPageInON((Page)node.Resource, node.Title, Guid.Empty);
                }

                Page pFirst = (Page)rtDoc.Organization.TableOfContents[0].Resource;
                importer.NavigateToPage(crntONFile, pFirst.Identifier.ToString("B"));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in opening " + filename + ", error message: " + ex.Message.ToString());
                return;
            }
        }
Example #2
0
        public RTDocumentHelper(Capability capability, RTDocument rtDocument)
        {
            this.capability = capability;

            this.rtDocument      = rtDocument;
            rtDocumentIdentifier = rtDocument.Identifier;

            // Set up delegate that is used to send the slides on a background thread
            beginSendAllSlidesDelegate = new SendAllSlidesHandler(SendAllSlides);
        }
        public RTDocumentHelper ( Capability capability, RTDocument rtDocument )
        {
            this.capability = capability;

            this.rtDocument = rtDocument;
            rtDocumentIdentifier = rtDocument.Identifier;

            // Set up delegate that is used to send the slides on a background thread
            beginSendAllSlidesDelegate = new SendAllSlidesHandler(SendAllSlides);
        }
 public Deck(RTDocument rtd)
 {
     matched     = false;
     matchExt    = null;
     exactMatch  = false;
     deckGuid    = rtd.Identifier;
     slideCount  = rtd.Organization.TableOfContents.Count;
     fileName    = "unknown name";
     slideTitles = null;
 }
Example #5
0
        public static bool AddTocIDToRTDocument(RTDocument rtDocument, Guid tocID)
        {
            TOCNode tocNode = new TOCNode();

            tocNode.ResourceIdentifier = Guid.Empty;
            tocNode.Identifier         = tocID;
            tocNode.Resource           = null;
            rtDocument.Organization.TableOfContents.Add(tocNode);
            return(true);
        }
Example #6
0
        public static int PageIDToPageIndex(RTDocument rtDoc, Guid pageID)
        {
            foreach (TOCNode n in rtDoc.Organization.TableOfContents)
            {
                if (n.ResourceIdentifier == pageID)
                {
                    return(rtDoc.Organization.TableOfContents.IndexOf(n));
                }
            }

            return(-1);
        }
Example #7
0
        public static bool AddPageToRTDocument(RTDocument rtDocument, Page page)
        {
            TOCNode tn = WalkTOCNodes(rtDocument.Organization.TableOfContents, page);

            if (tn == null)
            {
                return(false);
            }

            if (!rtDocument.Resources.Pages.ContainsKey(page.Identifier))
            {
                rtDocument.Resources.Pages.Add(page.Identifier, page);
                tn.Resource = page;
            }
            return(true);
        }
Example #8
0
        public void ReceiveRTDocument(RTDocument rtd)
        {
            if (!decksStored.ContainsKey(rtd.Identifier))
            {
                ArrayList titles = new ArrayList();
                foreach (TOCNode n in rtd.Organization.TableOfContents)
                {
                    titles.Add(n.Title);
                }

                decksStored.Add(rtd.Identifier, titles);
            }
            if (!deckTitles.ContainsKey(rtd.Identifier))
            {
                deckTitles.Add(rtd.Identifier, "RTDocument Deck");
            }
        }
Example #9
0
        /// <summary>
        /// Handle the reception of an RTDocument object. The rtDocument received
        /// does not contain the actual pages (the pages are received separately),
        /// so this function mainly handles the reception of the document structure
        /// (TOC, number of pages, guid of pages, etc.) on the client(s).
        /// </summary>
        /// <param name="rtDocReceived">rtDocument structure received</param>
        private void RTDocumentReceived(RTDocument rtDocReceived)
        {
            // Set rtDoc only if you receive a new document (not a repeat)
            if ((rtDoc == null) || (rtDocReceived.Identifier != rtDoc.Identifier))
            {
                rtDoc = rtDocReceived;

                // Deal with blank titles
                if (rtDocReceived.Metadata.Title == null)
                {
                    rtDocReceived.Metadata.Title = "Presentation Session";
                }

                // Pri2: Re-enable this feature (removed due to PS 2063)
                //string folderInON = Options.GetFolderForAuthor(rtDocReceived.Metadata.Creator);
                //crntONFile = folderInON + MakeTitleValid(rtDocReceived.Metadata.Title);
                crntONFile = MakeTitleValid(rtDocReceived.Metadata.Title);

                // If this file name already exists, we append the date & time to it.
                if (System.IO.File.Exists(this.oneNoteNotebookDir + "\\" + crntONFile + ".one"))
                {
                    if (Options.ShowOverwriteFileQuestion(crntONFile))
                    {
                        // Delete fails becuase the file is in use.  I guess we just plop the data
                        //  on top of the old slide, eh?
                        crntONFile += ".one";
                    }
                    else
                    {
                        crntONFile += DateTime.Now.ToString("u").Replace(":", ".").Replace("Z", "") + ".one";
                    }
                }
                else
                {
                    crntONFile += ".one";
                }

                // Add all Pages to strokes hash immediately
                this.strokesPerPage.Clear();
                foreach (TOCNode tn in rtDoc.Organization.TableOfContents)
                {
                    this.strokesPerPage.Add(tn.ResourceIdentifier, new ArrayList());
                }
            }
        }
Example #10
0
        public static bool AddPageIDToRTDocument(RTDocument rtDocument, Guid pageID)
        {
            TOCNode tocNode = new TOCNode();

            tocNode.ResourceIdentifier = pageID;
            if (rtDocument.Identifier == pageID)
            {
                tocNode.Identifier = pageID;
            }
            else
            {
                tocNode.Identifier = Guid.NewGuid();
            }
            Page p = new Page();

            p.Identifier     = pageID;
            p.Image          = null;
            tocNode.Resource = p;
            rtDocument.Organization.TableOfContents.Add(tocNode);
            return(AddPageToRTDocument(rtDocument, p));
        }
Example #11
0
        public RTDocument RTDocumentBodyOnly()
        {
            if (disposed)
            {
                throw new ObjectDisposedException("RTDocumentHelper has been disposed");
            }

            RTDocument rtDocBody = (RTDocument)((ICloneable)rtDocument).Clone();

            rtDocBody.Resources.ResourceList.Clear();
            rtDocBody.Resources.Pages.Clear();
            rtDocBody.Resources.Extension = null;

            // Go through TOCNodes and strip Resource object refs
            if (rtDocBody.Organization.TableOfContents != null)
            {
                for (int i = 0; i < rtDocBody.Organization.TableOfContents.Count; i++)
                {
                    StripResourceObjectFromTocNode(rtDocBody.Organization.TableOfContents[i]);
                }
            }

            return(rtDocBody);
        }
        private void processRTDocument(RTDocument rtd)
        {
            if (stopNow)
            {
                return;
            }
            if (rtd == null)
            {
                progressTracker.CurrentValue += 100;
                return;
            }

            if (outputDirs.ContainsKey(rtd.Identifier))
            {
                log.WriteLine("Warning: A duplicate RTDocument with identifier: " + rtd.Identifier + " was found in " +
                              "the presentation data.  This RTDocument will be ignored.");
                log.ErrorLevel = 5;
                progressTracker.CurrentValue += 100;
                return;
            }

            if (rtd.Organization.TableOfContents.Length <= 0)
            {
                progressTracker.CurrentValue += 100;
                return;
            }

            String tempDirName = Utility.GetTempDir();

            Directory.CreateDirectory(tempDirName);
            int i         = 1;
            int pagecount = rtd.Organization.TableOfContents.Length;
            int ptStart   = progressTracker.CurrentValue;

            foreach (TOCNode n in rtd.Organization.TableOfContents)
            {
                Page p = rtd.Resources.Pages[n.ResourceIdentifier];
                if ((p != null) && (p.Image != null))
                {
                    String jpgfile = Path.Combine(tempDirName, "slide" + i.ToString() + ".jpg");

                    if (!repairAspectRatio(p.Image, jpgfile))
                    {
                        if (p.Image.Size.Width > 1600)
                        {
                            //PRI2: how do we make the images look better, but still be 'small'?
                            Image img2 = new Bitmap(p.Image, new Size(960, 720));
                            img2.Save(jpgfile, ImageFormat.Jpeg);
                            img2.Dispose();
                        }
                        else
                        {
                            p.Image.Save(jpgfile, ImageFormat.Jpeg);
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("SlideImageGenerator: skipping rtdoc page: null page or null image.");
                }
                progressTracker.CurrentValue = ((100 * i) / pagecount) + ptStart;
                i++;
            }
            this.outputDirs.Add(rtd.Identifier, tempDirName);
        }
Example #13
0
        private void ConsumeObject(ObjectReceivedEventArgs orea)
        {
            // Create RTDoc with one slide & put it in ON
            if (rtDoc == null && !(orea.Data is RTDocument || orea.Data is RTFrame))
            {
                // Create blank RTDocument
                rtDoc                  = new RTDocument();
                rtDoc.Identifier       = new Guid(constWhiteboardGuid);
                rtDoc.Metadata.Title   = "Whiteboard Session " + DateTime.Now.ToString("u");
                rtDoc.Metadata.Creator = Conference.LocalParticipant.Name;

                // Add a blank page
                Page pg = new Page();
                pg.Identifier = new Guid(constWhiteboardGuid);
                TOCNode tn = new TOCNode();
                tn.Title              = "Whiteboard 1";
                tn.Resource           = pg;
                tn.ResourceIdentifier = pg.Identifier;
                tn.Identifier         = new Guid(constWhiteboardGuid);
                rtDoc.Organization.TableOfContents.Add(tn);
                rtDoc.Resources.Pages.Add(pg.Identifier, pg);

                // Add the page to the strokes hash
                strokesPerPage.Add(pg.Identifier, new ArrayList());

                // Init necessary vars
                this.crntPage = pg.Identifier;
                // Pri2: re-enable this feature (removed due to PS 2063)
                //string folderInON = Options.GetFolderForAuthor("Unknown / Whiteboard Session");
                //this.crntONFile = folderInON + " " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z","") + ".one";
                this.crntONFile = "Whiteboard - " + DateTime.Now.ToString("u").Replace(":", ".").Replace("Z", "") + ".one";

                // Import the page
                this.InsertPageInON(pg, tn.Title, Guid.Empty);

                // Show first page
                System.Threading.Thread.Sleep(50);
                importer.NavigateToPage(crntONFile, crntPage.ToString("B"));
            }

            if (orea.Data is RTStrokeRemove)
            {
                RTStrokeRemoveReceived((RTStrokeRemove)orea.Data);
            }
            else if (orea.Data is RTStroke)
            {
                RTStrokeReceived((RTStroke)orea.Data);
            }
            else if (orea.Data is Page)
            {
                PageReceived((Page)orea.Data);
            }
            else if (orea.Data is RTPageAdd)
            {
                RTPageAddReceived((RTPageAdd)orea.Data);
            }
            else if (orea.Data is RTNodeChanged)
            {
                RTNodeChangedReceived(
                    (RTNodeChanged)orea.Data);
            }
            else if (orea.Data is RTDocument)
            {
                RTDocumentReceived((RTDocument)orea.Data);
            }
            else if (orea.Data is RTFrame)
            {
                RTFrameReceived((RTFrame)orea.Data);
            }
        }
        public static RTDocument PPT2RTDwithSVG(string pptFilename)
        {
            //Pri2: Investigate where BasePath is and where we should be putting it in more depth.
            //      Concerned that we're creating directories there that never get cleaned up...
            if (!Directory.Exists(tfc.BasePath))
            {
                Directory.CreateDirectory(tfc.BasePath);
            }
            // Initialize PowerPoint app
            ApplicationClass ppt = new ApplicationClass();

            ppt.Visible = MsoTriState.msoTrue;

            // Open the PPT file
            Presentation presentation = ppt.Presentations.Open(pptFilename, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            PrintOptions po           = presentation.PrintOptions;

            po.ActivePrinter = @"SVGmaker";
            System.Threading.Thread.Sleep(6000);
            po.OutputType        = PpPrintOutputType.ppPrintOutputSlides;
            po.PrintInBackground = MsoTriState.msoFalse;
            Slides slides = presentation.Slides;

            // Set up the document
            RTDocument rtDoc = new RTDocument();

            rtDoc.Identifier       = Guid.NewGuid();
            rtDoc.Metadata.Title   = GetPresentationProperty(ppt.ActivePresentation, "Title");
            rtDoc.Metadata.Creator = GetPresentationProperty(ppt.ActivePresentation, "Author");

            //Iterate through the pages
            foreach (Slide s in slides)
            {
                // Set the page properties
                Page p = new Page();
                p.Identifier = Guid.NewGuid();
                p.Extension  = GetSlideSVG(presentation, s);
                p.MimeType   = "image/svg"; // TODO: look up the real value for this
                rtDoc.Resources.Pages.Add(p.Identifier, p);

                // Set the TOCNode properties for the page
                TOCNode tn = new TOCNode();
                tn.Title              = GetSlideTitle(s);
                tn.Resource           = p;
                tn.ResourceIdentifier = p.Identifier;
                // TODO: Insert thumbnail? (tn.thumbnail)
                rtDoc.Organization.TableOfContents.Add(tn);
            }

            // Close PPT
            presentation.Close();
            if (ppt.Presentations.Count == 0)
            {
                ppt.Quit();
            }
            ppt = null;

            tfc.Delete();

            return(rtDoc);
        }
Example #15
0
        public static RTDocument PPT2RTDocument(string pptFilename)
        {
            //Pri2: Investigate where BasePath is and where we should be putting it in more depth.
            //      Concerned that we're creating directories there that never get cleaned up...
            if (!Directory.Exists(tfc.BasePath))
            {
                Directory.CreateDirectory(tfc.BasePath);
            }
            // Initialize PowerPoint app
            ApplicationClass ppt = new ApplicationClass();

            // Open the PPT file
            Presentation presentation = ppt.Presentations.Open(pptFilename, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
            Slides       slides       = presentation.Slides;

            // Set up the document
            RTDocument rtDoc = new RTDocument();

            rtDoc.Identifier       = Guid.NewGuid();
            rtDoc.Metadata.Title   = GetPresentationProperty(presentation, "Title");
            rtDoc.Metadata.Creator = GetPresentationProperty(presentation, "Author");

            // Create shared MemoryStream to minimize mem usage
            MemoryStream ms = new MemoryStream();

            //Iterate through the pages
            int i = 0;

            foreach (Slide s in slides)
            {
                // Set the page properties
                Page p = new Page();
                p.Identifier = Guid.NewGuid();
                p.Image      = GetSlideImage(s, ms);
                if (p.Image is Metafile)
                {
                    p.MimeType = "image/x-wmf";
                }
                if (p.Image is Bitmap)
                {
                    p.MimeType = "image/png";
                }
                rtDoc.Resources.Pages.Add(p.Identifier, p);

                // TODO, slice in RegionBuilder code from Presenter work...

                // Set the TOCNode properties for the page
                TOCNode tn = new TOCNode();
                tn.Title              = GetSlideTitle(s);
                tn.Resource           = p;
                tn.ResourceIdentifier = p.Identifier;
                //Pri2: Shouldn't this be a byte[] containing the PNG stream instead of a System.Drawing.Image?
                tn.Thumbnail = RTDocumentHelper.GetThumbnailFromImage(p.Image);
                rtDoc.Organization.TableOfContents.Add(tn);
                i++;
            }

            // Close PPT
            presentation.Close();
            if (ppt.Presentations.Count == 0)
            {
                ppt.Quit();
            }

            ppt = null;

            tfc.Delete();

            return(rtDoc);
        }
Example #16
0
 public static bool AddRTPageAddToRTDocument(RTDocument rtDocument, RTPageAdd rtpa)
 {
     rtDocument.Organization.TableOfContents.Add(rtpa.TOCNode);
     return(AddPageToRTDocument(rtDocument, rtpa.Page));
 }
Example #17
0
        /// <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());
            }
        }