Beispiel #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);
                        }
                    }
                }
            }
Beispiel #2
0
        //WARNING - This method assumes that all necessary sanity checks for path have been done!
        /// <summary>
        ///
        /// </summary>
        /// <param name="traversal"></param>
        /// <param name="path"></param>
        /// <param name="format"></param>
        /// <returns>a List of strings with all the names of the image files</returns>
        public static List <string> ExportDeck(DefaultDeckTraversalModel traversal, string path, System.Drawing.Imaging.ImageFormat format)
        {
            List <string> file_names = new List <string>();

            //Info here:  http://gotdotnet.com/Community/MessageBoard/Thread.aspx?id=27804
            //Iterate over all the slides
            using (Synchronizer.Lock(traversal.SyncRoot)) {
                using (Synchronizer.Lock(traversal.Deck.SyncRoot)) {
                    using (Synchronizer.Lock(traversal.Deck.TableOfContents.SyncRoot)) {
                        //Create the directory, if it doesn't already exist
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        int imageCount = 1;
                        TableOfContentsModel.Entry currentEntry = traversal.Deck.TableOfContents.Entries[0];
                        while (currentEntry != null)
                        {
                            Color background = Color.Transparent;

                            // Add the background color
                            // First see if there is a Slide BG, if not, try the Deck.  Otherwise, use transparent.
                            using (Synchronizer.Lock(currentEntry.Slide.SyncRoot)) {
                                if (currentEntry.Slide.BackgroundColor != Color.Empty)
                                {
                                    background = currentEntry.Slide.BackgroundColor;
                                }
                                else if (traversal.Deck.DeckBackgroundColor != Color.Empty)
                                {
                                    background = traversal.Deck.DeckBackgroundColor;
                                }
                            }

                            // Get the Image
                            Bitmap toExport = DrawSlide(currentEntry, background, SheetDisposition.Background | SheetDisposition.Public | SheetDisposition.Student | SheetDisposition.All);

                            // Format the imageCount
                            string number = "";
                            if (imageCount >= 0 && imageCount < 10)
                            {
                                number = "00" + imageCount;
                            }
                            else if (imageCount >= 10 && imageCount < 100)
                            {
                                number = "0" + imageCount;
                            }
                            else
                            {
                                number = "" + imageCount;
                            }
                            string file_name = traversal.Deck.HumanName + number + ".jpg";
                            toExport.Save(path + "\\" + file_name, format);

                            /// Save the file name to our list
                            file_names.Add(file_name);

                            imageCount++;

                            // Done, get next entry
                            currentEntry = traversal.FindNext(currentEntry);

                            // Cleanup
                            toExport.Dispose();
                        }
                    }
                }
            }
            return(file_names);
        }
Beispiel #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);
                        }
                    }
                }
            }