예제 #1
0
        void UpdateMovedTopic(DocTopic topic)
        {
            // TODO: Get latest changes from Editor
            var editorTopic = Model.MarkdownMonsterModel.ActiveEditor?.Properties[Constants.EditorPropertyNames.KavaDocsTopic] as DocTopic;

            if (editorTopic == topic)
            {
                topic.Body = Model.MarkdownMonsterModel.ActiveEditor.GetMarkdown();
            }
            else
            {
                // TODO: Check if the topic is open in another tab
                var tab = Model.MarkdownMonsterModel.Window.GetTabFromFilename(topic.GetTopicFileName());
                if (tab != null)
                {
                    topic = (tab.Tag as MarkdownDocumentEditor)?.Properties[Constants.EditorPropertyNames.KavaDocsTopic] as DocTopic;
                    if (topic != null)
                    {
                        topic.Body = Model.MarkdownMonsterModel.ActiveEditor.GetMarkdown();
                    }
                }
                else
                {
                    topic.LoadTopicFile(); // get latest from disk
                }
            }

            // delete the old file
            topic.DeleteTopicFile();  // delete in old location

            // create new link and slug
            topic.CreateRelativeSlugAndLink();
            topic.SaveTopicFile();  // write in new location
        }
        public void TopicParserParseAssemblyTest()
        {
            var assemblyFile =
                @"C:\projects2010\Westwind.Utilities\Westwind.Utilities\bin\Release\net46\Westwind.Utilities.dll";

            var proj = DocProjectManager.Current.LoadProject(TestConfiguration.Current.Paths
                                                             .projectMarkdownMonsterHelpFile);

            var topic = new DocTopic(proj)
            {
                Title       = "Class Reference",
                DisplayType = "header",
            };

            topic.CreateRelativeSlugAndLink(topic);
            topic.Body = "Class Reference for " + assemblyFile;
            proj.Topics.Add(topic);
            topic.SaveTopicFile();

            var parser = new DocHound.Importer.TypeTopicParser(proj, topic)
            {
                NoInheritedMembers = true,
                ClassesToImport    = null
            };

            parser.ParseAssembly(assemblyFile, topic, true);
            proj.SaveProject();
        }
        public bool SaveProjectFileForTopic(DocTopic topic, DocProject project = null)
        {
            if (topic == null)
            {
                return(false);
            }

            if (!topic.TopicState.IsDirty)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(topic.TopicState.OldLink) && topic.TopicState.OldLink != topic.Link)
            {
                if (MessageBox.Show(
                        $@"Link has changed from {topic.TopicState.OldLink} to {
                                topic.Link
                            }.\r\n\rnDo you want to fix up the link and file?",
                        "Topic Link Changed",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    var oldFile = topic.GetTopicFileName(topic.TopicState.OldLink);
                    topic.SaveTopicFile(); // save new file
                    File.Delete(oldFile);
                }
            }


            if (project == null)
            {
                project = kavaUi.AddinModel.ActiveProject;
            }

            project.SaveProjectAsync();
            return(true);
        }