public void AddItem(IMusixMenuItem item) { Items.Add(item); MusixDynamicSidebarItem sidebarItem = new MusixDynamicSidebarItem(item); sidebarItem.SendStyle(Style); sidebarItem.OnSelect += SidebarItem_OnSelect; flowElements.Controls.Add(sidebarItem); }
public void SelectItem(IMusixMenuItem item) { MusixDynamicSidebarItem it = GetUIElement(item); if (it != null) { it.IsSelected = true; } }
public void RemoveItem(IMusixMenuItem item) { MusixDynamicSidebarItem UIElement = GetUIElement(item); if (UIElement != null) { UIElement.OnSelect -= SidebarItem_OnSelect; Items.Remove(item); flowElements.Controls.Remove(UIElement); return; } }
public void SelectItemAtIndex(int index) { IMusixMenuItem item = Items[index]; System.Console.WriteLine($"Index {index} > {item.Name}"); MusixDynamicSidebarItem menuItem = GetUIElement(item); System.Console.WriteLine($"Resolved entry index: {flowElements.Controls.IndexOf(menuItem)}"); if (menuItem != null) { System.Console.WriteLine("setselected"); menuItem.IsSelected = true; } }
public void CheckHover(MusixDynamicSidebarItem item, Point ctPoint) { if (IsInControl(item, ctPoint)) { if (!item.IsHover) { item.IsHover = true; } } else { if (item.IsHover) { item.IsHover = false; } } }
private void SidebarItem_OnSelect(MusixDynamicSidebarItem item) { if (item == SelectedItem) { return; } else { SelectedItem = item; } item.MenuItem.OnSelect(); OnSelectionChanged?.Invoke(item.MenuItem); foreach (MusixDynamicSidebarItem sidebarItem in flowElements.Controls.OfType <MusixDynamicSidebarItem>()) { if (sidebarItem != item && sidebarItem.IsSelected) { sidebarItem.IsSelected = false; sidebarItem.MenuItem.OnDeselect(); } } }
public void RemoveItem(MusixDynamicSidebarItem item) { item.OnSelect -= SidebarItem_OnSelect; Items.Remove(item.MenuItem); flowElements.Controls.Remove(item); }