Ram Watch - Hook up recent menu items

This commit is contained in:
andres.delikat 2011-01-19 04:41:21 +00:00
parent fadcd6c572
commit 99d9ece5fd
2 changed files with 108 additions and 21 deletions

View File

@ -38,7 +38,6 @@
this.appendFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.autoLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -60,6 +59,10 @@
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.listBox1 = new System.Windows.Forms.ListBox();
this.WatchCountLabel = new System.Windows.Forms.Label();
this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
@ -85,7 +88,6 @@
this.appendFileToolStripMenuItem,
this.recentToolStripMenuItem,
this.toolStripSeparator1,
this.autoLoadToolStripMenuItem,
this.saveWindowPositionToolStripMenuItem,
this.toolStripSeparator2,
this.exitToolStripMenuItem});
@ -136,22 +138,21 @@
//
// recentToolStripMenuItem
//
this.recentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem,
this.toolStripSeparator4,
this.clearToolStripMenuItem,
this.autoLoadToolStripMenuItem});
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.recentToolStripMenuItem.Text = "Recent";
this.recentToolStripMenuItem.DropDownOpened += new System.EventHandler(this.recentToolStripMenuItem_DropDownOpened);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(201, 6);
//
// autoLoadToolStripMenuItem
//
this.autoLoadToolStripMenuItem.Name = "autoLoadToolStripMenuItem";
this.autoLoadToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.autoLoadToolStripMenuItem.Text = "Auto-Load";
this.autoLoadToolStripMenuItem.Click += new System.EventHandler(this.autoLoadToolStripMenuItem_Click);
//
// saveWindowPositionToolStripMenuItem
//
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
@ -318,6 +319,29 @@
this.WatchCountLabel.TabIndex = 4;
this.WatchCountLabel.Text = "0 watches";
//
// noneToolStripMenuItem
//
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem.Text = "None";
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.clearToolStripMenuItem.Text = "Clear";
//
// autoLoadToolStripMenuItem
//
this.autoLoadToolStripMenuItem.Name = "autoLoadToolStripMenuItem";
this.autoLoadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.autoLoadToolStripMenuItem.Text = "Auto-Load";
//
// RamWatch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -353,7 +377,6 @@
private System.Windows.Forms.ToolStripMenuItem appendFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem autoLoadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
@ -374,5 +397,9 @@
private System.Windows.Forms.ColumnHeader Notes;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label WatchCountLabel;
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoLoadToolStripMenuItem;
}
}

View File

@ -42,6 +42,21 @@ namespace BizHawk.MultiClient
return count;
}
private void LoadWatchFromRecent(string file)
{
bool r = LoadWatchFile(file);
if (!r)
{
DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
Global.Config.RecentWatches.Remove(file);
}
//Debug
for (int x = 0; x < watchList.Count; x++)
TempDisplayWatchInTempList(watchList[x]);
}
bool LoadWatchFile(string path)
{
int y, z;
@ -98,8 +113,10 @@ namespace BizHawk.MultiClient
watchList.Add(w);
}
Global.Config.RecentWatches.Add(file.FullName);
//Update the number of watches
listBox1.Items.Clear();
listBox1.Items.Clear(); //Debug
WatchCountLabel.Text = count.ToString() + " watches";
}
@ -178,16 +195,7 @@ namespace BizHawk.MultiClient
private void autoLoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Global.Config.AutoLoadRamWatch == true)
{
Global.Config.AutoLoadRamWatch = false;
autoLoadToolStripMenuItem.Checked = false;
}
else
{
Global.Config.AutoLoadRamWatch = true;
autoLoadToolStripMenuItem.Checked = true;
}
UpdateAutoLoadRamWatch();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
@ -253,5 +261,57 @@ namespace BizHawk.MultiClient
else
autoLoadToolStripMenuItem.Checked = false;
}
private void UpdateAutoLoadRamWatch()
{
if (Global.Config.AutoLoadRamWatch == true)
{
Global.Config.AutoLoadRamWatch = false;
autoLoadToolStripMenuItem.Checked = false;
}
else
{
Global.Config.AutoLoadRamWatch = true;
autoLoadToolStripMenuItem.Checked = true;
}
}
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
//Clear out recent Roms list
//repopulate it with an up to date list
recentToolStripMenuItem.DropDownItems.Clear();
if (Global.Config.RecentWatches.IsEmpty())
{
recentToolStripMenuItem.DropDownItems.Add("None");
}
else
{
for (int x = 0; x < Global.Config.RecentWatches.Length(); x++)
{
string path = Global.Config.RecentWatches.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
item.Click += (o, ev) => LoadWatchFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item); //TODO: truncate this to a nice size
}
}
recentToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
clearitem.Click += (o, ev) => Global.Config.RecentRoms.Clear();
recentToolStripMenuItem.DropDownItems.Add(clearitem);
var auto = new ToolStripMenuItem();
auto.Text = "&Auto-Load";
auto.Click += (o, ev) => UpdateAutoLoadRamWatch();
if (Global.Config.AutoLoadRamWatch == true)
auto.Checked = true;
else
auto.Checked = false;
recentToolStripMenuItem.DropDownItems.Add(auto);
}
}
}