protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType() + ". ****** "); if (disposing && !IsDisposed) { CommandBarContextMenu.ClearMenuItems(MenuItems); IsDisposed = true; } base.Dispose(disposing); }
protected override void OnSelect(EventArgs e) { CommandBarContextMenu contextMenu = this.GetContextMenu() as CommandBarContextMenu; if (contextMenu == null) { throw new NotSupportedException(); } contextMenu.SelectedMenuItem = this; base.OnSelect(e); }
protected override void Dispose(bool disposing) { if (disposing) { this.items.Clear(); this.items = null; this.contextMenu = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (disposing) { this.items.Clear(); this.items = null; this.contextMenu = null; } base.Dispose(disposing); }
private void UpdateItems() { this.OwnerDraw = true; CommandBarSeparator separator = this.item as CommandBarSeparator; if (separator != null) { this.Text = "-"; } else { this.Text = (this.mnemonics) ? this.item.Text : this.item.Text.Replace("&", ""); } CommandBarMenu menu = this.item as CommandBarMenu; if (menu != null) { CommandBarContextMenu.ClearMenuItems(MenuItems); Size imageSize = GetImageSize(menu.Items); int visibleItemCount = 0; foreach (CommandBarItem item in menu.Items) { this.MenuItems.Add(new MenuBarItem(item, imageSize, font, mnemonics)); visibleItemCount += (item.IsVisible) ? 1 : 0; } this.Enabled = (visibleItemCount == 0) ? false : this.item.IsEnabled; } else { this.Enabled = this.item.IsEnabled; } this.Visible = this.item.IsVisible; }
protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (disposing) { IsDisposing = true; try { if (contextMenu != null) { contextMenu.Dispose(); } if (items != null) { // Disposing the item might remove it from the collection, so we better work on // a copy of the collection. var copiedItems = new CommandBarItem[items.Count]; items.CopyTo(copiedItems, 0); foreach (var item in copiedItems) { item.Dispose(); } this.items.Clear(); } } finally { IsDisposing = false; } } this.items = null; this.contextMenu = null; base.Dispose(disposing); }