private void UpdateNode(TreeNode node) { if (node == null || node.Tag == null) { return; } DialogTranslation.LineData tag = node.Tag as DialogTranslation.LineData; if (tag.isInterjection) { node.Text = "*插入对话节点*"; } else if (tag.dialogueLine.Lines.Count <= 0 || string.IsNullOrEmpty(tag.dialogueLine.Lines[0].Translation)) { node.Text = "<Empty>"; } else { node.Text = tag.dialogueLine.Lines[0].Translation; } if (tag.isLink) { node.ForeColor = Color.Gray; return; } TalkerEnum item = (TalkerEnum)tag.data.idata["speaker"]; if (tag.isInterjection) { node.BackColor = StateColours.getIntejectionColour(item); return; } node.ForeColor = StateColours.getTalkerColour(item); }
private void tvDialog_DrawNode(object sender, DrawTreeNodeEventArgs e) { bool state = (int)(e.State & TreeNodeStates.Selected) != 0; if (e.Node.Tag != null && this.currentLine != null && (e.Node.Tag as DialogTranslation.LineData).data == this.currentLine.data) { state = true; } if (state) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); TextRenderer.DrawText(e.Graphics, e.Node.Text, this.tvDialog.Font, e.Bounds, SystemColors.HighlightText, TextFormatFlags.Default); return; } if (!this.tvDialog.Focused && this.tvDialog.SelectedNode == e.Node) { e.Graphics.FillRectangle(SystemBrushes.ControlLight, e.Bounds); } else if (e.Node.BackColor.IsEmpty) { e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds); } else { using (SolidBrush solidBrush = new SolidBrush(e.Node.BackColor)) { e.Graphics.FillRectangle(solidBrush, e.Bounds); } } Color foreColor = e.Node.ForeColor; if (e.Node.Tag != null) { DialogTranslation.LineData tag = e.Node.Tag as DialogTranslation.LineData; if (tag.dialogueLine.State != TranslationManager.DialogueTranslationState.OK) { using (Pen pen = new Pen(Color.Red)) { pen.DashStyle = DashStyle.Dot; Rectangle bounds = e.Bounds; bounds.Size = new System.Drawing.Size(bounds.Width - 1, bounds.Height - 1); e.Graphics.DrawRectangle(pen, bounds); } } if (!tag.isLink) { foreColor = StateColours.getTalkerColour((TalkerEnum)tag.data["speaker"]); } } TextRenderer.DrawText(e.Graphics, e.Node.Text, this.tvDialog.Font, e.Bounds, foreColor, TextFormatFlags.Default); }