Example #1
0
            protected override void OnClick(EventArgs e)
            {
                base.OnClick(e);
                FolderBrowserDialog fbd = new FolderBrowserDialog();

                fbd.RootFolder = System.Environment.SpecialFolder.Desktop;
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    //TODO: Prompt for a file format

                    //Execute
                    using (this.m_Model.Workspace.Lock()) {
                        DeckTraversalModel        traversal = this.m_Model.Workspace.CurrentDeckTraversal;
                        DefaultDeckTraversalModel ddt       = traversal as DefaultDeckTraversalModel;
                        if (ddt == null)
                        {
                            LinkedDeckTraversalModel linked = traversal as LinkedDeckTraversalModel;
                            if (linked != null)
                            {
                                ddt = linked.LinkedModel as DefaultDeckTraversalModel;
                            }
                        }

                        if (ddt != null)
                        {
                            //PPTDeckIO.ExportDeck( ddt, fbd.SelectedPath, System.Drawing.Imaging.ImageFormat.Jpeg );
                            PPTDeckIO.ExportDeck(ddt, fbd.SelectedPath, System.Drawing.Imaging.ImageFormat.Png);
                        }
                    }
                }
            }
Example #2
0
        /// <summary>
        /// Draw the slide for printing.
        /// Note: This code first prints to an image and then to the page to allow for transparency and anti-aliasing
        /// </summary>
        /// <param name="traversal">The deck traversal to draw from</param>
        /// <param name="index">The slide index in the deck to draw</param>
        /// <param name="displayBounds">The bounds to draw the slide in</param>
        /// <param name="g">The graphics context to draw onto</param>
        private void DrawSlide3(DeckTraversalModel traversal, int index, System.Drawing.Rectangle displayBounds, System.Drawing.Graphics g)
        {
            using (Synchronizer.Lock(traversal.SyncRoot)) {
                using (Synchronizer.Lock(traversal.Deck.SyncRoot)) {
                    using (Synchronizer.Lock(traversal.Deck.TableOfContents.SyncRoot)) {
                        TableOfContentsModel.Entry currentEntry = traversal.Deck.TableOfContents.Entries[index];

                        // Get the background color and background template
                        Color background            = Color.Transparent;
                        BackgroundTemplate template = null;
                        using (Synchronizer.Lock(currentEntry.Slide.SyncRoot)) {
                            if (currentEntry.Slide.BackgroundTemplate != null)
                            {
                                template = currentEntry.Slide.BackgroundTemplate;
                            }
                            else if (traversal.Deck.DeckBackgroundTemplate != null)
                            {
                                template = traversal.Deck.DeckBackgroundTemplate;
                            }
                            if (currentEntry.Slide.BackgroundColor != Color.Empty)
                            {
                                background = currentEntry.Slide.BackgroundColor;
                            }
                            else if (traversal.Deck.DeckBackgroundColor != Color.Empty)
                            {
                                background = traversal.Deck.DeckBackgroundColor;
                            }
                        }

                        Bitmap toExport = PPTDeckIO.DrawSlide(currentEntry, template, background, SheetDisposition.Background | SheetDisposition.Public | SheetDisposition.Student | SheetDisposition.All);

                        Rectangle newRect = FillUpRectangle(displayBounds, new Rectangle(0, 0, toExport.Width, toExport.Height));
                        this.DrawSlideBorder(index + 1, newRect, g);
                        g.DrawImage(toExport, newRect);
                        toExport.Dispose();
                    }
                }
            }
        }
Example #3
0
            /// <summary>
            /// popus up a save dialogue, then creates a folder in the specified
            /// path containing an HTML file, along with images.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnClick(EventArgs e)
            {
                base.OnClick(e);

                // Choose a destination folder and file name
                SaveFileDialog exportDeckToHTMLDialog = new SaveFileDialog();

                exportDeckToHTMLDialog.Title  = "Name the new html file and folder";
                exportDeckToHTMLDialog.Filter = "HTML files (*.html;*.htm)|*.html;*.htm";
                string humanName = "";

                //set default name
                using (this.model_.Workspace.Lock()) {
                    using (Synchronizer.Lock((~this.model_.Workspace.CurrentDeckTraversal).SyncRoot)) {
                        using (Synchronizer.Lock((~this.model_.Workspace.CurrentDeckTraversal).Deck.SyncRoot)) {
                            if ((~this.model_.Workspace.CurrentDeckTraversal).Deck.Filename != "")
                            {
                                humanName = exportDeckToHTMLDialog.FileName = (~this.model_.Workspace.CurrentDeckTraversal).Deck.Filename;
                            }
                            else
                            {
                                humanName = exportDeckToHTMLDialog.FileName = (~this.model_.Workspace.CurrentDeckTraversal).Deck.HumanName;
                            }
                        }
                    }
                }
                ///Create a folder with the HTML file as well as the corresponding image
                ///files.
                if (exportDeckToHTMLDialog.ShowDialog() == DialogResult.OK)
                {
                    ///name of user's HTML file
                    string file_name = exportDeckToHTMLDialog.FileName;
                    ///name of folder that will hold the HTML files
                    string folder_name = Path.GetFullPath(file_name).Replace(Path.GetExtension(file_name), "") + "_files";


                    ///export the slide images to the folder
                    List <string> file_names;
                    using (this.model_.Workspace.Lock()) {
                        DeckTraversalModel        traversal = this.model_.Workspace.CurrentDeckTraversal;
                        DefaultDeckTraversalModel ddt       = traversal as DefaultDeckTraversalModel;
                        if (ddt == null)
                        {
                            LinkedDeckTraversalModel linked = traversal as LinkedDeckTraversalModel;
                            if (linked != null)
                            {
                                ddt = linked.LinkedModel as DefaultDeckTraversalModel;
                            }
                        }

//                        file_names = PPTDeckIO.ExportDeck(ddt, folder_name, System.Drawing.Imaging.ImageFormat.Jpeg);
                        file_names = PPTDeckIO.ExportDeck(ddt, folder_name, System.Drawing.Imaging.ImageFormat.Png);
                    }

                    ///export row/column icons
                    if (ExportFancy)
                    {
                        UW.ClassroomPresenter.Properties.Resources.singleslide.Save(folder_name + "\\singleslide.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                        UW.ClassroomPresenter.Properties.Resources.doubleslide.Save(folder_name + "\\doubleslide.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                    }

                    ///Now, all of the images are in the specified folder, so we just need to make
                    ///the HTML file for them
                    string html = BuildHtml(file_names, folder_name, 1, file_name, humanName);
                    if (!ExportFancy)
                    {
                        using (StreamWriter my_stream = new StreamWriter(file_name)) {
                            my_stream.Write(html);
                        }
                    }
                    else
                    {
                        using (StreamWriter my_stream = new StreamWriter(file_name.Insert(file_name.LastIndexOf('.'), "_1"))) {
                            my_stream.Write(html);
                        }
                        html = BuildHtmlTable(file_names, folder_name, 2, file_name, humanName);
                        using (StreamWriter my_stream = new StreamWriter(file_name.Insert(file_name.LastIndexOf('.'), "_2"))) {
                            my_stream.Write(html);
                        }
                    }
                }
            }