///////////////////////////////////////////////////////////////////////////// // 重写包的实现 #region Package Members /// <summary> /// 包的初始化;这个方法将在包被选址后调用,所以你可以把所有 /// 基于Visual Studio提供服务的初始化代码放在这儿。 /// </summary> protected override void Initialize() { base.Initialize(); ToolboxInitialized += new EventHandler(ToolboxItemPackage_ToolboxInitialized); this.ToolboxUpgraded += new EventHandler(ToolboxItemPackage_ToolboxUpgraded); // 初始化服务. vsActivityLog = GetService(typeof(SVsActivityLog)) as IVsActivityLog; vsToolbox2 = GetService(typeof(SVsToolbox)) as IVsToolbox2; LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION, string.Format("Entering initializer for: {0}", this.ToString())); // 添加工具箱项,如果它不存在. try { if (!VerifyToolboxTabExist()) { AddToolboxTab(); } if (!VerifyToolboxItemExist()) { AddToolboxItem(); } } catch (Exception ex) { LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, ex.Message); LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, ex.StackTrace); } }
private void AddToolboxItem(GadgeteerToolboxItem item, IToolboxService service, IVsToolbox3 toolbox) { service.AddToolboxItem(item, item.TabName); string testTabId = null; if (toolbox.GetIDOfTab(item.TabName, out testTabId) != 0 || testTabId != item.TabNameId + item.TabName) { toolbox.SetIDOfTab(item.TabName, item.TabNameId + item.TabName); // add a dummy item so that the group is not visible outside of Gadgeteer designer (empty groups are by design) IVsToolbox2 toolbox2 = toolbox as IVsToolbox2; if (toolbox2 != null) { Guid pkgGuid = new Guid(Constants.GadgeteerDSLPackageId); TBXITEMINFO[] info = new[] { new TBXITEMINFO { bstrText = "(hidden placeholder)" } }; toolbox2.AddItem2(new Microsoft.VisualStudio.Shell.OleDataObject(), info, item.TabName, ref pkgGuid); } } }
/// <summary> /// 包的初始化;这个方法将在包被选址后调用,所以你可以把所有 /// 基于Visual Studio提供服务的初始化代码放在这儿。 /// </summary> protected override void Initialize() { base.Initialize(); ToolboxInitialized += new EventHandler(ToolboxItemPackage_ToolboxInitialized); this.ToolboxUpgraded += new EventHandler(ToolboxItemPackage_ToolboxUpgraded); // 初始化服务. vsActivityLog = GetService(typeof(SVsActivityLog)) as IVsActivityLog; vsToolbox2 = GetService(typeof(SVsToolbox)) as IVsToolbox2; LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION, string.Format("Entering initializer for: {0}", this.ToString())); // 添加工具箱项,如果它不存在. try { if (!VerifyToolboxTabExist()) { AddToolboxTab(); } if (!VerifyToolboxItemExist()) { AddToolboxItem(); } } catch (Exception ex) { LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, ex.Message); LogEntry(__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, ex.StackTrace); } }