Beispiel #1
0
        public void ImportMarkdownMonsterHb5()
        {
            string outputFolder = @"c:\temp\markdownmonster_help";

            if (Directory.Exists(outputFolder))
            {
                try
                {
                    Directory.Delete(outputFolder);
                }
                catch { }
            }

            var importer = new HelpBuilder5JsonImporter();

            Assert.True(importer.ImportHbp(@"C:\Users\rstrahl\Documents\Html Help Builder Projects\markdownmonster\markdownmonster-10-01-18.json", outputFolder));
        }
Beispiel #2
0
        public void ImportHb5WestwindUtilities()
        {
            string outputFolder = @"C:\temp\Westwind.Utilities_help";

            if (Directory.Exists(outputFolder))
            {
                try
                {
                    Directory.Delete(outputFolder);
                }
                catch { }
            }

            var importer = new HelpBuilder5JsonImporter();

            Assert.True(importer.ImportHbp(@"C:\Users\rstrahl\Documents\Html Help Builder Projects\Westwind.Toolkit\westwind.toolkit_help.json", outputFolder));
        }
Beispiel #3
0
        public void ImportWebSurgeHb5()
        {
            string outputFolder = @"c:\temp\websurge_help";

            if (Directory.Exists(outputFolder))
            {
                try
                {
                    Directory.Delete(outputFolder);
                }
                catch { }
            }

            var importer = new HelpBuilder5JsonImporter();

            Assert.True(importer.ImportHbp(@"C:\Users\rstrahl\Documents\Html Help Builder Projects\west wind websurge\west wind websurge.json",
                                           outputFolder, KavaDocsAddinPath));
        }
        private void Button_ImportFromHelpBuilder(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog()
            {
                DefaultExt = ".json",
                Filter     = "JSON files (*.json)|*.json|" +
                             "All files (*.*)|*.*",
                CheckFileExists  = true,
                RestoreDirectory = true,
                Multiselect      = false,
                Title            = "Open Help Builder JSON Export File"
            };

            var result = openFileDialog.ShowDialog(this);

            if (!result.Value)
            {
                return;
            }

            var inputJsonFile = openFileDialog.FileName;

            if (string.IsNullOrEmpty(ProjectCreator.ProjectFolder))
            {
                var dlg = new CommonOpenFileDialog()
                {
                    Title            = "Select folder for new KavaDocs Project",
                    IsFolderPicker   = true,
                    RestoreDirectory = true,
                    ShowPlacesList   = true,
                    Multiselect      = false,
                    EnsureValidNames = false,
                    EnsureFileExists = false,
                    EnsurePathExists = false
                };

                if (!string.IsNullOrEmpty(kavaUi.Configuration.LastProjectFile))
                {
                    dlg.InitialDirectory = System.IO.Path.GetDirectoryName(kavaUi.Configuration.LastProjectFile);
                }
                else
                {
                    dlg.InitialDirectory = kavaUi.Configuration.DocumentsFolder;
                }

                var res = dlg.ShowDialog();

                if (res != CommonFileDialogResult.Ok)
                {
                    return;
                }

                ProjectCreator.ProjectFolder = dlg.FileName;
            }



            if (Directory.Exists(ProjectCreator.ProjectFolder) && Directory.GetFiles(ProjectCreator.ProjectFolder).Length > 0)
            {
                if (MessageBox.Show(
                        "The output folder exists already. The folder to create a new project has to be empty, so either delete the folder or pick a different one.\r\n\r\n" +
                        "Do you want to continue and delete the existing folder?", "New Project Folder exists already",
                        MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) != MessageBoxResult.Yes)
                {
                    return;
                }

                try
                {
                    Directory.Delete(ProjectCreator.ProjectFolder, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Failed to delete output folder:\r\n{ex.Message}");
                    return;
                }
            }

            var importer = new HelpBuilder5JsonImporter
            {
                Title = ProjectCreator.Title,
                Owner = ProjectCreator.Owner
            };

            if (!importer.ImportHbp(inputJsonFile, ProjectCreator.ProjectFolder, KavaDocsConfiguration.Current.HomeFolder))
            {
                MessageBox.Show($"Couldn't create new project from import file.");
                return;
            }

            Close();

            if (!string.IsNullOrEmpty(ProjectCreator.Owner))
            {
                kavaUi.Configuration.LastProjectCompany = ProjectCreator.Owner;
            }

            kavaUi.AddinModel.OpenProject(System.IO.Path.Combine(ProjectCreator.ProjectFolder, "_toc.json"));
        }