Create and use `ToolStripDropDownItem.ReplaceDropDownItems` extension
This commit is contained in:
parent
5df9879842
commit
36cb62a792
|
@ -133,6 +133,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return tabControl.TabPages.Cast<TabPage>();
|
||||
}
|
||||
|
||||
public static void ReplaceDropDownItems(this ToolStripDropDownItem menu, params ToolStripItem[] items)
|
||||
{
|
||||
menu.DropDownItems.Clear();
|
||||
menu.DropDownItems.AddRange(items);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ListViewExtensions
|
||||
|
|
|
@ -115,10 +115,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentRomMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentRomSubMenu.DropDownItems.Clear();
|
||||
RecentRomSubMenu.DropDownItems.AddRange(Config.RecentRoms.RecentMenu(this, LoadRomFromRecent, "ROM", romLoading: true));
|
||||
}
|
||||
=> RecentRomSubMenu.ReplaceDropDownItems(Config.RecentRoms.RecentMenu(this, LoadRomFromRecent, "ROM", romLoading: true));
|
||||
|
||||
private bool HasSlot(int slot) => _stateSlots.HasSlot(Emulator, MovieSession.Movie, slot, SaveStatePrefix());
|
||||
|
||||
|
@ -248,10 +245,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentMovieSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentMovieSubMenu.DropDownItems.Clear();
|
||||
RecentMovieSubMenu.DropDownItems.AddRange(Config.RecentMovies.RecentMenu(this, LoadMoviesFromRecent, "Movie"));
|
||||
}
|
||||
=> RecentMovieSubMenu.ReplaceDropDownItems(Config.RecentMovies.RecentMenu(this, LoadMoviesFromRecent, "Movie"));
|
||||
|
||||
private void MovieEndSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -307,10 +307,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Settings.RecentBotFiles.RecentMenu(MainForm, LoadFileFromRecent, "Bot Parameters"));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(Settings.RecentBotFiles.RecentMenu(MainForm, LoadFileFromRecent, "Bot Parameters"));
|
||||
|
||||
private void NewMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -394,12 +391,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void MemoryDomainsMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
MemoryDomainsMenuItem.DropDownItems.Clear();
|
||||
MemoryDomainsMenuItem.DropDownItems.AddRange(
|
||||
MemoryDomains.MenuItems(SetMemoryDomain, _currentDomain.Name)
|
||||
.ToArray());
|
||||
}
|
||||
=> MemoryDomainsMenuItem.ReplaceDropDownItems(MemoryDomains.MenuItems(SetMemoryDomain, _currentDomain.Name).ToArray());
|
||||
|
||||
private void BigEndianMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -288,10 +288,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(_recent.RecentMenu(MainForm, LoadFile, "Session"));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(_recent.RecentMenu(MainForm, LoadFile, "Session"));
|
||||
|
||||
private void NewFileLogic()
|
||||
{
|
||||
|
|
|
@ -344,10 +344,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Config.Cheats.Recent.RecentMenu(MainForm, LoadFileFromRecent, "Cheats"));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(Config!.Cheats.Recent.RecentMenu(MainForm, LoadFileFromRecent, "Cheats"));
|
||||
|
||||
private void NewMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -1332,10 +1332,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentTablesSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentTablesSubMenu.DropDownItems.Clear();
|
||||
RecentTablesSubMenu.DropDownItems.AddRange(RecentTables.RecentMenu(MainForm, LoadFileFromRecent, "Session"));
|
||||
}
|
||||
=> RecentTablesSubMenu.ReplaceDropDownItems(RecentTables.RecentMenu(MainForm, LoadFileFromRecent, "Session"));
|
||||
|
||||
private void EditMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -1518,10 +1515,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void MemoryDomainsMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
MemoryDomainsMenuItem.DropDownItems.Clear();
|
||||
MemoryDomainsMenuItem.DropDownItems.AddRange(
|
||||
MemoryDomains.MenuItems(SetMemoryDomain, _domain.Name)
|
||||
.ToArray());
|
||||
MemoryDomainsMenuItem.ReplaceDropDownItems(MemoryDomains.MenuItems(SetMemoryDomain, _domain.Name).ToArray());
|
||||
|
||||
if (_romDomain != null)
|
||||
{
|
||||
|
|
|
@ -761,16 +761,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSessionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSessionsSubMenu.DropDownItems.Clear();
|
||||
RecentSessionsSubMenu.DropDownItems.AddRange(Config.RecentLuaSession.RecentMenu(MainForm, LoadSessionFromRecent, "Session"));
|
||||
}
|
||||
=> RecentSessionsSubMenu.ReplaceDropDownItems(Config!.RecentLuaSession.RecentMenu(MainForm, LoadSessionFromRecent, "Session"));
|
||||
|
||||
private void RecentScriptsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentScriptsSubMenu.DropDownItems.Clear();
|
||||
RecentScriptsSubMenu.DropDownItems.AddRange(Config.RecentLua.RecentMenu(MainForm, LoadLuaFile, "Script"));
|
||||
}
|
||||
=> RecentScriptsSubMenu.ReplaceDropDownItems(Config!.RecentLua.RecentMenu(MainForm, LoadLuaFile, "Script"));
|
||||
|
||||
private void NewSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -243,10 +243,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentToolStripMenuItem.DropDownItems.Clear();
|
||||
RecentToolStripMenuItem.DropDownItems.AddRange(Config.RecentMacros.RecentMenu(MainForm, DummyLoadMacro, "Macro"));
|
||||
}
|
||||
=> RecentToolStripMenuItem.ReplaceDropDownItems(Config!.RecentMacros.RecentMenu(MainForm, DummyLoadMacro, "Macro"));
|
||||
|
||||
private void DummyLoadMacro(string path)
|
||||
{
|
||||
|
|
|
@ -67,10 +67,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Settings.RecentTas.RecentMenu(MainForm, DummyLoadProject, "Project"));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(Settings.RecentTas.RecentMenu(MainForm, DummyLoadProject, "Project"));
|
||||
|
||||
private void NewTasMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -251,10 +248,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentMacrosMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
recentMacrosToolStripMenuItem.DropDownItems.Clear();
|
||||
recentMacrosToolStripMenuItem.DropDownItems.AddRange(Config.RecentMacros.RecentMenu(MainForm, DummyLoadMacro, "Macro", noAutoload: true));
|
||||
}
|
||||
=> recentMacrosToolStripMenuItem.ReplaceDropDownItems(Config!.RecentMacros.RecentMenu(MainForm, DummyLoadMacro, "Macro", noAutoload: true));
|
||||
|
||||
private void ToBk2MenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -971,10 +971,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Settings.RecentSearches.RecentMenu(MainForm, LoadFileFromRecent, "Search", noAutoload: true));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(Settings.RecentSearches.RecentMenu(MainForm, LoadFileFromRecent, "Search", noAutoload: true));
|
||||
|
||||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -1051,12 +1048,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
MemoryDomainsSubMenu.DropDownItems.Clear();
|
||||
MemoryDomainsSubMenu.DropDownItems.AddRange(
|
||||
MemoryDomains.MenuItems(SetMemoryDomain, _searches.Domain.Name, MaxSupportedSize)
|
||||
.ToArray());
|
||||
}
|
||||
=> MemoryDomainsSubMenu.ReplaceDropDownItems(MemoryDomains.MenuItems(SetMemoryDomain, _searches.Domain.Name, MaxSupportedSize).ToArray());
|
||||
|
||||
private void SizeSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -692,10 +692,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Config.RecentWatches.RecentMenu(MainForm, LoadFileFromRecent, "Watches"));
|
||||
}
|
||||
=> RecentSubMenu.ReplaceDropDownItems(Config!.RecentWatches.RecentMenu(MainForm, LoadFileFromRecent, "Watches"));
|
||||
|
||||
private void WatchesSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -725,12 +722,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
MemoryDomainsSubMenu.DropDownItems.Clear();
|
||||
MemoryDomainsSubMenu.DropDownItems.AddRange(
|
||||
MemoryDomains.MenuItems(SetMemoryDomain, CurrentDomain.Name)
|
||||
.ToArray());
|
||||
}
|
||||
=> MemoryDomainsSubMenu.ReplaceDropDownItems(MemoryDomains.MenuItems(SetMemoryDomain, CurrentDomain.Name).ToArray());
|
||||
|
||||
private void NewWatchMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue