public void create_popup_menu_command( string host_menu_bar_name, string command_name, string item_text, string tooltip_text, int position, menu_command_querystatus_handler querystatus_handler, menu_command_exec_handler exec_handler ) { object[] contextGUIDS = new object[] { }; BARS.CommandBar host_bar = ((BARS.CommandBars)_ssms.DTE2.CommandBars)[host_menu_bar_name]; Command new_command = _SSMS_commands_collection.AddNamedCommand2(_ssms.addin, command_name, item_text, tooltip_text, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton); if (new_command == null) { throw new Exception("SSMSW08 could not create command bar: " + item_text); } position = (position == 0 ? host_bar.Controls.Count + 1 : position); new_command.AddControl(host_bar, position); menu_command_handlers handlers = new menu_command_handlers(); handlers.querystatus_handler = querystatus_handler == null ? this._default_querystatus_handler : querystatus_handler; handlers.exec_handler = exec_handler == null ? this._default_exec_handler : exec_handler; this._addin_menu_commands_dictonary.Add(_ssms.addin.ProgID + "." + command_name, handlers); }
public void create_bar_command( string host_menu_bar_name, string command_name, string item_text, string tooltip_text, int position, menu_command_querystatus_handler querystatus_handler, menu_command_exec_handler exec_handler, Bitmap picture, bool beginGroup ) { try { object[] contextGUIDS = new object[] { }; RemoveCommandIfAlreadyExits(command_name); vsCommandStyle commandStyle = (picture == null) ? vsCommandStyle.vsCommandStyleText : vsCommandStyle.vsCommandStylePictAndText; BARS.CommandBar host_bar = (BARS.CommandBar)((BARS.CommandBars)VSI.ServiceCache.ExtensibilityModel.CommandBars)[host_menu_bar_name]; Command new_command = _SSMS_commands_collection.AddNamedCommand2(_ssms.addin, command_name, item_text, tooltip_text, true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)commandStyle, vsCommandControlType.vsCommandControlTypeButton); if (new_command != null) { position = (position == 0 ? host_bar.Controls.Count + 1 : position); BARS.CommandBarButton control = (BARS.CommandBarButton)new_command.AddControl(host_bar, position); control.BeginGroup = beginGroup; control.TooltipText = tooltip_text.Substring(0, tooltip_text.Length > 255 ? 255 : tooltip_text.Length); menu_command_handlers handlers = new menu_command_handlers(); handlers.querystatus_handler = querystatus_handler == null ? this._default_querystatus_handler : querystatus_handler; handlers.exec_handler = exec_handler == null ? this._default_exec_handler : exec_handler; this._addin_menu_commands_dictonary.Add(_ssms.addin.ProgID + "." + command_name, handlers); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message, "Exception at create_bar_command"); System.Diagnostics.Debug.Print(e.Message); } }
private menu_command_exec_handler CreateOpenRfPluginCommandHandler() { menu_command_exec_handler exec_handler = delegate(vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { if (FToolwindowContainer != null) { FToolwindowContainer.Activate(); } else { try { var wins2Obj = (EnvDTE80.Windows2)_ssmsAbstract.DTE2.Windows; object myControl = null; FToolwindowContainer = wins2Obj.CreateToolWindow2( _ssmsAbstract.addin, System.Reflection.Assembly.GetExecutingAssembly().Location, typeof(SQL2014.WinformHost).FullName, // Should be use Windows Forms control "RF Wpf User Control", "{F198702E-02A2-42D7-AE75-E4ECFB0E5686}", ref myControl ); //var _wpfToolWindow = myControl as WinformHost; FToolwindowContainer.IsFloating = false; FToolwindowContainer.Visible = true; FToolwindowContainer.Linkable = false; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Exception when Open:" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); } } }; return(exec_handler); }