private void CommandExecuted(object sender, RoutedEventArgs e) { if ((e as ExecutedRoutedEventArgs).Command == ApplicationCommands.Paste) { // verify that the textbox handled the paste command if (e.Handled) { string signLower = txtSignature.Text.ToLower(); int pos = signLower.IndexOf("proc"); if (pos == -1) { return; } bool PosInSpaceBefProcName = false; bool PosProcName = false; string spname = string.Empty; for (int i = pos; i < txtSignature.Text.Length; ++i) { char c = txtSignature.Text[i]; if (PosInSpaceBefProcName == false) { if (SPSignature.IsWhitespace(c) == false) { continue; } else { PosInSpaceBefProcName = true; } } else if (PosInSpaceBefProcName && PosProcName == false) { if (SPSignature.IsWhitespace(c)) { continue; } else { spname += c; PosProcName = true; } } else if (PosProcName) { if (SPSignature.IsWhitespace(c) == false && c != '(') { spname += c; } else { break; } } } txtMethodName.Text = spname.Trim(); } } }
protected override void WndProc(ref Message m) { if (m.Msg == WM_PASTE) { if (Clipboard.ContainsText() == true) { string sign = Clipboard.GetText(); string signLower = sign.ToLower(); int pos = signLower.IndexOf("proc"); if (pos == -1) { return; } bool PosInSpaceBefProcName = false; bool PosProcName = false; string spname = string.Empty; for (int i = pos; i < sign.Length; ++i) { char c = sign[i]; if (PosInSpaceBefProcName == false) { if (SPSignature.IsWhitespace(c) == false) { continue; } else { PosInSpaceBefProcName = true; } } else if (PosInSpaceBefProcName && PosProcName == false) { if (SPSignature.IsWhitespace(c)) { continue; } else { spname += c; PosProcName = true; } } else if (PosProcName) { if (SPSignature.IsWhitespace(c) == false && c != '(') { spname += c; } else { break; } } } PastedEvent(spname.Trim()); } } base.WndProc(ref m); }