示例#1
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            try
            {
                var txtxMgr = (IVsTextManager)GetService(typeof(SVsTextManager));

                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                IntPtr     mainWnd;
                uiShell.GetDialogOwnerHwnd(out mainWnd);

                var dialog = new Window1();
                WindowInteropHelper helper = new WindowInteropHelper(dialog);
                helper.Owner = mainWnd;

                dialog.ShowDialog();

                if (dialog.SelectedOperation == Window1.Operation.AutoFull)
                {
                    var plugin = new AutoPropertyConverter(txtxMgr);
                    plugin.Execute();
                }
                else if (dialog.SelectedOperation == Window1.Operation.Encapsulate)
                {
                    var plugin = new FieldConverter(txtxMgr);
                    plugin.Execute();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            try
            {
                var txtxMgr = (IVsTextManager)GetService(typeof(SVsTextManager));

                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                IntPtr mainWnd;
                uiShell.GetDialogOwnerHwnd(out mainWnd);

                var dialog = new Window1();
                WindowInteropHelper helper = new WindowInteropHelper(dialog);
                helper.Owner = mainWnd;

                dialog.ShowDialog();

                if (dialog.SelectedOperation == Window1.Operation.AutoFull)
                {
                    var plugin = new AutoPropertyConverter(txtxMgr);
                    plugin.Execute();
                }
                else if (dialog.SelectedOperation == Window1.Operation.Encapsulate)
                {
                    var plugin = new FieldConverter(txtxMgr);
                    plugin.Execute();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }