private void contextMenuStrip1_ItemClicked(object sender, System.Windows.Forms.ToolStripItemClickedEventArgs e) { if (e.ClickedItem == mnuCopy) { _EditorControl.Copy(); } else if (e.ClickedItem == mnuCut) { _EditorControl.Cut(); } else if (e.ClickedItem == mnuPaste) { _EditorControl.Paste(); } else if (e.ClickedItem == mnuUndo) { _EditorControl.Undo(); } else if (e.ClickedItem == mnuRedo) { _EditorControl.Redo(); } else if (e.ClickedItem == mnuSelectAll) { _EditorControl.SelectAll(); } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem == mnuCopy) { _EditorControl.Copy(); } else if (e.ClickedItem == mnuCut) { _EditorControl.Cut(); } else if (e.ClickedItem == mnuPaste) { _EditorControl.Paste(); } else if (e.ClickedItem == mnuUndo) { _EditorControl.Undo(); } else if (e.ClickedItem == mnuRedo) { _EditorControl.Redo(); } else if (e.ClickedItem == mnuSelectAll) { _EditorControl.SelectAll(); } else if (e.ClickedItem == mnuComment) { Comment(); } else if (e.ClickedItem == mnuUnComment) { UnComment(); } else if (e.ClickedItem == mnuGoToDeclarition) { if (e.ClickedItem.Tag != null) { string word = e.ClickedItem.Tag.ToString(); string text = _EditorControl.Document.Text; int index = text.IndexOf(word); int totalIndex = 0; while (index > 0) { totalIndex += index; string preText = text.Substring(0, index).TrimEnd(' ', '\r', '\n'); if (preText.EndsWith("define")) { _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; _EditorControl.GotoLine(_EditorControl.Selection.Bounds.FirstRow); _EditorControl.ScrollIntoView(); _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; break; } else { totalIndex += (text.Length - index); text = text.Substring(index + word.Length); text = text.TrimStart('(', ')', ' ', '\r', '\n'); totalIndex -= text.Length; if (text.StartsWith("=")) { _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; _EditorControl.GotoLine(_EditorControl.Selection.Bounds.FirstRow); _EditorControl.ScrollIntoView(); _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; break; } else { int index2 = text.IndexOf(")"); if (index2 > 0) { string temp = text.Substring(0, index2); string[] parts = temp.Split(new char[] { ',', ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); bool isParamter = true; foreach (string s in parts) { if (!Common.Ultility.Ultility.IsAValidName(s)) { isParamter = false; break; } } if (isParamter) { totalIndex += text.Length; text = text.Substring(index2).TrimStart(')', ' ', '\r', '\n'); totalIndex -= text.Length; if (text.StartsWith("=")) { _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; _EditorControl.GotoLine(_EditorControl.Selection.Bounds.FirstRow); _EditorControl.ScrollIntoView(); _EditorControl.Selection.SelStart = totalIndex; _EditorControl.Selection.SelLength = word.Length; break; } } } } } index = text.IndexOf(word); } } } //else if (e.ClickedItem == mnuFindUsage) //{ // UnComment(); //} else if (e.ClickedItem == mnuRename) { if (e.ClickedItem.Tag == null) { string word = this._EditorControl.Selection.Text; bool enable = Common.Ultility.Ultility.IsAValidName(word); Word formatedWord = _EditorControl.Document.GetFormatWordFromPos(this._EditorControl.Selection.Bounds.FirstColumn + 1, this._EditorControl.Selection.Bounds.FirstRow); if (formatedWord != null) { if (formatedWord.Style.ForeColor == Color.Black && enable) { Rename(word); } } } else { Rename(e.ClickedItem.Tag.ToString()); } } }