public void Translate(TagTreeNode node, StringBuilder textBuilder) { var translation = tagTranslator.Translate(node.TagInfo); textBuilder.Append(node.IsRaw ? node.TagInfo.OpeningTag : translation.OpeningTranslation); TranslateChildren(node, textBuilder); textBuilder.Append(node.IsRaw ? node.TagInfo.ClosingTag : translation.ClosingTranslation); }
/// <summary> /// /// </summary> private void ValidateState() { TagTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as TagTreeNode; deleteToolStripMenuItem.Enabled = (Node != null); editToolStripMenuItem.Enabled = (Node != null); addTagToolStripMenuItem.Enabled = true; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteClicked(object sender, EventArgs e) { TagTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as TagTreeNode; if (Node == null) { return; } Program.NetClient.DeleteTag(Node.BuildTag.Id); Program.NetClient.RequestTagList(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditClicked(object sender, EventArgs e) { TagTreeNode Node = MainTreeView.SelectedNode == null ? null : MainTreeView.SelectedNode.Tag as TagTreeNode; if (Node == null) { return; } using (AddTagForm form = new AddTagForm()) { form.TagName = Node.BuildTag.Name; form.TagColor = Node.BuildTag.Color; form.TagUnique = Node.BuildTag.Unique; form.TagDecayTagId = Node.BuildTag.DecayTagId; if (form.ShowDialog(this) == DialogResult.OK) { Node.Name = form.TagName; Program.NetClient.RenameTag(Node.BuildTag.Id, form.TagName, form.TagColor, form.TagUnique, form.TagDecayTagId); Program.NetClient.RequestTagList(); } } }
/// <summary> /// </summary> /// <param name="Users"></param> private void TagsRecieved(List <Tag> InTags) { bool ForceUpdate = false; InTags.Sort((Item1, Item2) => - Item1.Name.CompareTo(Item2.Name)); // Add new tags. foreach (Tag Tag in InTags) { bool Found = false; foreach (TagTreeNode Node in Model.Nodes) { if (Node.BuildTag.Id == Tag.Id) { if (!Node.BuildTag.EqualTo(Tag)) { Node.BuildTag = Tag; Node.BuildTags = new Tag[1]; Node.BuildTags[0] = Tag; Node.Name = Tag.Name; Node.Unique = Tag.Unique ? "True" : "False"; if (Tag.DecayTagId != Guid.Empty) { Node.DecayTags = new Tag[1]; Node.DecayTags[0] = Program.TagRegistry.GetTagById(Tag.DecayTagId); } else { Node.DecayTags = new Tag[0]; } ForceUpdate = true; } Found = true; break; } } if (!Found) { TagTreeNode Node = new TagTreeNode(); Node.BuildTag = Tag; Node.BuildTags = new Tag[1]; Node.BuildTags[0] = Tag; Node.Unique = Tag.Unique ? "True" : "False"; Node.Name = Tag.Name; Node.Icon = Resources.appbar_tag; if (Tag.DecayTagId != Guid.Empty) { Node.DecayTags = new Tag[1]; Node.DecayTags[0] = Program.TagRegistry.GetTagById(Tag.DecayTagId); } else { Node.DecayTags = new Tag[0]; } Model.Nodes.Add(Node); ForceUpdate = true; } } // Remove old tags. List <TagTreeNode> RemovedNodes = new List <TagTreeNode>(); foreach (TagTreeNode Node in Model.Nodes) { bool Found = false; foreach (Tag Tag in InTags) { if (Node.BuildTag.Id == Tag.Id) { Found = true; break; } } if (!Found) { RemovedNodes.Add(Node); } } foreach (TagTreeNode Node in RemovedNodes) { Model.Nodes.Remove(Node); ForceUpdate = true; } if (ForceUpdate) { TagRenderer.InvalidateResources(); Invalidate(); Refresh(); } }
/// <summary> /// Initializes a new instance of the <see cref="ItemContextMenu"/> class. /// </summary> /// <param name="node">The node.</param> internal ContextMenuTag(TagTreeNode node) : this() { m_Node = node; }