protected override void OnExecute(Microsoft.VisualStudio.Shell.OleMenuCommand command) { VSCodeModel codeModel = new VSCodeModel(); VSTextView textView = new VSTextView(VSTextView.ActiveTextView); if (string.IsNullOrEmpty(textView.GetSelectedText().Trim())) { MessageBox.Show("please select valid text"); return; } //需要判断选中的内容属于哪个类或结构体下面 TextSpan ts = textView.GetSelectedSpan(); CodeElement classElement = GetClassElementSelectionBelong(textView, codeModel); if (classElement == null) { MessageBox.Show("Can't detect which class or struct the selection belongs to"); return; } MoveToRegionForm form = new MoveToRegionForm(classElement); form.OnSelectRegion += form_OnSelectRegion; form.ShowDialog(); }