[Test] public void SeparateHiddenControls() { _bar.Size = _bar.MinSize; _bar.SeparateHiddenControls = true; Label lbl1 = new Label(); lbl1.Text = "lbl1"; Label lbl2 = new Label(); lbl2.Text = "lbl2"; using (new LayoutSuspender(_bar)) { _bar.AddControl(lbl1); _bar.AddHiddenControl(lbl2); } _bar.Size = _bar.MinSize; // Let the chevron bar have its valid size ContextMenu menu = new ContextMenu(); _bar.FillChevronContextMenu(menu); Assert.AreEqual(3, menu.MenuItems.Count); Assert.AreEqual("-", menu.MenuItems [1].Text); menu.MenuItems [2].PerformClick(); Assert.AreSame(lbl2, _clickedControl); // see bug #6157 }
/// <summary> /// Fills the chevron bar with shortcut links. /// </summary> public void RebuildShortcutBar() { if (_resourcesWithShortcuts != null) { _resourcesWithShortcuts.ResourceDeleting -= OnResourceWithShortcutDeleting; _resourcesWithShortcuts.Dispose(); } _chevronBar.ClearControls(); using (new LayoutSuspender(_chevronBar)) { IResourceList shortcuts = Core.ResourceStore.GetAllResources("Shortcut"); shortcuts.Sort(new int[] { ShortcutProps.Order }, true); _numShortcuts = shortcuts.Count; foreach (IResource shortcut in shortcuts) { if (shortcut.IsDeleting) { continue; } IResource target = shortcut.GetLinkProp(ShortcutProps.Target); if (target == null || target.IsDeleting) { // delete the shortcut when its target is deleted new ResourceProxy(shortcut).Delete(); continue; } if (!Core.ResourceStore.ResourceTypes[target.Type].OwnerPluginLoaded) { continue; } ResourceLinkLabel lbl = new ResourceLinkLabel(); lbl.Resource = target; if (shortcut.HasProp("Name")) { lbl.Text = shortcut.GetStringProp("Name"); if (target.DisplayName != lbl.Text) { _tooltip.SetToolTip(lbl.NameLabel, target.DisplayName); } } lbl.Tag = shortcut; lbl.ResourceLinkClicked += OnResourceLinkClicked; lbl.LinkContextMenu += OnResourceLinkContextMenu; lbl.ResourceDragOver += OnResourceLinkDragOver; lbl.ResourceDrop += OnResourceLinkDrop; lbl.Width = lbl.PreferredWidth + 4; _chevronBar.AddControl(lbl); _maxOrder = shortcut.GetIntProp(ShortcutProps.Order); } _chevronBar.AddHiddenControl(_lblOrganize); } _resourcesWithShortcuts = Core.ResourceStore.FindResourcesWithPropLive(null, ShortcutProps.Target); _resourcesWithShortcuts.ResourceDeleting += OnResourceWithShortcutDeleting; if (_site != null) { _site.PerformLayout(this); } PerformLayout(); }