diff --git a/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Attributes/MenuAttribute.cs b/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Attributes/MenuAttribute.cs index ff3e2ad..de2c5cc 100644 --- a/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Attributes/MenuAttribute.cs +++ b/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Attributes/MenuAttribute.cs @@ -9,31 +9,56 @@ namespace BlueByte.SOLIDWORKS.PDMProfessional.SDK.Attributes [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class MenuAttribute : Attribute { - /// - /// Creates a command menu. - /// - /// ID of the command. - /// Text that will appear in the menu. - /// Where the menu will appear. - /// Help message that will appear in the status bar. - /// Help message that appear in the Windows tooltip. - /// Index of the command button. - /// ID of the toolbar image. - public MenuAttribute(int iD, string menuCaption, int flags = 0, string statusBarHelp = "", string toolTip = "", int toolButtonIndex = -1, int toolbarImageID = 0) + /// + /// Creates a command menu. + /// + /// ID of the command. + /// Text that will appear in the menu. + /// Where the menu will appear. + /// Help message that will appear in the status bar. + /// Help message that appear in the Windows tooltip. + /// Index of the command button. + /// ID of the toolbar image. + public MenuAttribute(int ID, string menuCaption, int flags = 0, string statusBarHelp = "", string toolTip = "", int toolButtonIndex = -1, int toolbarImageID = 0) { - ID = iD; + this.ID = ID; MenuCaption = menuCaption; Flags = flags; StatusBarHelp = statusBarHelp; Tooltip = toolTip; ToolButtonIndex = toolButtonIndex; - ToolbarImageID = toolbarImageID; } - + /// + /// Creates a command menu. + /// + /// ID of the command. + /// Text that will appear in the menu. + /// Where the menu will appear. + /// Callback + public MenuAttribute(int ID, string menuCaption, int flags = 0, string callback = "") + { + this.ID = ID; + MenuCaption = menuCaption; + Flags = flags; + StatusBarHelp = menuCaption; + Tooltip = menuCaption; + ToolButtonIndex = -1; + ToolbarImageID = 0; + this.Callback = callback; + } + + + /// + /// Gets or sets the callback. + /// + /// + /// The callback. + /// + /// This is not implemented yet. + public string Callback { get; set; } - /// /// ID of the command. diff --git a/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Core/AddInBase.cs b/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Core/AddInBase.cs index 4afce5b..fe6173b 100644 --- a/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Core/AddInBase.cs +++ b/src/BlueByte.SOLIDWORKS.PDMProfessional.SDK/Core/AddInBase.cs @@ -600,9 +600,12 @@ public void AttachDebugger() { var information = new StringBuilder(); information.AppendLine(); - information.AppendLine($"Process name = { process.ProcessName}"); - information.AppendLine($"Command Id = { process.Id}"); - information.AppendLine($"Command type = { poCmd.meCmdType.ToString()}"); + information.AppendLine($"Host Name = { process.ProcessName}"); + information.AppendLine($"Host Id = { process.Id}"); + information.AppendLine($"Command Type = { poCmd.meCmdType.ToString()}"); + information.AppendLine($"Command Id = { poCmd.mlCmdID.ToString()}"); + information.AppendLine($"Parent Handle= { poCmd.mlParentWnd}"); + information.AppendLine($"Comments = { poCmd.mbsComment}"); if (MessageBox.Show($"Attach Debugger? {information.ToString()}", $"{Identity.Name} - {Identity.Version}", MessageBoxButtons.OKCancel) == DialogResult.OK) Debugger.Launch(); @@ -882,30 +885,31 @@ public virtual void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IE { if (commandVisibility.CommandID == MenuAtt.ID) { + var add = false; var userandgroups = commandVisibility.HideFromTheseUserOrGroupNames; if (userandgroups != null) { - var add = false; + // only add command if usergroups does not contain username or groups users is a member of. if ((userandgroups.Contains(userName) || userandgroups.Where(x => groupNames.Contains(x)).Count() > 0) == false) add = true; + } - var permissions = commandVisibility.OnlyShowToUsersWithThesePermissions; - - // if there are permissions check if currently logged in user has the right permissions - if (permissions != default(EdmSysPerm)) - { - var hasAllPermissions = currentlyLoggedInUser.HasSysRightEx(permissions); - if (hasAllPermissions) - add = true; - } - - - if (add) - poCmdMgr.AddCmd(MenuAtt.ID, MenuAtt.MenuCaption, (int)MenuAtt.Flags, MenuAtt.StatusBarHelp, MenuAtt.Tooltip, MenuAtt.ToolButtonIndex, MenuAtt.ToolbarImageID); + var permissions = commandVisibility.OnlyShowToUsersWithThesePermissions; + // if there are permissions check if currently logged in user has the right permissions + if (permissions != default(EdmSysPerm)) + { + var hasAllPermissions = currentlyLoggedInUser.HasSysRightEx(permissions); + if (hasAllPermissions) + add = true; } + + + if (add) + poCmdMgr.AddCmd(MenuAtt.ID, MenuAtt.MenuCaption, (int)MenuAtt.Flags, MenuAtt.StatusBarHelp, MenuAtt.Tooltip, MenuAtt.ToolButtonIndex, MenuAtt.ToolbarImageID); + } } } @@ -1023,13 +1027,14 @@ public virtual void OnCmd(ref EdmCmd poCmd, ref EdmCmdData[] ppoData) case EdmCmdType.EdmCmd_TaskLaunchButton: OnTaskLaunchButton(ref poCmd, ref ppoData); break; - default: break; } } } + + /// /// Fires when task details are initialized ///