public void Show(Control control, Point point) { CommandBarItemCollection chevronItems = new CommandBarItemCollection(); Size size = ClientSize; for (int i = 0; i < items.Count; i++) { NativeMethods.RECT rect = new NativeMethods.RECT(); NativeMethods.SendMessage(Handle, NativeMethods.TB_GETITEMRECT, i, ref rect); if (rect.right > size.Width) { CommandBarItem item = items[i]; if (item.IsVisible) { if ((!(item is CommandBarSeparator)) || (chevronItems.Count != 0)) { chevronItems.Add(item); } } } } this.contextMenu.Mnemonics = false; this.contextMenu.Items.Clear(); this.contextMenu.Items.AddRange(chevronItems); this.contextMenu.Show(control, point); }
public CommandBar() { this.SetStyle(ControlStyles.UserPaint, false); this.TabStop = false; this.Font = SystemInformation.MenuFont; this.Dock = DockStyle.Top; this.items = new CommandBarItemCollection(this); }
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); }
protected override void Dispose(bool fDisposing) { if (fDisposing) { 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(); items.Clear(); } } items = null; base.Dispose(fDisposing); }
protected override void Dispose(bool fDisposing) { if (fDisposing) { 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(); } items.Clear(); } } items = null; base.Dispose(fDisposing); }
private static Size GetImageSize(CommandBarItemCollection items) { Size imageSize = new Size(16, 16); for (int i = 0; i < items.Count; i++) { Image image = items[i].Image; if (image != null) { if (image.Width > imageSize.Width) { imageSize.Width = image.Width; } if (image.Height > imageSize.Height) { imageSize.Height = image.Height; } } } return(imageSize); }
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); }