Example #1
0
        /// <summary>
        ///     Handles the export file clicked event.
        /// </summary>
        private void HandleExportFileEvent()
        {
            if (Core.Model.Instance.Compilation != null) //there is any?
            {
                // Displays a ExportFileDialog so the user can export the compilaton
                using (SaveFileDialog exportFileDialog = new SaveFileDialog {
                    Filter = "Quirli compilation (EXPERIMENTAL)|*.html",
                    Title = "Export the compilation to a location.",
                    InitialDirectory = Core.Model.Instance.Settings.DefaultCompilationLookupDirectory,
                    FileName = EncodeFileName(Core.Model.Instance.Compilation.Title) + ".html"
                }) {
                    exportFileDialog.ShowDialog();
                    // If the file name is not an empty string open it for exporting.
                    if (exportFileDialog.FileName != "")
                    {
                        // Exports the compilation in the appropriate format based upon the
                        // File type selected in the dialog box.
                        // NOTE that the FilterIndex property is one-based.
                        switch (exportFileDialog.FilterIndex)
                        {
                        case 1:                                                                 //Quirli

                            if (Core.Model.Instance.Compilation.Type != CompilationType.Quirli) //conversion needed?
                            {
                                CompilationFactory.Convert(Core.Model.Instance.Compilation, CompilationType.Quirli)
                                .Store(exportFileDialog.FileName);
                            }
                            break;
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        ///     Handles the save file as event.
        /// </summary>
        private void HandleSaveFileAsEvent()
        {
            if (Core.Model.Instance.Compilation != null) //there is any?
            {
                // Displays a SaveFileDialog so the user can save the compilaton
                using (SaveFileDialog saveFileDialog = new SaveFileDialog {
                    Filter = "Zip compilation|*.rez|XML compilation|*.rex|Quirli compilation (EXPERIMENTAL)|*.html",
                    Title = "Save a compilation to a new location.",
                    InitialDirectory =
                        Core.Model.Instance.Settings.DefaultCompilationLookupDirectory
                }) {
                    saveFileDialog.ShowDialog();
                    // If the file name is not an empty string open it for saving.
                    if (saveFileDialog.FileName != "")
                    {
                        // Saves the compilation in the appropriate format based upon the
                        // File type selected in the dialog box.
                        // NOTE that the FilterIndex property is one-based.
                        switch (saveFileDialog.FilterIndex)
                        {
                        case 1:                                                              //ZIP

                            if (Core.Model.Instance.Compilation.Type != CompilationType.Zip) //conversion needed?
                            {
                                Core.Model.Instance.Compilation =
                                    CompilationFactory.Convert(Core.Model.Instance.Compilation, CompilationType.Zip);
                            }
                            break;

                        case 2:                                                              //XML

                            if (Core.Model.Instance.Compilation.Type != CompilationType.Xml) //conversion needed?
                            {
                                Core.Model.Instance.Compilation =
                                    CompilationFactory.Convert(Core.Model.Instance.Compilation, CompilationType.Xml);
                            }
                            break;

                        case 3:                                                                 //Quirli

                            if (Core.Model.Instance.Compilation.Type != CompilationType.Quirli) //conversion needed?
                            {
                                Core.Model.Instance.Compilation =
                                    CompilationFactory.Convert(Core.Model.Instance.Compilation, CompilationType.Quirli);
                            }
                            break;
                        }
                        Core.Model.Instance.Compilation.Store(saveFileDialog.FileName);
                        //save the eventually converted session to the specified filename now
                        Core.Model.Instance.Settings.DefaultCompilationLookupDirectory =
                            Path.GetDirectoryName(saveFileDialog.FileName);
                    }
                }
            }
        }
        public void IntegrationTestThat_LoadsAZipCompilationAndConvertsItIntoATiddlyWikiCompilation()
        {
            //load the original compilation
            ICompilation compilation = CompilationFactory.Retrieve(@"Spezial-PB Compilation 2010.zip");

            //convert to target type
            var targetCompilation = CompilationFactory.Convert <TiddlyWikiCompilation>(compilation);

            //save target compilation
            targetCompilation.Store();

            Assert.IsTrue(File.Exists(@"Spezial-PB Compilation 2010.html"));

            //open for visual inspection
            String firefoxPath = @"C:\Documents and Settings\All Users\Desktop\PortableApps\FirefoxPortable\FirefoxPortable.exe";

            Process.Start(firefoxPath, @"file:///" + @"""" + (Path.GetFullPath(@"Spezial-PB Compilation 2010.html")) + @"""");
        }
Example #4
0
        public void StoreTest_TestsWhetherAnXmlCompilationCanBeStoredAsHtmlCompilation()
        {
            //load the original xml compilation
            ICompilation xmlCompilation = CompilationFactory.Retrieve(@"Spezial-PB Compilation 2010_ModifiedFileNames.xml");

            //convert to html
            HtmlCompilation htmlCompilation = CompilationFactory.Convert <HtmlCompilation>(xmlCompilation);


            //save html compilation
            htmlCompilation.Store();

            Assert.IsTrue(File.Exists(@"Spezial-PB Compilation 2010_ModifiedFileNames.html"));


            //open for visual inspection
            String firefoxPath = @"C:\Documents and Settings\All Users\Desktop\PortableApps\FirefoxPortable\FirefoxPortable.exe";

            Process.Start(firefoxPath, @"file:///" + @"""" + (Path.GetFullPath(@"Spezial-PB Compilation 2010_ModifiedFileNames.html")) + @"""");
        }