Beispiel #1
0
        public void OpenProject(string projectFile, bool noErrorDisplay = false)
        {
            Window.ShowStatus("Opening project file...");
            ActiveProject = null;

            DocProject project = null;

            if (string.IsNullOrEmpty(projectFile))
            {
                /// TODO: Need Wizard here
                project = DocProjectManager.CreateProject(new DocProjectCreator()
                {
                    Filename      = System.IO.Path.GetFileName(projectFile),
                    ProjectFolder = System.IO.Path.GetDirectoryName(projectFile),
                    Title         = "New Project",
                    Owner         = "West Wind Technologies"
                });
            }
            else
            {
                project = DocProject.LoadProject(projectFile);
                if (project == null)
                {
                    if (!noErrorDisplay)
                    {
                        MessageBox.Show("Failed to load project.",
                                        KavaApp.ApplicationName,
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                    }
                    else
                    {
                        Window.ShowStatus("Failed to load project: " + projectFile,
                                          KavaApp.Configuration.StatusMessageTimeout);
                        Window.SetStatusIcon(FontAwesomeIcon.Warning, Colors.Red);
                    }

                    Window.ShowStatus();
                    return;
                }
            }

            Window.ShowStatus("Generating project tree...");

            ActiveProject = project;
            TopicsTree.LoadProject(project);

            PreviewTopic();

            Window.ShowStatus($"Project '{project.Title}' opened.", KavaApp.Configuration.StatusMessageTimeout);
        }
 /// <summary>
 /// Creates a new project based on given parameters
 /// </summary>
 /// <param name="creator"></param>
 /// <returns></returns>
 public static DocProject CreateProject(DocProjectCreator creator)
 {
     return(DocProjectManager.CreateProject(creator));
 }