private void OnBeforeQueryStatusDynamicItem(object sender, EventArgs args) { DynamicItemMenuCommand matchedCommand = (DynamicItemMenuCommand)sender; if (MySqlDataProviderPackage.Instance != null) { _connectionsList = MySqlDataProviderPackage.Instance.GetMySqlConnections(); } bool isRootItem = (matchedCommand.MatchedCommandId == 0); if (_connectionsList.Count == 0) { matchedCommand.Visible = false; } else { matchedCommand.Enabled = true; matchedCommand.Visible = true; int indexForDisplay = (isRootItem ? 0 : (matchedCommand.MatchedCommandId - _baselistID)); matchedCommand.Text = _connectionsList[indexForDisplay].DisplayName; } matchedCommand.MatchedCommandId = 0; }
internal void InitMruMenu(ref OleMenuCommandService mcs) { if (mcs == null) { return; } var dynamicItemRootId = new CommandID(GuidList.GuidIdeToolbarCmdSet, _baselistID); var dynamicMenuCommand = new DynamicItemMenuCommand(dynamicItemRootId, IsValidDynamicItem, OnInvokedDynamicItem, OnBeforeQueryStatusDynamicItem); mcs.AddCommand(dynamicMenuCommand); }