/// <summary> /// Swaps location of 2 menu items and rewrites menu. Nothing will happen if /// 'MenuItem' objects are the same. /// </summary> /// <param name="menuThing1"></param> /// <param name="menuThing2"></param> /// <returns></returns> public Menu Swap(MenuThing menuThing1, MenuThing menuThing2) { Swap( MenuGlobal.IndexOf(menuThing1), MenuGlobal.IndexOf(menuThing2) ); return(this); }
/// <summary> /// Swaps location of 2 menu items and rewrites menu. Nothing will happen /// if indexes are out of range or equal. /// </summary> /// <param name="menuThingIndex"></param> /// <param name="newMenuThingIndex"></param> public Menu Swap(int menuThingIndex, int newMenuThingIndex) { if (menuThingIndex < MenuGlobal.Count && menuThingIndex >= 0 && newMenuThingIndex < MenuGlobal.Count && newMenuThingIndex >= 0 && menuThingIndex != newMenuThingIndex) { MenuThing menuThing1 = MenuGlobal[menuThingIndex]; MenuThing menuThing2 = MenuGlobal[newMenuThingIndex]; MenuGlobal.Remove(menuThing1); MenuGlobal.Remove(menuThing2); MenuGlobal.Insert(newMenuThingIndex, menuThing1); MenuGlobal.Insert(menuThingIndex, menuThing2); this.GoTo(); } return(this); }
/// <summary> /// Removes a menu thing. /// </summary> /// <param name="menuThing"></param> /// <returns></returns> public Menu Remove(MenuThing menuThing) { this.MenuGlobal.Remove(menuThing); return(this); }