internal void Init(Menu parentMenu, Control hostControl, string header, MenuItems items, int?selectedIndex, MenuItemChosenDelegate menuItemChosenDelegate) { if (menuItemChosenDelegate != null) { this.MenuItemClickedEvent += menuItemChosenDelegate; } if (parentMenu != null) { this.parentMenu = parentMenu; } this.hostControl = hostControl; this.hostControl.PreviewKeyDown += new PreviewKeyDownEventHandler(this.formMain_PreviewKeyDown); this.hostControl.Resize += new EventHandler(this.hostControl_Resize); if (selectedIndex.HasValue) { this.selectedIndex = selectedIndex.Value; } this.menuItemChosenDelegate = menuItemChosenDelegate; this.header = header; this.items = items; this.items.SelectOnly(this.selectedIndex); this.UpdateShowedItems(); RefreshSelection(); }
public Menu(Menu parentMenu, string header, MenuItems menuItems, MenuItemChosenDelegate menuItemChosenDelegate) { if (parentMenu != null) { this.parentMenu = parentMenu; } this.header = header; this.items = menuItems; this.menuItemChosenDelegate = menuItemChosenDelegate; }
public Menu(Menu parentMenu, string header, string folderPath, bool isRootMenu, bool includeFilesFromRoot, bool includeFiles, bool navigateToEmptyFolder, string parentFolderNameAsFirstItem, bool addBracesToFolderNames, MenuItemChosenDelegate menuItemChosenDelegate) { this.header = header; this.parentMenu = parentMenu; this.menuItemChosenDelegate = menuItemChosenDelegate; this.items = new MenuItems(); if (!isRootMenu && !string.IsNullOrEmpty(parentFolderNameAsFirstItem)) { MenuItem parentFolderAsFirstItem = new MenuItem(parentFolderNameAsFirstItem, this); parentFolderAsFirstItem.tag = folderPath; this.items.Add(parentFolderAsFirstItem); } foreach (string subFolderPath in CraftSynth.BuildingBlocks.IO.FileSystem.GetFolderPaths(folderPath)) { MenuItem menuItem = new MenuItem(); string subMenuName = Path.GetFileName(subFolderPath); Menu subMenu = new Menu(this, subMenuName, subFolderPath, false, includeFilesFromRoot, includeFiles, navigateToEmptyFolder, parentFolderNameAsFirstItem, addBracesToFolderNames, menuItemChosenDelegate); if (addBracesToFolderNames) { subMenuName = string.Format("[ {0} ]", subMenuName); } menuItem.text = subMenuName; menuItem.haveChildren = subMenu.items != null && subMenu.items.Count > 0; if (subMenu.items.Count > 0) { menuItem.value = subMenu; } else { if (navigateToEmptyFolder) { menuItem.value = subMenu; } else { menuItem.value = subFolderPath; } } menuItem.tag = subFolderPath; this.items.Add(menuItem); } if ((includeFiles && !isRootMenu) || (includeFiles && isRootMenu && includeFilesFromRoot)) { foreach (string filePath in CraftSynth.BuildingBlocks.IO.FileSystem.GetFilePaths(folderPath)) { MenuItem menuItem = new MenuItem(); menuItem.text = Path.GetFileName(filePath); menuItem.haveChildren = false; menuItem.value = filePath; menuItem.tag = filePath; this.items.Add(menuItem); } } }
public static void ChangePage(Menu parentMenu, string header, MenuItems menuItems, int?selectedIndex, CraftSynth.BuildingBlocks.UI.WindowsForms.Slider.SlideType slideType, MenuItemChosenDelegate menuItemChosenDelegate) { OSD.menu2 = new Menu(); OSD.menu.inSlideProcess = true; OSD.menu2.inSlideProcess = true; if (menuItemChosenDelegate != null) { OSD.menu.menuItemChosenDelegate = menuItemChosenDelegate; } OSD.menu2.Init(parentMenu, OSD.formMain, header, menuItems, selectedIndex, OSD.menu.menuItemChosenDelegate); OSD.formMainSlider.Execute(OSD.formMain.pnlContent, OSD.formMain.pnlContent2, slideType, true); //switch back panels OSD.formMain.pnlContent.Tag = !((bool)OSD.formMain.pnlContent.Tag); OSD.formMain.pnlContent2.Tag = !((bool)OSD.formMain.pnlContent2.Tag); Panel pnlTemp = OSD.formMain.pnlContent; OSD.formMain.pnlContent = OSD.formMain.pnlContent2; OSD.formMain.pnlContent2 = pnlTemp; //switch back menus Menu tempMenu = OSD.menu; OSD.menu = OSD.menu2; tempMenu.Dispose(); //refresh //int selectedIndex = OSD.menu.selectedIndex; //OSD.menu.MoveDown();OSD.menu.ref OSD.formMain.pnlContent.BringToFront(); OSD.formMain.pnlContentParent.Refresh(); Application.DoEvents(); OSD.menu.inSlideProcess = false; }
public static void ChangePage(string header, MenuItems menuItems, int?selectedIndex, CraftSynth.BuildingBlocks.UI.WindowsForms.Slider.SlideType slideType, MenuItemChosenDelegate menuItemChosenDelegate) { Menu.ChangePage(null, header, menuItems, selectedIndex, slideType, menuItemChosenDelegate); }
public static void ChangePage(Menu parentMenu, string header, MenuItems menuItems, int?selectedIndex, MenuItemChosenDelegate menuItemChosenDelegate) { Menu.ChangePage(parentMenu, header, menuItems, selectedIndex, CraftSynth.BuildingBlocks.UI.WindowsForms.Slider.SlideType.SlideToLeft, menuItemChosenDelegate); }
public static void ChangePage(string header, MenuItems menuItems, MenuItemChosenDelegate menuItemChosenDelegate) { Menu.ChangePage(null, header, menuItems, null, CraftSynth.BuildingBlocks.UI.WindowsForms.Slider.SlideType.SlideToLeft, menuItemChosenDelegate); }
public static MenuItem ShowMenu(Form ownerForm, Menu parentMenu, string header, MenuItems menuItems, int?selectedIndex, MenuItemChosenDelegate menuItemChosenDelegate) { OSD.InitializeIfNeeded(); OSD.menu = new Menu(); OSD.menu.Init(parentMenu, OSD.formMain, header, menuItems, selectedIndex, menuItemChosenDelegate); OSD.formMain.pnlContent.Tag = true; OSD.formMain.pnlContent2.Tag = false; OSD.formMain.Text = "OSD"; OSD.formMain.TopLevel = true; OSD.formMain.TopMost = true; OSD.formMain.Owner = ownerForm; OSD.formDisplayer.ShowForm(OSD.formMain); OSD.formMain.ShowDialog(); return(OSD.menu.SelectedItem); }
public static MenuItem ShowMenu(Menu parentMenu, string header, MenuItems menuItems, int?selectedIndex, MenuItemChosenDelegate menuItemChosenDelegate) { return(ShowMenu(null, parentMenu, header, menuItems, selectedIndex, menuItemChosenDelegate)); }
public static MenuItem ShowMenu(Menu parentMenu, string header, MenuItems menuItems, MenuItemChosenDelegate menuItemChosenDelegate) { return(ShowMenu(null, parentMenu, header, menuItems, null, menuItemChosenDelegate)); }
public static MenuItem ShowMenu(Menu menu, MenuItemChosenDelegate menuItemChosenDelegate) { return(ShowMenu(menu.parentMenu, menu.header, menu.items, menu.selectedIndex, (menuItemChosenDelegate == null)?menu.menuItemChosenDelegate:menuItemChosenDelegate)); }