public void ReloadTopics() { if (this.currentProject != null) { this.defaultTopicComboBox.Items.Clear(); if (this.currentProject.Topics != null) foreach (CHMTopic topic in this.currentProject.Topics) InsertTopics(topic); } //Default topic laden if (!string.IsNullOrEmpty(this.currentProject.DefaultTopic)) { CHMTopic defaultTopic = new CHMTopic(); foreach (CHMTopic topic in this.defaultTopicComboBox.Items) { if (topic.Id.ToString().Equals(this.currentProject.DefaultTopic)) { defaultTopic = topic; break; } } if (defaultTopic != null) { this.defaultTopicComboBox.Items.Insert(0, string.Empty); this.defaultTopicComboBox.SelectedItem = defaultTopic; } } else this.defaultTopicComboBox.Items.Insert(0, string.Empty); }
private void RemoveKeywords(CHMTopic topic) { openedProject.Keywords = openedProject.Keywords.Where(p => !p.Id.Equals(topic.Id)).ToList(); if (topic.Children != null && topic.Children.Count > 0) foreach (CHMTopic child in topic.Children) RemoveKeywords(child); }
private void chmTreeEditor_AfterSelect(object sender, TreeViewEventArgs e) { CHMTopic topic = (CHMTopic)e.Node.Tag; if (e.Node.Parent != null) { this.init = true; projectSettings1.Visible = false; neuerOrdnerToolStripMenuItem.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; neuerUntereintragToolStripMenuItem.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; newFolderBtn.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; newTopicBtn.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; newLink.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; neuerLinkToolStripMenuItem.Enabled = topic.TopicType == CHMTopic.CHMTopicType.Folder; löschenToolStripMenuItem.Enabled = true; deleteBtn.Enabled = true; if (topic.TopicType != CHMTopic.CHMTopicType.Link) { linkSettings1.Visible = false; topicEditor.Visible = true; htmlEditor1.InitEditor(topic.Html, topic.TopicName); } else if (topic.TopicType == CHMTopic.CHMTopicType.Link) { linkSettings1.Visible = true; if (!string.IsNullOrEmpty(topic.LinkAddress)) linkSettings1.Address = topic.LinkAddress; topicEditor.Visible = false; } this.currentEditedTopic = topic; topicEditor.Enabled = true; iconÄndernToolStripMenuItem.Enabled = true; keywordsListBox.Items.Clear(); keywordTextbox.Text = string.Empty; if (this.openedProject.Keywords != null && topic.TopicType != CHMTopic.CHMTopicType.Link) foreach (CHMKeyword keyword in this.openedProject.Keywords.Where(p => p.Id.Equals(this.currentEditedTopic.Id))) keywordsListBox.Items.Add(keyword); if (topic.TopicType != CHMTopic.CHMTopicType.Link) htmlEditor1.StartDirtTracking(); this.init = false; } else { projectSettings1.Visible = true; topicEditor.Visible = false; linkSettings1.Visible = false; neuerOrdnerToolStripMenuItem.Enabled = true; neuerUntereintragToolStripMenuItem.Enabled = true; löschenToolStripMenuItem.Enabled = false; deleteBtn.Enabled = false; newFolderBtn.Enabled = true; newTopicBtn.Enabled = true; iconÄndernToolStripMenuItem.Enabled = false; neuerLinkToolStripMenuItem.Enabled = true; newLink.Enabled = true; htmlEditor1.StopDirtTracking(); } }
private string BuildToolTipText(CHMTopic topic) { string type = string.Empty; switch (topic.TopicType) { case CHMTopic.CHMTopicType.Folder: type = "Ordner"; break; case CHMTopic.CHMTopicType.Link: type = "Link"; break; case CHMTopic.CHMTopicType.Page: type = "Seite"; break; } return string.Concat("Typ: ", type, "\nURL: ", topic.Id.ToString(), ".htm"); }
private void AddTreeNodes(TreeNode parent, CHMTopic topic, bool first) { if (first) { TreeNode current = new TreeNode(topic.Name); current.ToolTipText = BuildToolTipText(topic); chmTreeEditor.Nodes[0].Nodes.Add(current); if (topic.TopicType == CHMTopic.CHMTopicType.Folder) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = FOLDER_OPEN; current.SelectedImageIndex = FOLDER_OPEN; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } foreach (CHMTopic child in topic.Children) AddTreeNodes(current, child, false); } else if (topic.TopicType == CHMTopic.CHMTopicType.Page) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = PAGE; current.SelectedImageIndex = PAGE; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } } else if (topic.TopicType == CHMTopic.CHMTopicType.Link) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = LINK; current.SelectedImageIndex = LINK; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } } } else { TreeNode current = new TreeNode(topic.Name); current.ToolTipText = BuildToolTipText(topic); parent.Nodes.Add(current); if (topic.TopicType == CHMTopic.CHMTopicType.Folder) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = FOLDER_OPEN; current.SelectedImageIndex = FOLDER_OPEN; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } foreach (CHMTopic child in topic.Children) AddTreeNodes(current, child, false); } else if (topic.TopicType == CHMTopic.CHMTopicType.Page) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = PAGE; current.SelectedImageIndex = PAGE; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } } else if (topic.TopicType == CHMTopic.CHMTopicType.Link) { current.Tag = topic; if (topic.ImageNumber == 0) { current.ImageIndex = LINK; current.SelectedImageIndex = LINK; } else { current.ImageIndex = topic.ImageNumber; current.SelectedImageIndex = topic.ImageNumber; } } } }
private void InsertTopics(CHMTopic topic) { if (topic.TopicType != CHMTopic.CHMTopicType.Link) this.defaultTopicComboBox.Items.Add(topic); if (topic.Children != null && topic.Children.Count > 0) foreach (CHMTopic child in topic.Children) InsertTopics(child); }