예제 #1
0
        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;
        }
예제 #2
0
        object ICloneable.Clone()
        {
            RTDocument rtD = new RTDocument();

            rtD.identifier = identifier;
            rtD.Metadata   = (Metadata)((ICloneable)Metadata).Clone();
            // Need to be sure to clone resources first because Organization refers to Resources...
            rtD.Resources    = (Resources)((ICloneable)Resources).Clone();
            rtD.Organization = (Organization)((ICloneable)Organization).Clone();

            return(rtD);
        }
예제 #3
0
        object ICloneable.Clone()
        {
            RTDocument rtD = new RTDocument();

            rtD.identifier = identifier;
            rtD.Metadata = (Metadata)((ICloneable)Metadata).Clone();
            // Need to be sure to clone resources first because Organization refers to Resources...
            rtD.Resources = (Resources)((ICloneable)Resources).Clone();
            rtD.Organization = (Organization)((ICloneable)Organization).Clone();

            return rtD;
        }
예제 #4
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;
        }
예제 #5
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() );
                }
            }
        }
예제 #6
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 override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if(presentationCapability == null)
            {
                presentationCapability = (PresentationCapability)capability;
                presentationCapability.ObjectReceived += new CapabilityObjectReceivedEventHandler(ObjectReceived);

                // Init StatusBar
                statusBar.SetBusyStatusMessage(Strings.Loading);

                // Init ThumbnailsListView
                this.thumbnailsView.ImageSelected += new System.EventHandler(this.thumbnailsView_SelectedImageChanged);
                this.thumbnailsView.ImageMouseEnter += new EventHandler(thumbnailsView_ImageMouseEnter);
                this.thumbnailsView.ImageMouseLeave +=new EventHandler(thumbnailsView_ImageMouseLeave);
                Size pbSize = new Size(thumbnailsView.ClientRectangle.Width - 55, 0);
                pbSize.Height = (int)( ((float)pbSize.Width)*(3F/4F) );

                // Create blank RTDocument
                this.rtDocument = new RTDocument();
                rtDocument.Identifier = new Guid(constWhiteboardGuid);
                rtDocument.Metadata.Title = Strings.WhiteboardSession;
                rtDocument.Metadata.Creator = Conference.LocalParticipant.Name;
            
                // Add a blank page
                Page pg = new Page();
                pg.Identifier = new Guid(constWhiteboardGuid);
                TOCNode tn = new TOCNode();
                tn.Title = Strings.Whiteboard1;
                tn.Resource = pg;
                tn.ResourceIdentifier = pg.Identifier;
                tn.Identifier = new Guid(constWhiteboardGuid);
                rtDocument.Organization.TableOfContents.Add(tn);
                rtDocument.Resources.Pages.Add(pg.Identifier, pg);

                // Wrap the RTD with a helper & init vars
                rtDocumentHelper = new RTDocumentHelper( presentationCapability, rtDocument );
                rtDocumentHelper.CurrentOrganizationNodeIdentifier = tn.Identifier;
                statusBar.SetMaxPage( 1, rtDocument.Organization.TableOfContents.Count );
                thumbnailsView.InsertThumbnail(null, tn.Title, 0, tn.Identifier);
                thumbnailsView.SelectedIndex = 0;
                this.pageShowing = pg.Identifier;
            }
        }
        /// <summary>
        /// Save all pages in the RTDocument to PNG files at the specified path.  Existing files will be overwritten.
        /// </summary>
        /// <param name="rtd"></param>
        /// <param name="path"></param>
        private void saveRTDocument(RTDocument rtd, string path) {
            if (rtd == null) {
                Debug.WriteLine("RTDocument is null");
                return;
            }

            if (rtd.Organization.TableOfContents.Length <= 0) {
                Debug.WriteLine("RTDocument contains zero pages");
                return;
            }

            //Make sure ink on the current page is stored before we proceed
            if ((inkOverlay != null) && (inkOverlay.Ink.Strokes.Count > 0)) {
                StoreInk(pageShowing);
            }

            //Create directory.  Does nothing if the directory exists.
            Directory.CreateDirectory(path);

            int pagecount = rtd.Organization.TableOfContents.Length;
            int i = 1;
            foreach (TOCNode n in rtd.Organization.TableOfContents) {
                Page p = rtd.Resources.Pages[n.ResourceIdentifier];
                //Make a file name for the current image.
                String pngfile = Path.Combine(path, "page" + i.ToString() + ".png");

                Image img = null;
                if ((p != null) && (p.Image != null)) {
                    //Slide image or screen shot: Scale to size with maximum dimension to 960.
                    int w = 960;
                    int h = 960;
                    double ar = ((double)p.Image.Width) / ((double)p.Image.Height);
                    if (ar >= 1.0) { 
                        //width is the larger dimension.
                        h = (int)Math.Round(960.0 / ar);
                    }
                    else { 
                        //height is the larger dimension.
                        w = (int)Math.Round(960.0 * ar);
                    }
                    img = new Bitmap(p.Image, new Size(w,h));
                }
                else {
                    //Whiteboard: make a white 4x3 white image
                    img = new Bitmap(960,720);
                    Graphics g = Graphics.FromImage(img);
                    SolidBrush whiteBrush = new SolidBrush(Color.White);
                    g.FillRectangle(whiteBrush, 0, 0, img.Width, img.Height);
                    whiteBrush.Dispose();
                    g.Dispose();
                }                

                //Add ink and save
                AddInkOverlay(img, p.Identifier);
                img.Save(pngfile, ImageFormat.Png);
                img.Dispose();
                i++;
            }
        }
        /// <summary>
        /// Open a file in local rtd file name.
        /// </summary>
        /// <param name="fileName">filename (path + filename)</param>
        // Pri3: There is a lot of duplication of code between openLocalFile
        // and miOpenRemote_Click method that could be written just once
        // If this code is going to stay in long term we should change that
        private void openLocalFile(string fileName)
        {
            try
            {
                // Open a RTD file
                lock(this)
                {
                    rtDocument = LoadRtdFile(fileName);
                }
                if (rtDocument == null)
                {
                    return;
                }

                // Update the title bar of the form 
                // with the document name followed by the capability name
                this.Text = rtDocument.Metadata.Title + " - " + this.presentationCapability.Name;

                DisplayRTDocumentOnlyStructureInfo();
                rtDocumentHelper = new RTDocumentHelper(this.presentationCapability, rtDocument);

                DisplayRTDocumentStructureInfo();

                #region Populate thumbnails
                ArrayList thumbnails = new ArrayList();

                using (Bitmap bp = new Bitmap( thumbnailsView.ImageSize.Width, thumbnailsView.ImageSize.Height, 
                           System.Drawing.Imaging.PixelFormat.Format24bppRgb))
                {
                    using (Graphics g = Graphics.FromImage(bp))
                    {
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                        foreach( TOCNode tn in rtDocument.Organization.TableOfContents )
                        {
                            Page p = (Page)tn.Resource;

                            ThumbnailListView.CreateSlideThumbnail( thumbnailsView.ImageSize,
                                p.Image, g, tn.Title );

                            ThumbnailListViewItem item = new ThumbnailListViewItem();
                            item.thumbnail = ((Bitmap)bp.Clone());
                            item.tag = tn.Identifier;
                            thumbnails.Add(item);
                        }
                    }
                }

                thumbnailsView.Items = (ThumbnailListViewItem[])thumbnails.ToArray(typeof(ThumbnailListViewItem));
                #endregion

                // Initialize the index on the first slide
                index = 0;

                // Show the current page
                statusBar.SetMaxPage( 1, rtDocument.Organization.TableOfContents.Count );
                ShowPage(rtDocument.Organization.TableOfContents[index].Identifier);

                // Display the current page on the sender and viewer
                UpdateCurrentPage();
                UpdateNavigationButtonState();
            }
            catch(Exception ex) 
            {
                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, Strings.ErrorInOpening, 
                    fileName,ex.Message.ToString()), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, 
                    MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                return;
            }
        }
        // Pri2: All the code in this region is temporary

        // The code in this region allows to request remote capability to open a 
        // rtd file located in the same place than the one open by the initiator

        // The Open Remote menu has to be explicitely activated using the 
        // application configuration key
        // MSR.LST.ConferenceXP.Capability.Presentation.OpenRemote

        /// <summary>
        /// Menu item miOpenRemote_Click event handler. Open a remote rtd file.
        /// When you open a file using this menu, the exact same rtd file has to be
        /// at at the same location on every remote machine 
        /// </summary>
        /// <param name="sender">The event sender object</param>
        /// <param name="e">The event arguments</param>
        private void miOpenRemote_Click(object sender, System.EventArgs e)
        {
            System.Windows.Forms.OpenFileDialog cdlg = new OpenFileDialog();
            cdlg.Filter = "RTDocument files (*.rtd)|*.rtd" ;
            DialogResult dr = cdlg.ShowDialog();

            try
            {
                if (dr == DialogResult.OK)
                {
                    string fileName = cdlg.FileName;

                    if (System.IO.Path.GetExtension(fileName).ToLower(CultureInfo.InvariantCulture) == ".rtd")
                    {
                        // Open a RTD file
                        lock(this)
                        {
                            rtDocument = LoadRtdFile(fileName);
                        }
                        if (rtDocument == null)
                        {
                            return;
                        }
                    } 
                    else
                    {
                        RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, 
                            Strings.ErrorInOpeningFileType, fileName), string.Empty, MessageBoxButtons.OK, 
                            MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                        return;
                    }

                    Log(string.Format(CultureInfo.CurrentCulture, "rtDocID = {0}", 
                        rtDocument.Identifier.ToString()));

                    // Update the title bar of the form 
                    // with the document name followed by the capability name
                    this.Text = rtDocument.Metadata.Title + " - " + this.presentationCapability.Name;

                    // Clean up the screen
                    DeleteAllStrokes();

                    Log("On open doc: info before creating RTDocHelper,");
                    DisplayRTDocumentOnlyStructureInfo();
                    rtDocumentHelper = new RTDocumentHelper(this.presentationCapability, rtDocument);

                    Log("Structure Info on open after creating RTDocHelper,");
                    DisplayRTDocumentStructureInfo();

                    #region Populate thumbnails
                    ArrayList thumbnails = new ArrayList();

                    using (Bitmap bp = new Bitmap( thumbnailsView.ImageSize.Width, thumbnailsView.ImageSize.Height, 
                               System.Drawing.Imaging.PixelFormat.Format24bppRgb))
                    {
                        using (Graphics g = Graphics.FromImage(bp))
                        {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                            foreach( TOCNode tn in rtDocument.Organization.TableOfContents )
                            {
                                Page p = (Page)tn.Resource;

                                ThumbnailListView.CreateSlideThumbnail( thumbnailsView.ImageSize,
                                    p.Image, g, tn.Title );

                                ThumbnailListViewItem item = new ThumbnailListViewItem();
                                item.thumbnail = ((Bitmap)bp.Clone());
                                item.tag = tn.Identifier;
                                thumbnails.Add(item);
                            }
                        }
                    }

                    thumbnailsView.Items = (ThumbnailListViewItem[])thumbnails.ToArray(typeof(ThumbnailListViewItem));
                    #endregion

                    // Initialize the index on the first slide
                    index = 0;

                    // Show the current page
                    statusBar.SetMaxPage( 1, rtDocument.Organization.TableOfContents.Count );
                    ShowPage(rtDocument.Organization.TableOfContents[index].Identifier);

                    // Send a message to request the remote users to open the rtd file
                    // fileName
                    SendRemoteFileOpen(fileName);

                    // Update the Backward/Forward buttons (push the navigation button in the 
                    // direction(s)that you cannot move anymore)
                    UpdateNavigationButtonState();

                    // Display the current page on the sender and viewer
                    UpdateCurrentPage();
                }
            }
            catch(Exception ex) 
            {
                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, Strings.ErrorInOpening, 
                    cdlg.FileName, ex.Message.ToString()), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, 
                    MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                return;
            }
        }
        /// <summary>
        /// This method allows the initiator to open a .ppt or .rtd file.
        /// After the file is open, all the slides are sent to the client(s) and the
        /// client(s) are positionned to the same page than the initiator.
        /// </summary>
        /// <remarks>If you open a .ppt file, a corresponding .rtd file is automatically 
        /// created with the same name and saved in the same folder. If there is an 
        /// existing .rtd file with the same name in  this folder, it will be overwrited</remarks>
        /// <param name="fileMenu">This parameter is for extensibility. The only value so far
        /// is OpenSlideDeck</param>
        private void openFile()
        {
            System.Windows.Forms.OpenFileDialog cdlg = new OpenFileDialog();
            cdlg.Filter = "All Presentation Documents (*.ppt, *.pptx, *.rtd)|" +
                "*.ppt;*.pptx;*.rtd|PowerPoint document files (*.ppt,*.pptx)|*.ppt;*.pptx|RTDocument files (*.rtd)|*.rtd" ;
            DialogResult dr = cdlg.ShowDialog();

            try
            {
                if (dr == DialogResult.OK)
                {
                    string fileName = cdlg.FileName;
                    string extension = System.IO.Path.GetExtension(fileName).ToLower(CultureInfo.InvariantCulture);

                    if (extension == ".ppt" || extension == ".pptx")
                    {
                        #region Open a PPT file
                        lock(this)
                        {
                            statusBar.SetWaitStatusMessage(Strings.ImportingPowerpointDocument);

                            rtDocument = PPTConversion.PPT2RTDocument(fileName);

                            // Autosave the PPT document a RTD document in the same directory as PPT
                            string outFileName = fileName.Substring(0, 
                                fileName.Length - extension.Length) + ".rtd";

                            FileStream fs = new FileStream(outFileName, FileMode.Create);
                            BinaryFormatter bf = new BinaryFormatter();
                            bf.Serialize(fs, rtDocument);
                            fs.Close();

                            statusBar.SetReadyStatusMessage();
                        }
                        #endregion
                    }
                    else if (extension == ".rtd")
                    {
                        #region Open a RTD file
                        lock(this)
                        {
                            BinaryFormatter myBinaryFormat = new BinaryFormatter();
                            try 
                            {
                                FileStream myInputStream = System.IO.File.OpenRead(fileName);
                                rtDocument = (RTDocument) myBinaryFormat.Deserialize(myInputStream);
                            }
                            catch (Exception)
                            {
                                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, 
                                    Strings.ErrorInOpeningVersion, fileName), string.Empty, MessageBoxButtons.OK, 
                                    MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                                return;
                            }
                        }
                        #endregion
                    } 
                    else
                    {
                        RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, 
                            Strings.ErrorInOpeningFileType, fileName), string.Empty, MessageBoxButtons.OK, 
                            MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                        return;
                    }

                    Log(string.Format(CultureInfo.CurrentCulture, "rtDocID = {0}", rtDocument.Identifier.ToString()));

                    // Update the title bar of the form 
                    // with the document name followed by the capability name
                    this.Text = rtDocument.Metadata.Title + " - " + this.presentationCapability.Name;

                    // Clean up the screen
                    DeleteAllStrokes();

                    Log("On open doc: info before creating RTDocHelper,");
                    DisplayRTDocumentOnlyStructureInfo();
                    rtDocumentHelper = new RTDocumentHelper(this.presentationCapability, rtDocument);

                    Log("Structure Info on open after creating RTDocHelper,");
                    DisplayRTDocumentStructureInfo();

                    #region Populate thumbnails
                    ArrayList thumbnails = new ArrayList();

                    using (Bitmap bp = new Bitmap( thumbnailsView.ImageSize.Width, thumbnailsView.ImageSize.Height, 
                               System.Drawing.Imaging.PixelFormat.Format24bppRgb))
                    {
                        using (Graphics g = Graphics.FromImage(bp))
                        {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                            foreach( TOCNode tn in rtDocument.Organization.TableOfContents )
                            {
                                Page p = (Page)tn.Resource;

                                ThumbnailListView.CreateSlideThumbnail( thumbnailsView.ImageSize,
                                    p.Image, g, tn.Title );

                                ThumbnailListViewItem item = new ThumbnailListViewItem();
                                item.thumbnail = ((Bitmap)bp.Clone());
                                item.tag = tn.Identifier;
                                thumbnails.Add(item);
                            }
                        }
                    }

                    thumbnailsView.Items = (ThumbnailListViewItem[])thumbnails.ToArray(typeof(ThumbnailListViewItem));
                    #endregion

                    // Initialize the index on the first slide
                    index = 0;

                    // Show the current page
                    statusBar.SetMaxPage( 1, rtDocument.Organization.TableOfContents.Count );
                    ShowPage(rtDocument.Organization.TableOfContents[index].Identifier);

                    if( presentationCapability.IsSender )
                    {
                        EnableSlideSend(false);
                        statusBar.StatusMessage = Strings.SendingSlides;

                        rtDocumentHelper.BeginSendAllSlides(new AsyncCallback(SlidesSent), null);
                    }

                    // Update the Backward/Forward buttons (push the navigation button in the 
                    // direction(s)that you cannot move anymore)
                    UpdateNavigationButtonState();
                }
            }
            catch(Exception ex) 
            {
                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, Strings.ErrorInOpening, 
                    cdlg.FileName, ex.Message.ToString()), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, 
                    MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                return;
            }
        }
        /// <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)
        {
            Log("It's an RTDocument object,");

            // Set the rtDocument only if you receive a new document (not a repeat)
            if( (rtDocument == null) || (!rtDocReceived.Identifier.Equals(rtDocument.Identifier)) )
            {
                // Clean up the screen
                DeleteAllStrokes();

                Image tempImg = pbRTDoc.Image;
                pbRTDoc.Image = null;
                if( tempImg != null )
                    tempImg.Dispose();

                Log("The document received is different than the one already open!");
                rtDocument = rtDocReceived;

                Log(string.Format(CultureInfo.CurrentCulture, "rtDocID in RTDocumentReceived method: {0}", 
                    rtDocument.Identifier.ToString()));

                Log("Info before creating RTDocHelper,");
                DisplayRTDocumentOnlyStructureInfo();

                rtDocumentHelper = new RTDocumentHelper( presentationCapability, rtDocument );

                // Pri2: is crntPage == 0 correct??
                statusBar.SetMaxPage( 0, rtDocument.Organization.TableOfContents.Count );

                statusBar.StatusMessage = string.Format(CultureInfo.CurrentCulture, Strings.ReceivingPage_of_, 
                    rtDocument.Organization.TableOfContents.Count.ToString(CultureInfo.InvariantCulture)); 

                thumbnailsView.Items = new ThumbnailListViewItem[0];

                // Update the title bar of the form 
                this.Text = rtDocument.Metadata.Title + " - " + presentationCapability.Name;

                Log("Doc organization received:");
                DisplayRTDocumentStructureInfo();

                // Initialize the received page counter
                pageReceivedCounter = 0;

                if( this.cachedPages != null )
                {
                    // In the odd case that we have pages waiting, and the wrong TOC is received,
                    //  we'll try to add all the pages, fail, and then just discard them all.
                    for( int cnt = cachedPages.Count; cnt > 0; --cnt )
                    {
                        this.PageReceived( (Page)cachedPages.Dequeue() );
                    }

                    this.cachedPages = null;
                }
            }
        }