protected virtual object[] GetBands() { RebarBand[] result = new RebarBand[bandsCount]; if (bandsCount > 0) { Array.Copy(bands, 0, result, 0, bandsCount); } return(result); }
public int FindIndex(RebarBand value) { for (int x = 0; x < owner.Bands.Count; x++) { if (owner.Bands[x] == this) { return(x); } } return(-1); }
public void UpdateRebarBand(RebarBand value, int index) { if (IsHandleCreated) { BeginUpdate(); if (Marshal.SystemDefaultCharSize == 1) { NativeMethods.REBARBANDINFO bandINFO = value.GetREBARBANDINFO(index); UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.RB_SETBANDINFOA, index, ref bandINFO); } else { NativeMethods.REBARBANDINFO bandINFO = value.GetREBARBANDINFO(index); UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.RB_SETBANDINFOW, index, ref bandINFO); } EndUpdate(); } }
private void WmReflectNotifyChevronPushed(ref Message m) { NativeMethods.NMREBARCHEVRON nrch = (NativeMethods.NMREBARCHEVRON)m.GetLParam(typeof(NativeMethods.NMREBARCHEVRON)); RebarBand band = Bands[nrch.wID]; ContextMenu childMenu = new ContextMenu(); if (band.Control != null && band.Control is ToolBox) { ToolBox toolBar = band.Control as ToolBox; NativeMethods.RECT lpRect = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(new HandleRef(band.Control, band.Control.Handle), ref lpRect); int count = (int)UnsafeNativeMethods.SendMessage(new HandleRef(band.Control, band.Control.Handle), NativeMethods.TB_BUTTONCOUNT, IntPtr.Zero, IntPtr.Zero); if (count != toolBar.buttonsCount) { throw new ArgumentOutOfRangeException("count"); } for (int i = 0; i < count; i++) { NativeMethods.RECT brc = new NativeMethods.RECT(); UnsafeNativeMethods.SendMessage(new HandleRef(band.Control, band.Control.Handle), NativeMethods.TB_GETITEMRECT, i, ref brc); if (brc.right >= (lpRect.right - lpRect.left)) { ToolBoxButton btn = toolBar.Buttons[i]; if ((btn.Appearance & TBBAppearance.Separator) == 0) { string text = string.Empty; if (!string.IsNullOrEmpty(btn.Text)) { text = btn.Text; } else if (!string.IsNullOrEmpty(btn.ToolTipText)) { text = btn.ToolTipText; } else { text = btn.MenuText; } MenuItem menuItem = null; if (btn.Enable) { menuItem = new MenuItem(text, OnMenuItemClick); menuItem.Tag = btn; toolBar.Renderer.SetEnable(menuItem, true); } else { menuItem = new MenuItem(text); toolBar.Renderer.SetEnable(menuItem, false); } toolBar.Renderer.SetImageIndex(menuItem, btn.ImageIndex); childMenu.MenuItems.Add(menuItem); if (btn.DropDownMenu != null) { foreach (MenuItem item in btn.DropDownMenu.MenuItems) { MenuItem newMenuItem = new MenuItem(item.Text, OnMenuSubItemClick); newMenuItem.Tag = item; menuItem.MenuItems.Add(newMenuItem); } } } } } } if (band.Control != null && band.Control is MenuBox) { MenuBox menuBar = band.Control as MenuBox; NativeMethods.RECT lpRect = new NativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(new HandleRef(band.Control, band.Control.Handle), ref lpRect); int count = (int)UnsafeNativeMethods.SendMessage(new HandleRef(band.Control, band.Control.Handle), NativeMethods.TB_BUTTONCOUNT, IntPtr.Zero, IntPtr.Zero); if (count != menuBar.itemsCount) { throw new ArgumentOutOfRangeException("count"); } for (int i = 0; i < count; i++) { NativeMethods.RECT brc = new NativeMethods.RECT(); UnsafeNativeMethods.SendMessage(new HandleRef(band.Control, band.Control.Handle), NativeMethods.TB_GETITEMRECT, i, ref brc); if (brc.right >= (lpRect.right - lpRect.left)) { MenuBoxItem menuBarItem = menuBar.Items[i]; MenuItem menuItem = new MenuItem(menuBarItem.Text); childMenu.MenuItems.Add(menuItem); if (menuBarItem.DropDownMenu != null) { foreach (MenuItem item in menuBarItem.DropDownMenu.MenuItems) { MenuItem newMenuItem = new MenuItem(item.Text, OnMenuSubItemClick); newMenuItem.Tag = item; menuItem.MenuItems.Add(newMenuItem); } } } } } childMenu.Show(this, new Point(nrch.rc.left, nrch.rc.bottom)); }