private void UpdateRichTextBox() { int maxLine = Math.Min(ScrolledLine + FVisibleLines, FRTFSelectionList.Count); var rtfBuilder = new StringBuilder(CRTFHeader); for (int i = ScrolledLine; i < maxLine; i++) { rtfBuilder.Append(FRTFSelectionList[i]); } //seems mono adds a \par here automatically, so remove one string rtf = rtfBuilder.ToString(); rtf = rtf.TrimEnd(new char[5] { '\\', 'p', 'a', 'r', ' ' }); // + "}"; if (FRichTextBox.InvokeRequired) { FRichTextBox.Invoke(new MethodInvoker(() => { FRichTextBox.Rtf = rtf; })); } else { FRichTextBox.Rtf = rtf; } FNodeTypePanel.Invalidate(); }
private void ShowToolTip(int x) { var selectionIndex = FHoverLine + FScrolledLine; if (selectionIndex < 0 || selectionIndex >= FSelectionList.Count) { return; } var ni = FSelectionList[FHoverLine + ScrolledLine]; int y = FRichTextBox.GetPositionFromCharIndex(FRichTextBox.GetFirstCharIndexFromLine(FHoverLine)).Y; string tip = ""; if (!string.IsNullOrEmpty(ni.Shortcut)) { tip = "(" + ni.Shortcut + ") "; } if (!string.IsNullOrEmpty(ni.Help)) { tip += ni.Help.Trim(); } if (!string.IsNullOrEmpty(ni.Warnings)) { tip += "\n WARNINGS: " + ni.Warnings.Trim(); } if (!string.IsNullOrEmpty(ni.Bugs)) { tip += "\n BUGS: " + ni.Bugs.Trim(); } if ((!string.IsNullOrEmpty(ni.Author)) && (ni.Author != "vvvv group")) { tip += "\n AUTHOR: " + ni.Author.Trim(); } if (!string.IsNullOrEmpty(ni.Credits)) { tip += "\n CREDITS: " + ni.Credits.Trim(); } if (ni.Type == NodeType.Dynamic || ni.Type == NodeType.Effect || ni.Type == NodeType.VL || ni.Type == NodeType.Module) { tip += "\n Use CTRL+Enter or CTRL+Click to clone this node."; } if (!string.IsNullOrEmpty(ni.Filename)) { tip += "\n\n" + ni.Filename; } if (!string.IsNullOrEmpty(tip)) { FToolTip.Show(tip.Trim(), FRichTextBox, x, y + DIPX(15)); } else { FToolTip.Hide(FRichTextBox); } }
private void RedrawSelection() { //clear old selection FRichTextBox.SelectionBackColor = Color.Silver; if (FHoverLine > -1) { //draw current selection FRichTextBox.SelectionStart = FRichTextBox.GetFirstCharIndexFromLine(FHoverLine); FRichTextBox.SelectionLength = CLineLength; FRichTextBox.SelectionBackColor = CHoverColor; } //make sure the selection is also drawn in the NodeTypePanel FRichTextBox.Invalidate(); }
void RichTextBoxMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (FHoverLine < 0 || FHoverLine >= FRichTextBox.Lines.Length) { return; } string username = FRichTextBox.Lines[FHoverLine].Trim(); FRichTextBox.SelectionStart = FRichTextBox.GetFirstCharIndexFromLine(FHoverLine) + 1; TagsTextBox.Focus(); //as plugin in its own window if (AllowDragDrop) { var selNode = FSelectionList[FHoverLine + ScrolledLine]; TagsTextBox.DoDragDrop(string.Format("{0}||{1}", selNode.Systemname, selNode.Filename), DragDropEffects.All); return; } //else popped up on doubleclick else if (e.Button == MouseButtons.Left) { CreateNodeFromHoverLine(); } else { try { var selNode = FSelectionList[FHoverLine + ScrolledLine]; if (e.Button == MouseButtons.Middle) { OnShowNodeReference(selNode); } else { TagsTextBox.Text = ""; OnShowHelpPatch(selNode); } } catch //username is a filename..do nothing {} } }
void RichTextBoxMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (FRichTextBox.Lines.Length == 0) { return; } var charIndex = FRichTextBox.GetCharIndexFromPosition(e.Location); int newHoverLine = FRichTextBox.GetLineFromCharIndex(charIndex); //avoid some flicker if (newHoverLine != FHoverLine) // if ((e.Location.X != FLastMouseHoverLocation.X) || (e.Location.Y != FLastMouseHoverLocation.Y)) { FLastMouseHoverLocation = e.Location; FHoverLine = newHoverLine; ShowToolTip(e.X + DIPX(15)); RedrawSelection(); } }