2011-01-18 03:36:43 +00:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Data ;
using System.Drawing ;
using System.Linq ;
using System.Text ;
using System.Windows.Forms ;
2011-01-18 17:17:14 +00:00
using System.IO ;
2011-01-19 02:49:47 +00:00
using System.Globalization ;
2011-01-18 03:36:43 +00:00
namespace BizHawk.MultiClient
{
2011-06-16 02:39:35 +00:00
/// <summary>
/// A winform designed to display ram address values of the user's choice
/// </summary>
public partial class RamWatch : Form
{
//TODO:
//When receiving a watch from a different domain, should something be done?
2011-06-19 19:10:01 +00:00
//when sorting, "Prev as Change" option not taken into account
2011-09-12 23:08:42 +00:00
//A GUI interface for setting the x,y coordinates of the ram watch display
//Allow each watch to be on or off screen, and on its own x,y
2011-06-16 02:39:35 +00:00
int defaultWidth ; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight ;
int defaultAddressWidth ;
int defaultValueWidth ;
int defaultPrevWidth ;
int defaultChangeWidth ;
2012-07-04 23:11:17 +00:00
int defaultDiffWidth ;
2012-09-10 02:37:44 +00:00
int defaultDomainWidth ;
2011-06-16 02:39:35 +00:00
int NotesWidth ;
string systemID = "NULL" ;
MemoryDomain Domain = new MemoryDomain ( "NULL" , 1 , Endian . Little , addr = > 0 , ( a , v ) = > { } ) ;
2012-09-03 23:42:00 +00:00
List < Watch > Watches = new List < Watch > ( ) ;
2012-06-07 03:16:25 +00:00
string currentFile = "" ;
2011-06-16 02:39:35 +00:00
bool changes = false ;
List < ToolStripMenuItem > domainMenuItems = new List < ToolStripMenuItem > ( ) ;
2011-08-27 13:20:02 +00:00
string addressFormatStr = "{0:X4} " ;
2011-06-16 02:39:35 +00:00
2011-06-19 19:10:01 +00:00
string sortedCol ;
bool sortReverse ;
2011-06-16 02:39:35 +00:00
public void Restart ( )
{
2012-08-15 01:35:17 +00:00
if ( ( ! this . IsHandleCreated | | this . IsDisposed ) & & ! Global . Config . DisplayRamWatch )
{
return ;
}
2012-06-07 03:16:25 +00:00
if ( currentFile . Length > 0 )
2012-08-15 01:35:17 +00:00
{
2012-06-07 03:16:25 +00:00
LoadWatchFile ( currentFile , false ) ;
2012-08-15 01:35:17 +00:00
}
2011-08-20 15:41:33 +00:00
else
2012-08-15 01:35:17 +00:00
{
2011-08-20 15:41:33 +00:00
NewWatchList ( true ) ;
2012-08-15 01:35:17 +00:00
}
2011-06-16 02:39:35 +00:00
}
public List < Watch > GetRamWatchList ( )
{
List < Watch > w = new List < Watch > ( ) ;
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
2012-09-04 00:33:47 +00:00
{
2012-09-03 23:42:00 +00:00
w . Add ( new Watch ( Watches [ x ] ) ) ;
2012-09-04 00:33:47 +00:00
}
2011-06-16 02:39:35 +00:00
return w ;
}
public void DisplayWatchList ( )
{
2012-09-03 23:42:00 +00:00
WatchListView . ItemCount = Watches . Count ;
2011-06-16 02:39:35 +00:00
}
public void UpdateValues ( )
{
2012-08-15 01:35:17 +00:00
if ( ( ! this . IsHandleCreated | | this . IsDisposed ) & & ! Global . Config . DisplayRamWatch )
{
return ;
}
2011-09-12 23:08:42 +00:00
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
2011-06-16 02:39:35 +00:00
{
2012-09-04 00:33:47 +00:00
Watches [ x ] . PeekAddress ( ) ;
2011-06-16 02:39:35 +00:00
}
2011-09-12 23:08:42 +00:00
if ( Global . Config . DisplayRamWatch )
{
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
2011-09-12 23:08:42 +00:00
{
2012-09-03 23:42:00 +00:00
bool alert = Global . CheatList . IsActiveCheat ( Domain , Watches [ x ] . Address ) ;
Global . OSD . AddGUIText ( Watches [ x ] . ToString ( ) ,
2012-06-10 23:27:30 +00:00
Global . Config . DispRamWatchx , ( Global . Config . DispRamWatchy + ( x * 14 ) ) , alert , Color . Black , Color . White , 0 ) ;
2011-09-12 23:08:42 +00:00
}
}
if ( ! this . IsHandleCreated | | this . IsDisposed ) return ;
WatchListView . BlazingFast = true ;
2011-06-16 02:39:35 +00:00
WatchListView . Refresh ( ) ;
2011-08-04 02:28:25 +00:00
WatchListView . BlazingFast = false ;
2011-06-16 02:39:35 +00:00
}
public void AddWatch ( Watch w )
{
2012-09-03 23:42:00 +00:00
Watches . Add ( w ) ;
2011-09-10 21:37:03 +00:00
Changes ( ) ;
2011-08-25 01:22:03 +00:00
UpdateValues ( ) ;
2011-09-10 21:16:29 +00:00
DisplayWatchList ( ) ;
2011-06-16 02:39:35 +00:00
}
private void LoadConfigSettings ( )
{
ColumnPositionSet ( ) ;
defaultWidth = Size . Width ; //Save these first so that the user can restore to its original size
defaultHeight = Size . Height ;
defaultAddressWidth = WatchListView . Columns [ Global . Config . RamWatchAddressIndex ] . Width ;
defaultValueWidth = WatchListView . Columns [ Global . Config . RamWatchValueIndex ] . Width ;
defaultPrevWidth = WatchListView . Columns [ Global . Config . RamWatchPrevIndex ] . Width ;
defaultChangeWidth = WatchListView . Columns [ Global . Config . RamWatchChangeIndex ] . Width ;
2012-07-04 23:11:17 +00:00
defaultDiffWidth = WatchListView . Columns [ Global . Config . RamWatchDiffIndex ] . Width ;
2012-09-10 02:37:44 +00:00
defaultDomainWidth = WatchListView . Columns [ Global . Config . RamWatchDomainIndex ] . Width ;
2011-06-16 02:39:35 +00:00
NotesWidth = WatchListView . Columns [ Global . Config . RamWatchNotesIndex ] . Width ;
if ( Global . Config . RamWatchSaveWindowPosition & & Global . Config . RamWatchWndx > = 0 & & Global . Config . RamWatchWndy > = 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Location = new Point ( Global . Config . RamWatchWndx , Global . Config . RamWatchWndy ) ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchWidth > = 0 & & Global . Config . RamWatchHeight > = 0 )
{
Size = new System . Drawing . Size ( Global . Config . RamWatchWidth , Global . Config . RamWatchHeight ) ;
}
SetPrevColumn ( Global . Config . RamWatchShowPrevColumn ) ;
SetChangesColumn ( Global . Config . RamWatchShowChangeColumn ) ;
2012-07-05 01:58:33 +00:00
SetDiffColumn ( Global . Config . RamWatchShowDiffColumn ) ;
2012-09-15 14:35:13 +00:00
SetDomainColumn ( Global . Config . RamWatchShowDomainColumn ) ;
2012-09-10 02:37:44 +00:00
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchAddressWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ Global . Config . RamWatchAddressIndex ] . Width = Global . Config . RamWatchAddressWidth ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchValueWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ Global . Config . RamWatchValueIndex ] . Width = Global . Config . RamWatchValueWidth ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchPrevWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ Global . Config . RamWatchPrevIndex ] . Width = Global . Config . RamWatchPrevWidth ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchChangeWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ Global . Config . RamWatchChangeIndex ] . Width = Global . Config . RamWatchChangeWidth ;
2012-09-10 02:37:44 +00:00
}
2012-07-04 23:11:17 +00:00
if ( Global . Config . RamWatchDiffWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2012-07-04 23:11:17 +00:00
WatchListView . Columns [ Global . Config . RamWatchDiffIndex ] . Width = Global . Config . RamWatchDiffWidth ;
2012-09-10 02:37:44 +00:00
}
if ( Global . Config . RamWatchDomainWidth > 0 )
{
WatchListView . Columns [ Global . Config . RamWatchDomainIndex ] . Width = Global . Config . RamWatchDomainWidth ;
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchNotesWidth > 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ Global . Config . RamWatchNotesIndex ] . Width = Global . Config . RamWatchNotesWidth ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
}
public void SaveConfigSettings ( )
{
ColumnPositionSet ( ) ;
Global . Config . RamWatchAddressWidth = WatchListView . Columns [ Global . Config . RamWatchAddressIndex ] . Width ;
Global . Config . RamWatchValueWidth = WatchListView . Columns [ Global . Config . RamWatchValueIndex ] . Width ;
Global . Config . RamWatchPrevWidth = WatchListView . Columns [ Global . Config . RamWatchPrevIndex ] . Width ;
Global . Config . RamWatchChangeWidth = WatchListView . Columns [ Global . Config . RamWatchChangeIndex ] . Width ;
2012-07-04 23:11:17 +00:00
Global . Config . RamWatchDiffWidth = WatchListView . Columns [ Global . Config . RamWatchDiffIndex ] . Width ;
2012-09-10 02:37:44 +00:00
Global . Config . RamWatchDomainWidth = WatchListView . Columns [ Global . Config . RamWatchDomainIndex ] . Width ;
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchNotesWidth = WatchListView . Columns [ Global . Config . RamWatchNotesIndex ] . Width ;
Global . Config . RamWatchWndx = this . Location . X ;
Global . Config . RamWatchWndy = this . Location . Y ;
Global . Config . RamWatchWidth = this . Right - this . Left ;
Global . Config . RamWatchHeight = this . Bottom - this . Top ;
}
public RamWatch ( )
{
InitializeComponent ( ) ;
WatchListView . QueryItemText + = new QueryItemTextHandler ( WatchListView_QueryItemText ) ;
WatchListView . QueryItemBkColor + = new QueryItemBkColorHandler ( WatchListView_QueryItemBkColor ) ;
WatchListView . VirtualMode = true ;
Closing + = ( o , e ) = > SaveConfigSettings ( ) ;
2011-06-19 19:10:01 +00:00
sortReverse = false ;
sortedCol = "" ;
2011-06-16 02:39:35 +00:00
}
protected override void OnClosing ( CancelEventArgs e )
{
if ( ! AskSave ( ) )
e . Cancel = true ;
base . OnClosing ( e ) ;
}
2011-09-12 00:17:17 +00:00
2011-06-16 02:39:35 +00:00
private void WatchListView_QueryItemBkColor ( int index , int column , ref Color color )
{
2012-09-03 23:42:00 +00:00
if ( index > = Watches . Count )
2012-08-15 00:56:34 +00:00
{
return ;
}
2011-08-27 13:56:06 +00:00
if ( column = = 0 )
{
2012-09-03 23:42:00 +00:00
if ( Watches [ index ] . Type = = Watch . TYPE . SEPARATOR )
{
2011-08-27 13:56:06 +00:00
color = this . BackColor ;
2012-09-03 23:42:00 +00:00
}
if ( Global . CheatList . IsActiveCheat ( Domain , Watches [ index ] . Address ) )
{
2011-08-27 13:56:06 +00:00
color = Color . LightCyan ;
2012-09-03 23:42:00 +00:00
}
2011-08-27 13:56:06 +00:00
}
2011-06-16 02:39:35 +00:00
}
void WatchListView_QueryItemText ( int index , int column , out string text )
{
text = "" ;
2012-09-03 23:42:00 +00:00
if ( Watches [ index ] . Type = = Watch . TYPE . SEPARATOR | | index > = Watches . Count )
2012-08-15 00:56:34 +00:00
{
return ;
}
2012-09-10 02:37:44 +00:00
switch ( column )
2011-06-16 02:39:35 +00:00
{
2012-09-10 02:37:44 +00:00
case 0 :
text = Watches [ index ] . Address . ToString ( addressFormatStr ) ;
break ;
case 1 :
switch ( Global . Config . RamWatchPrev_Type )
{
case 1 :
text = Watches [ index ] . PrevString ;
break ;
case 2 :
text = Watches [ index ] . LastChangeString ;
break ;
}
break ;
case 2 :
switch ( Global . Config . RamWatchPrev_Type )
{
case 1 :
text = Watches [ index ] . PrevString ;
break ;
case 2 :
text = Watches [ index ] . LastChangeString ;
break ;
}
break ;
case 3 :
text = Watches [ index ] . Changecount . ToString ( ) ;
break ;
case 4 :
switch ( Global . Config . RamWatchPrev_Type )
{
case 1 :
text = Watches [ index ] . DiffToString ( Watches [ index ] . DiffPrev ) ;
break ;
case 2 :
text = Watches [ index ] . DiffToString ( Watches [ index ] . DiffLastChange ) ;
break ;
}
break ;
case 5 :
text = Watches [ index ] . Domain . Name ;
break ;
case 6 :
text = Watches [ index ] . Notes ;
break ;
2011-06-16 02:39:35 +00:00
}
}
public bool AskSave ( )
{
2012-07-10 17:22:23 +00:00
if ( Global . Config . SupressAskSave ) //User has elected to not be nagged
{
return true ;
}
2011-06-16 02:39:35 +00:00
if ( changes )
{
2011-09-12 23:14:57 +00:00
Global . Sound . StopSound ( ) ;
2011-06-16 02:39:35 +00:00
DialogResult result = MessageBox . Show ( "Save Changes?" , "Ram Watch" , MessageBoxButtons . YesNoCancel , MessageBoxIcon . Question , MessageBoxDefaultButton . Button3 ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StartSound ( ) ;
2011-06-16 02:39:35 +00:00
if ( result = = DialogResult . Yes )
{
2012-06-07 03:16:25 +00:00
if ( string . Compare ( currentFile , "" ) = = 0 )
2011-06-16 02:39:35 +00:00
{
SaveAs ( ) ;
}
else
2012-06-07 03:16:25 +00:00
SaveWatchFile ( currentFile ) ;
2011-06-16 02:39:35 +00:00
return true ;
}
else if ( result = = DialogResult . No )
return true ;
else if ( result = = DialogResult . Cancel )
return false ;
}
return true ;
}
public void LoadWatchFromRecent ( string file )
{
bool z = true ;
if ( changes ) z = AskSave ( ) ;
if ( z )
{
bool r = LoadWatchFile ( file , false ) ;
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 ) ;
}
DisplayWatchList ( ) ;
changes = false ;
}
}
private void NewWatchList ( bool suppressAsk )
{
bool result = true ;
if ( changes ) result = AskSave ( ) ;
if ( result = = true | | suppressAsk )
{
2012-09-03 23:42:00 +00:00
Watches . Clear ( ) ;
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
2012-06-09 21:57:00 +00:00
UpdateWatchCount ( ) ;
2012-06-07 03:16:25 +00:00
currentFile = "" ;
2011-06-16 02:39:35 +00:00
changes = false ;
MessageLabel . Text = "" ;
2011-06-19 19:10:01 +00:00
sortReverse = false ;
sortedCol = "" ;
2011-06-16 02:39:35 +00:00
}
}
private bool SaveWatchFile ( string path )
{
2012-09-03 23:42:00 +00:00
return WatchCommon . SaveWchFile ( path , Domain . Name , Watches ) ;
2011-06-16 02:39:35 +00:00
}
2012-06-09 21:57:00 +00:00
private void UpdateWatchCount ( )
{
int count = 0 ;
2012-09-03 23:42:00 +00:00
foreach ( Watch w in Watches )
2012-06-09 21:57:00 +00:00
{
2012-09-03 23:42:00 +00:00
if ( ! ( w . Type = = Watch . TYPE . SEPARATOR ) )
2012-06-09 21:57:00 +00:00
{
count + + ;
}
}
WatchCountLabel . Text = count . ToString ( ) + ( count = = 1 ? " watch" : " watches" ) ;
}
2011-06-16 02:39:35 +00:00
public bool LoadWatchFile ( string path , bool append )
{
2012-06-07 03:16:25 +00:00
string domain = "" ;
2012-09-03 23:42:00 +00:00
bool result = WatchCommon . LoadWatchFile ( path , append , Watches , out domain ) ;
2011-06-16 02:39:35 +00:00
2012-06-07 03:16:25 +00:00
if ( result )
2011-06-16 02:39:35 +00:00
{
2012-09-03 23:42:00 +00:00
foreach ( Watch w in Watches )
2012-06-10 17:45:20 +00:00
{
InitializeAddress ( w ) ;
}
2011-06-16 02:39:35 +00:00
if ( ! append )
{
2012-06-07 03:16:25 +00:00
currentFile = path ;
2011-06-16 02:39:35 +00:00
}
changes = false ;
2012-06-07 03:16:25 +00:00
MessageLabel . Text = Path . GetFileNameWithoutExtension ( path ) ;
2012-06-09 21:57:00 +00:00
UpdateWatchCount ( ) ;
2012-06-07 03:16:25 +00:00
Global . Config . RecentWatches . Add ( path ) ;
SetMemoryDomain ( WatchCommon . GetDomainPos ( domain ) ) ;
return true ;
2011-06-16 02:39:35 +00:00
2012-06-07 03:16:25 +00:00
}
else
return false ;
2011-06-16 02:39:35 +00:00
}
private Point GetPromptPoint ( )
{
Point p = new Point ( WatchListView . Location . X , WatchListView . Location . Y ) ;
Point q = new Point ( ) ;
q = PointToScreen ( p ) ;
return q ;
}
2012-06-10 17:45:20 +00:00
private void AddNewWatch ( )
2011-06-16 02:39:35 +00:00
{
RamWatchNewWatch r = new RamWatchNewWatch ( ) ;
r . location = GetPromptPoint ( ) ;
2012-09-10 02:03:24 +00:00
Watch w = new Watch ( ) ;
w . Domain = Domain ;
r . SetWatch ( w ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StopSound ( ) ;
2011-06-16 02:39:35 +00:00
r . ShowDialog ( ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StartSound ( ) ;
2012-09-10 02:03:24 +00:00
if ( r . SelectionWasMade = = true )
2011-06-16 02:39:35 +00:00
{
2012-09-10 02:03:24 +00:00
InitializeAddress ( r . Watch ) ;
Watches . Add ( r . Watch ) ;
2011-07-09 00:26:23 +00:00
Changes ( ) ;
2012-06-09 21:57:00 +00:00
UpdateWatchCount ( ) ;
2012-06-10 17:45:20 +00:00
DisplayWatchList ( ) ;
2011-06-16 02:39:35 +00:00
}
}
2012-06-10 17:45:20 +00:00
private void InitializeAddress ( Watch w )
{
2012-09-04 00:33:47 +00:00
w . PeekAddress ( ) ;
2012-09-03 23:42:00 +00:00
w . Prev = w . Value ;
w . Original = w . Value ;
w . LastChange = w . Value ;
w . LastSearch = w . Value ;
w . Changecount = 0 ;
2012-06-10 17:45:20 +00:00
}
2011-06-16 02:39:35 +00:00
void Changes ( )
{
changes = true ;
2012-06-07 03:16:25 +00:00
MessageLabel . Text = Path . GetFileName ( currentFile ) + " *" ;
2011-06-16 02:39:35 +00:00
}
void EditWatchObject ( int pos )
{
RamWatchNewWatch r = new RamWatchNewWatch ( ) ;
r . location = GetPromptPoint ( ) ;
2012-09-10 02:03:24 +00:00
r . SetWatch ( Watches [ pos ] , "Edit Watch" ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StopSound ( ) ;
2011-06-16 02:39:35 +00:00
r . ShowDialog ( ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StartSound ( ) ;
2011-06-16 02:39:35 +00:00
2012-09-10 02:03:24 +00:00
if ( r . SelectionWasMade = = true )
2011-06-16 02:39:35 +00:00
{
Changes ( ) ;
2012-09-10 02:03:24 +00:00
Watches [ pos ] = r . Watch ;
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
}
}
void EditWatch ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
2012-09-10 02:03:24 +00:00
2011-06-16 02:39:35 +00:00
if ( indexes . Count > 0 )
2012-09-10 02:03:24 +00:00
{
2011-06-16 02:39:35 +00:00
EditWatchObject ( indexes [ 0 ] ) ;
2012-09-10 02:03:24 +00:00
}
2011-09-10 21:16:29 +00:00
UpdateValues ( ) ;
2011-06-16 02:39:35 +00:00
}
void RemoveWatch ( )
{
Changes ( ) ;
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
foreach ( int index in indexes )
{
2012-09-03 23:42:00 +00:00
Watches . Remove ( Watches [ indexes [ 0 ] ] ) ; //index[0] used since each iteration will make this the correct list index
2011-06-16 02:39:35 +00:00
}
2011-08-17 00:26:34 +00:00
indexes . Clear ( ) ;
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
}
2011-09-10 21:16:29 +00:00
UpdateValues ( ) ;
2012-06-09 21:57:00 +00:00
UpdateWatchCount ( ) ;
2011-06-16 02:39:35 +00:00
}
void DuplicateWatch ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
RamWatchNewWatch r = new RamWatchNewWatch ( ) ;
r . location = GetPromptPoint ( ) ;
2012-09-10 02:03:24 +00:00
r . SetWatch ( Watches [ indexes [ 0 ] ] , "Duplicate Watch" ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StopSound ( ) ;
2011-06-16 02:39:35 +00:00
r . ShowDialog ( ) ;
2011-09-12 23:14:57 +00:00
Global . Sound . StartSound ( ) ;
2011-06-16 02:39:35 +00:00
2012-09-10 02:03:24 +00:00
if ( r . SelectionWasMade = = true )
2011-06-16 02:39:35 +00:00
{
2012-09-10 02:03:24 +00:00
InitializeAddress ( r . Watch ) ;
2011-06-16 02:39:35 +00:00
Changes ( ) ;
2012-09-10 02:03:24 +00:00
Watches . Add ( r . Watch ) ;
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
}
}
2011-09-10 21:16:29 +00:00
UpdateValues ( ) ;
2012-06-09 21:57:00 +00:00
UpdateWatchCount ( ) ;
2011-06-16 02:39:35 +00:00
}
void MoveUp ( )
{
if ( WatchListView . SelectedIndices . Count = = 0 )
return ;
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
2012-03-26 23:38:29 +00:00
if ( indexes [ 0 ] = = 0 )
return ;
2011-06-16 02:39:35 +00:00
Watch temp = new Watch ( ) ;
if ( indexes . Count = = 0 ) return ;
foreach ( int index in indexes )
{
2012-09-03 23:42:00 +00:00
temp = Watches [ index ] ;
Watches . Remove ( Watches [ index ] ) ;
Watches . Insert ( index - 1 , temp ) ;
2011-06-16 02:39:35 +00:00
//Note: here it will get flagged many times redundantly potentially,
//but this avoids it being flagged falsely when the user did not select an index
Changes ( ) ;
}
List < int > i = new List < int > ( ) ;
for ( int z = 0 ; z < indexes . Count ; z + + )
2012-09-04 00:33:47 +00:00
{
2011-06-16 02:39:35 +00:00
i . Add ( indexes [ z ] - 1 ) ;
2012-09-04 00:33:47 +00:00
}
2011-06-16 02:39:35 +00:00
WatchListView . SelectedIndices . Clear ( ) ;
for ( int z = 0 ; z < i . Count ; z + + )
2012-09-04 00:33:47 +00:00
{
2011-06-16 02:39:35 +00:00
WatchListView . SelectItem ( i [ z ] , true ) ;
2012-09-04 00:33:47 +00:00
}
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
}
void MoveDown ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
Watch temp = new Watch ( ) ;
if ( indexes . Count = = 0 ) return ;
foreach ( int index in indexes )
{
2012-09-03 23:42:00 +00:00
temp = Watches [ index ] ;
2011-06-16 02:39:35 +00:00
2012-09-03 23:42:00 +00:00
if ( index < Watches . Count - 1 )
2011-06-16 02:39:35 +00:00
{
2012-09-03 23:42:00 +00:00
Watches . Remove ( Watches [ index ] ) ;
Watches . Insert ( index + 1 , temp ) ;
2011-06-16 02:39:35 +00:00
}
//Note: here it will get flagged many times redundantly potnetially,
//but this avoids it being flagged falsely when the user did not select an index
Changes ( ) ;
}
List < int > i = new List < int > ( ) ;
for ( int z = 0 ; z < indexes . Count ; z + + )
i . Add ( indexes [ z ] + 1 ) ;
WatchListView . SelectedIndices . Clear ( ) ;
for ( int z = 0 ; z < i . Count ; z + + )
WatchListView . SelectItem ( i [ z ] , true ) ;
DisplayWatchList ( ) ;
}
private void exitToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( ! AskSave ( ) )
return ;
this . Close ( ) ;
}
private void newListToolStripMenuItem_Click ( object sender , EventArgs e )
{
NewWatchList ( false ) ;
}
private FileInfo GetFileFromUser ( )
{
var ofd = new OpenFileDialog ( ) ;
2012-06-07 03:16:25 +00:00
if ( currentFile . Length > 0 )
ofd . FileName = Path . GetFileNameWithoutExtension ( currentFile ) ;
2011-06-16 02:39:35 +00:00
ofd . InitialDirectory = PathManager . MakeAbsolutePath ( Global . Config . WatchPath , "" ) ;
ofd . Filter = "Watch Files (*.wch)|*.wch|All Files|*.*" ;
ofd . RestoreDirectory = true ;
Global . Sound . StopSound ( ) ;
var result = ofd . ShowDialog ( ) ;
Global . Sound . StartSound ( ) ;
if ( result ! = DialogResult . OK )
return null ;
var file = new FileInfo ( ofd . FileName ) ;
return file ;
}
private void OpenWatchFile ( )
{
var file = GetFileFromUser ( ) ;
if ( file ! = null )
{
bool r = true ;
if ( changes ) r = AskSave ( ) ;
if ( r )
{
LoadWatchFile ( file . FullName , false ) ;
DisplayWatchList ( ) ;
}
}
}
private void openToolStripMenuItem_Click ( object sender , EventArgs e )
{
OpenWatchFile ( ) ;
}
private void saveToolStripMenuItem_Click ( object sender , EventArgs e )
{
2012-06-07 03:16:25 +00:00
if ( string . Compare ( currentFile , "" ) = = 0 )
2012-06-02 22:06:00 +00:00
{
SaveAs ( ) ;
}
else if ( changes )
2011-06-26 18:56:56 +00:00
{
2012-06-07 03:16:25 +00:00
SaveWatchFile ( currentFile ) ;
MessageLabel . Text = Path . GetFileName ( currentFile ) + " saved." ;
2011-06-26 18:56:56 +00:00
}
2011-06-16 02:39:35 +00:00
}
private void SaveAs ( )
{
2012-06-07 03:16:25 +00:00
var file = WatchCommon . GetSaveFileFromUser ( currentFile ) ;
2011-06-16 02:39:35 +00:00
if ( file ! = null )
{
SaveWatchFile ( file . FullName ) ;
2012-06-07 03:16:25 +00:00
currentFile = file . FullName ;
MessageLabel . Text = Path . GetFileName ( currentFile ) + " saved." ;
2011-06-26 19:01:06 +00:00
Global . Config . RecentWatches . Add ( file . FullName ) ;
2011-06-16 02:39:35 +00:00
}
}
private void saveAsToolStripMenuItem_Click ( object sender , EventArgs e )
{
SaveAs ( ) ;
}
private void appendFileToolStripMenuItem_Click ( object sender , EventArgs e )
{
var file = GetFileFromUser ( ) ;
if ( file ! = null )
LoadWatchFile ( file . FullName , true ) ;
DisplayWatchList ( ) ;
Changes ( ) ;
}
private void autoLoadToolStripMenuItem_Click ( object sender , EventArgs e )
{
UpdateAutoLoadRamWatch ( ) ;
}
private void newWatchToolStripMenuItem_Click ( object sender , EventArgs e )
{
AddNewWatch ( ) ;
}
private void editWatchToolStripMenuItem_Click ( object sender , EventArgs e )
{
EditWatch ( ) ;
}
private void removeWatchToolStripMenuItem_Click ( object sender , EventArgs e )
{
RemoveWatch ( ) ;
}
private void duplicateWatchToolStripMenuItem_Click ( object sender , EventArgs e )
{
DuplicateWatch ( ) ;
}
private void moveUpToolStripMenuItem_Click ( object sender , EventArgs e )
{
MoveUp ( ) ;
}
private void moveDownToolStripMenuItem_Click ( object sender , EventArgs e )
{
MoveDown ( ) ;
}
private void RamWatch_Load ( object sender , EventArgs e )
{
LoadConfigSettings ( ) ;
SetMemoryDomainMenu ( ) ;
}
private void filesToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
if ( Global . Config . AutoLoadRamWatch = = true )
autoLoadToolStripMenuItem . Checked = true ;
else
autoLoadToolStripMenuItem . Checked = false ;
2012-06-02 22:06:00 +00:00
if ( ! changes )
2011-06-16 02:39:35 +00:00
{
saveToolStripMenuItem . Enabled = false ;
}
else
{
saveToolStripMenuItem . Enabled = true ;
}
}
private void UpdateAutoLoadRamWatch ( )
{
autoLoadToolStripMenuItem . Checked = Global . Config . AutoLoadRamWatch ^ = 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 ( ) )
{
var none = new ToolStripMenuItem ( ) ;
none . Enabled = false ;
none . Text = "None" ;
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 ) ;
}
}
recentToolStripMenuItem . DropDownItems . Add ( "-" ) ;
var clearitem = new ToolStripMenuItem ( ) ;
clearitem . Text = "&Clear" ;
clearitem . Click + = ( o , ev ) = > Global . Config . RecentWatches . 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 ) ;
}
private void WatchListView_AfterLabelEdit ( object sender , LabelEditEventArgs e )
{
if ( e . Label = = null ) //If no change
return ;
string Str = e . Label . ToUpper ( ) . Trim ( ) ;
int index = e . Item ;
if ( InputValidate . IsValidHexNumber ( Str ) )
{
2012-09-03 23:42:00 +00:00
Watches [ e . Item ] . Address = int . Parse ( Str , NumberStyles . HexNumber ) ;
2011-06-16 02:39:35 +00:00
EditWatchObject ( index ) ;
}
else
{
MessageBox . Show ( "Invalid number!" ) ; //TODO: More parameters and better message
2012-09-03 23:42:00 +00:00
WatchListView . Items [ index ] . Text = Watches [ index ] . Address . ToString ( ) ; //TODO: Why doesn't the list view update to the new value? It won't until something else changes
2011-06-16 02:39:35 +00:00
}
}
private void restoreWindowSizeToolStripMenuItem_Click ( object sender , EventArgs e )
{
this . Size = new System . Drawing . Size ( defaultWidth , defaultHeight ) ;
Global . Config . RamWatchAddressIndex = 0 ;
Global . Config . RamWatchValueIndex = 1 ;
Global . Config . RamWatchPrevIndex = 2 ;
Global . Config . RamWatchChangeIndex = 3 ;
2012-07-04 23:11:17 +00:00
Global . Config . RamWatchDiffIndex = 4 ;
Global . Config . RamWatchNotesIndex = 5 ;
2011-06-16 02:39:35 +00:00
ColumnPositionSet ( ) ;
showPreviousValueToolStripMenuItem . Checked = false ;
Global . Config . RamWatchShowPrevColumn = false ;
showChangeCountsToolStripMenuItem . Checked = true ;
Global . Config . RamWatchShowChangeColumn = true ;
2012-07-04 23:11:17 +00:00
Global . Config . RamWatchShowDiffColumn = false ;
2012-09-15 14:35:13 +00:00
Global . Config . RamWatchShowDomainColumn = true ;
2012-07-05 03:21:39 +00:00
WatchListView . Columns [ 0 ] . Width = 60 ;
WatchListView . Columns [ 1 ] . Width = 59 ;
2011-06-16 02:39:35 +00:00
WatchListView . Columns [ 2 ] . Width = 0 ;
2012-07-05 03:21:39 +00:00
WatchListView . Columns [ 3 ] . Width = 55 ;
2012-07-04 23:11:17 +00:00
WatchListView . Columns [ 4 ] . Width = 0 ;
2012-09-10 02:37:44 +00:00
WatchListView . Columns [ 5 ] . Width = 55 ;
WatchListView . Columns [ 6 ] . Width = 128 ;
2012-06-19 00:27:57 +00:00
Global . Config . DisplayRamWatch = false ;
Global . Config . RamWatchSaveWindowPosition = false ;
2011-06-16 02:39:35 +00:00
}
private void newToolStripButton_Click ( object sender , EventArgs e )
{
NewWatchList ( false ) ;
}
private void openToolStripButton_Click ( object sender , EventArgs e )
{
OpenWatchFile ( ) ;
}
private void saveToolStripButton_Click ( object sender , EventArgs e )
{
2012-06-07 03:16:25 +00:00
if ( changes & & currentFile . Length > 0 )
2011-06-16 02:39:35 +00:00
{
2012-06-07 03:16:25 +00:00
SaveWatchFile ( currentFile ) ;
2011-06-16 02:39:35 +00:00
}
else
{
SaveAs ( ) ;
}
}
private void InsertSeparator ( )
{
2012-06-02 22:06:00 +00:00
Changes ( ) ;
2011-06-16 02:39:35 +00:00
Watch w = new Watch ( ) ;
2012-09-03 23:42:00 +00:00
w . Type = Watch . TYPE . SEPARATOR ;
2011-06-16 02:39:35 +00:00
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
int x ;
if ( indexes . Count > 0 )
{
x = indexes [ 0 ] ;
if ( indexes [ 0 ] > 0 )
2012-09-03 23:42:00 +00:00
Watches . Insert ( indexes [ 0 ] , w ) ;
2011-06-16 02:39:35 +00:00
}
else
2012-09-04 00:33:47 +00:00
{
2012-09-03 23:42:00 +00:00
Watches . Add ( w ) ;
2012-09-04 00:33:47 +00:00
}
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
}
private void cutToolStripButton_Click ( object sender , EventArgs e )
{
RemoveWatch ( ) ;
}
private void NewWatchStripButton1_Click ( object sender , EventArgs e )
{
AddNewWatch ( ) ;
}
private void MoveUpStripButton1_Click ( object sender , EventArgs e )
{
MoveUp ( ) ;
}
private void MoveDownStripButton1_Click ( object sender , EventArgs e )
{
MoveDown ( ) ;
}
private void EditWatchToolStripButton1_Click ( object sender , EventArgs e )
{
EditWatch ( ) ;
}
private void DuplicateWatchToolStripButton_Click ( object sender , EventArgs e )
{
DuplicateWatch ( ) ;
}
private void toolStripButton1_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void insertSeparatorToolStripMenuItem_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void PoketoolStripButton2_Click ( object sender , EventArgs e )
{
PokeAddress ( ) ;
}
private void PokeAddress ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
2011-09-12 23:14:57 +00:00
Global . Sound . StopSound ( ) ;
2011-06-16 02:39:35 +00:00
RamPoke p = new RamPoke ( ) ;
2012-06-02 21:07:29 +00:00
Global . Sound . StartSound ( ) ;
2011-06-16 02:39:35 +00:00
if ( indexes . Count > 0 )
2012-09-04 00:33:47 +00:00
{
p . SetWatchObject ( Watches [ indexes [ 0 ] ] ) ;
}
2011-06-16 02:39:35 +00:00
p . location = GetPromptPoint ( ) ;
p . ShowDialog ( ) ;
2012-06-02 21:07:29 +00:00
UpdateValues ( ) ;
2011-06-16 02:39:35 +00:00
}
private void pokeAddressToolStripMenuItem_Click ( object sender , EventArgs e )
{
PokeAddress ( ) ;
}
private void watchesToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
editWatchToolStripMenuItem . Enabled = true ;
duplicateWatchToolStripMenuItem . Enabled = true ;
removeWatchToolStripMenuItem . Enabled = true ;
moveUpToolStripMenuItem . Enabled = true ;
moveDownToolStripMenuItem . Enabled = true ;
pokeAddressToolStripMenuItem . Enabled = true ;
freezeAddressToolStripMenuItem . Enabled = true ;
}
else
{
editWatchToolStripMenuItem . Enabled = false ;
duplicateWatchToolStripMenuItem . Enabled = false ;
removeWatchToolStripMenuItem . Enabled = false ;
moveUpToolStripMenuItem . Enabled = false ;
moveDownToolStripMenuItem . Enabled = false ;
pokeAddressToolStripMenuItem . Enabled = false ;
freezeAddressToolStripMenuItem . Enabled = false ;
}
}
private void editToolStripMenuItem_Click ( object sender , EventArgs e )
{
EditWatch ( ) ;
}
private void removeToolStripMenuItem_Click ( object sender , EventArgs e )
{
RemoveWatch ( ) ;
}
private void duplicateToolStripMenuItem_Click ( object sender , EventArgs e )
{
DuplicateWatch ( ) ;
}
private void pokeToolStripMenuItem_Click ( object sender , EventArgs e )
{
PokeAddress ( ) ;
}
private void insertSeperatorToolStripMenuItem_Click ( object sender , EventArgs e )
{
InsertSeparator ( ) ;
}
private void moveUpToolStripMenuItem1_Click ( object sender , EventArgs e )
{
MoveUp ( ) ;
}
private void moveDownToolStripMenuItem1_Click ( object sender , EventArgs e )
{
MoveDown ( ) ;
}
private void contextMenuStrip1_Opening ( object sender , CancelEventArgs e )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count = = 0 )
{
2012-09-23 15:19:58 +00:00
editToolStripMenuItem . Visible = false ;
removeToolStripMenuItem . Visible = false ;
duplicateToolStripMenuItem . Visible = false ;
pokeToolStripMenuItem . Visible = false ;
freezeToolStripMenuItem . Visible = false ;
viewInHexEditorToolStripMenuItem . Visible = false ;
toolStripSeparator6 . Visible = false ;
insertSeperatorToolStripMenuItem . Visible = false ;
moveUpToolStripMenuItem1 . Visible = false ;
moveDownToolStripMenuItem1 . Visible = false ;
toolStripSeparator2 . Visible = false ;
2011-06-16 02:39:35 +00:00
}
else
{
2012-09-23 15:19:58 +00:00
for ( int i = 0 ; i < contextMenuStrip1 . Items . Count ; i + + )
{
contextMenuStrip1 . Items [ i ] . Visible = true ;
}
2011-08-07 00:32:22 +00:00
if ( indexes . Count = = 1 )
{
2012-09-03 23:42:00 +00:00
if ( Global . CheatList . IsActiveCheat ( Domain , Watches [ indexes [ 0 ] ] . Address ) )
2011-08-07 00:32:22 +00:00
{
2012-09-23 15:19:58 +00:00
freezeToolStripMenuItem . Text = "&Unfreeze address" ;
freezeToolStripMenuItem . Image =
BizHawk . MultiClient . Properties . Resources . Unfreeze ;
}
else
{
freezeToolStripMenuItem . Text = "&Freeze address" ;
freezeToolStripMenuItem . Image =
BizHawk . MultiClient . Properties . Resources . Freeze ;
}
}
else
{
bool allCheats = true ;
foreach ( int i in indexes )
{
if ( ! Global . CheatList . IsActiveCheat ( Domain , Watches [ i ] . Address ) )
{
allCheats = false ;
}
}
if ( allCheats )
{
freezeToolStripMenuItem . Text = "&Unfreeze address" ;
freezeToolStripMenuItem . Image =
2011-08-07 00:32:22 +00:00
BizHawk . MultiClient . Properties . Resources . Unfreeze ;
}
else
{
2012-09-23 15:19:58 +00:00
freezeToolStripMenuItem . Text = "&Freeze address" ;
freezeToolStripMenuItem . Image =
2011-08-07 00:32:22 +00:00
BizHawk . MultiClient . Properties . Resources . Freeze ;
}
}
2011-06-16 02:39:35 +00:00
}
if ( Global . Config . RamWatchShowChangeColumn )
2012-09-23 15:19:58 +00:00
{
showChangeCountsToolStripMenuItem1 . Text = "Hide change counts" ;
}
2011-06-16 02:39:35 +00:00
else
2012-09-23 15:19:58 +00:00
{
showChangeCountsToolStripMenuItem1 . Text = "Show change counts" ;
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchShowPrevColumn )
2012-09-23 15:19:58 +00:00
{
showPreviousValueToolStripMenuItem1 . Text = "Hide previous value" ;
}
2011-06-16 02:39:35 +00:00
else
2012-09-23 15:19:58 +00:00
{
showPreviousValueToolStripMenuItem1 . Text = "Show previous value" ;
}
2011-06-16 02:39:35 +00:00
2012-07-04 23:11:17 +00:00
if ( Global . Config . RamWatchShowDiffColumn )
2012-09-23 15:19:58 +00:00
{
showDifferenceToolStripMenuItem . Text = "Hide difference value" ;
}
2011-06-16 02:39:35 +00:00
else
2012-09-23 15:19:58 +00:00
{
showDifferenceToolStripMenuItem . Text = "Show difference value" ;
}
2012-09-15 14:53:34 +00:00
if ( Global . Config . RamWatchShowDomainColumn )
{
showDomainToolStripMenuItem . Text = "Hide domain" ;
}
else
{
showDomainToolStripMenuItem . Text = "Show domain" ;
}
2012-09-23 15:19:58 +00:00
if ( Global . CheatList . HasActiveCheats )
{
unfreezeAllToolStripMenuItem . Visible = true ;
}
else
{
unfreezeAllToolStripMenuItem . Visible = false ;
}
2012-09-15 14:53:34 +00:00
2011-06-16 02:39:35 +00:00
}
private void WatchListView_MouseDoubleClick ( object sender , MouseEventArgs e )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
EditWatch ( ) ;
}
}
private void RamWatch_DragDrop ( object sender , DragEventArgs e )
{
string [ ] filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
if ( Path . GetExtension ( filePaths [ 0 ] ) = = ( ".wch" ) )
{
LoadWatchFile ( filePaths [ 0 ] , false ) ;
DisplayWatchList ( ) ;
}
}
private void RamWatch_DragEnter ( object sender , DragEventArgs e )
{
e . Effect = e . Data . GetDataPresent ( DataFormats . FileDrop ) ? DragDropEffects . Copy : DragDropEffects . None ; string [ ] filePaths = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
}
private void ClearChangeCounts ( )
{
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
Watches [ x ] . Changecount = 0 ;
2011-06-16 02:39:35 +00:00
DisplayWatchList ( ) ;
MessageLabel . Text = "Change counts cleared" ;
}
private void ClearChangeCountstoolStripButton_Click ( object sender , EventArgs e )
{
ClearChangeCounts ( ) ;
}
private void clearChangeCountsToolStripMenuItem_Click ( object sender , EventArgs e )
{
ClearChangeCounts ( ) ;
}
private void showChangeCountsToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . RamWatchShowChangeColumn ^ = true ;
SetChangesColumn ( Global . Config . RamWatchShowChangeColumn ) ;
}
2012-07-04 23:11:17 +00:00
private void SetDiffColumn ( bool show )
{
Global . Config . RamWatchShowDiffColumn = show ;
diffToolStripMenuItem . Checked = show ;
if ( show )
2012-09-10 02:37:44 +00:00
{
2012-07-04 23:11:17 +00:00
WatchListView . Columns [ Global . Config . RamWatchDiffIndex ] . Width = 59 ;
2012-09-10 02:37:44 +00:00
}
2012-07-04 23:11:17 +00:00
else
2012-09-10 02:37:44 +00:00
{
2012-07-04 23:11:17 +00:00
WatchListView . Columns [ Global . Config . RamWatchDiffIndex ] . Width = 0 ;
2012-09-10 02:37:44 +00:00
}
2012-07-04 23:11:17 +00:00
}
2012-09-15 14:35:13 +00:00
private void SetDomainColumn ( bool show )
{
Global . Config . RamWatchShowDomainColumn = show ;
domainToolStripMenuItem . Checked = show ;
if ( show )
{
WatchListView . Columns [ Global . Config . RamWatchDomainIndex ] . Width = 55 ;
}
else
{
WatchListView . Columns [ Global . Config . RamWatchDomainIndex ] . Width = 0 ;
}
}
2011-06-16 02:39:35 +00:00
private void SetChangesColumn ( bool show )
{
Global . Config . RamWatchShowChangeColumn = show ;
showChangeCountsToolStripMenuItem . Checked = show ;
if ( show )
WatchListView . Columns [ Global . Config . RamWatchChangeIndex ] . Width = 54 ;
else
WatchListView . Columns [ Global . Config . RamWatchChangeIndex ] . Width = 0 ;
}
private void SetPrevColumn ( bool show )
{
Global . Config . RamWatchShowPrevColumn = show ;
showPreviousValueToolStripMenuItem . Checked = show ;
if ( show )
WatchListView . Columns [ Global . Config . RamWatchPrevIndex ] . Width = 59 ;
else
WatchListView . Columns [ Global . Config . RamWatchPrevIndex ] . Width = 0 ;
}
private void showPreviousValueToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . RamWatchShowPrevColumn ^ = true ;
SetPrevColumn ( Global . Config . RamWatchShowPrevColumn ) ;
}
private void optionsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
2011-09-12 23:08:42 +00:00
displayWatchesOnScreenToolStripMenuItem . Checked = Global . Config . DisplayRamWatch ;
2011-06-26 19:13:52 +00:00
saveWindowPositionToolStripMenuItem . Checked = Global . Config . RamWatchSaveWindowPosition ;
2011-06-16 02:39:35 +00:00
}
private void viewInHexEditorToolStripMenuItem_Click ( object sender , EventArgs e )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
Global . MainForm . LoadHexEditor ( ) ;
2012-09-19 00:52:40 +00:00
Global . MainForm . HexEditor1 . SetDomain ( Watches [ indexes [ 0 ] ] . Domain ) ;
2012-09-03 23:42:00 +00:00
Global . MainForm . HexEditor1 . GoToAddress ( Watches [ indexes [ 0 ] ] . Address ) ;
2011-06-16 02:39:35 +00:00
}
}
private int GetNumDigits ( Int32 i )
{
//if (i == 0) return 0;
//if (i < 0x10) return 1;
//if (i < 0x100) return 2;
//if (i < 0x1000) return 3; //adelikat: commenting these out because I decided that regardless of domain, 4 digits should be the minimum
if ( i < 0x10000 ) return 4 ;
if ( i < 0x1000000 ) return 6 ;
else return 8 ;
}
private void freezeToolStripMenuItem_Click ( object sender , EventArgs e )
{
2011-08-07 00:32:22 +00:00
if ( sender . ToString ( ) . Contains ( "Unfreeze" ) )
2012-09-23 15:37:25 +00:00
{
2011-08-07 04:19:49 +00:00
UnfreezeAddress ( ) ;
2012-09-23 15:37:25 +00:00
}
2011-08-07 04:19:49 +00:00
else
2012-09-23 15:37:25 +00:00
{
2011-08-07 00:32:22 +00:00
FreezeAddress ( ) ;
2012-09-23 15:37:25 +00:00
}
2011-06-16 02:39:35 +00:00
}
private int WORDGetLowerByte ( int value )
{
return value / 256 ;
}
private int WORDGetUpperByte ( int value )
{
return value > > 2 ;
}
private void FreezeAddress ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
2011-08-07 00:32:22 +00:00
for ( int i = 0 ; i < indexes . Count ; i + + )
2011-06-16 02:39:35 +00:00
{
2012-09-03 23:42:00 +00:00
switch ( Watches [ indexes [ i ] ] . Type )
2011-08-07 00:32:22 +00:00
{
2012-09-03 23:42:00 +00:00
case Watch . TYPE . BYTE :
Cheat c = new Cheat ( "" , Watches [ indexes [ i ] ] . Address , ( byte ) Watches [ indexes [ i ] ] . Value ,
2011-08-07 00:32:22 +00:00
true , Domain ) ;
Global . MainForm . Cheats1 . AddCheat ( c ) ;
break ;
2012-09-03 23:42:00 +00:00
case Watch . TYPE . WORD :
2011-06-16 02:39:35 +00:00
{
2012-09-03 23:42:00 +00:00
byte low = ( byte ) ( Watches [ indexes [ i ] ] . Value / 256 ) ;
byte high = ( byte ) ( Watches [ indexes [ i ] ] . Value ) ;
int a1 = Watches [ indexes [ i ] ] . Address ;
int a2 = Watches [ indexes [ i ] ] . Address + 1 ;
if ( Watches [ indexes [ i ] ] . BigEndian )
2011-08-07 00:32:22 +00:00
{
Cheat c1 = new Cheat ( "" , a1 , low , true , Domain ) ;
Cheat c2 = new Cheat ( "" , a2 , high , true , Domain ) ;
Global . MainForm . Cheats1 . AddCheat ( c1 ) ;
Global . MainForm . Cheats1 . AddCheat ( c2 ) ;
}
else
{
Cheat c1 = new Cheat ( "" , a1 , high , true , Domain ) ;
Cheat c2 = new Cheat ( "" , a2 , low , true , Domain ) ;
Global . MainForm . Cheats1 . AddCheat ( c1 ) ;
Global . MainForm . Cheats1 . AddCheat ( c2 ) ;
}
2011-06-16 02:39:35 +00:00
}
2011-08-07 00:32:22 +00:00
break ;
2012-09-03 23:42:00 +00:00
case Watch . TYPE . DWORD :
2011-06-16 02:39:35 +00:00
{
2012-09-03 23:42:00 +00:00
byte HIWORDhigh = ( byte ) ( Watches [ indexes [ i ] ] . Value / 0x1000000 ) ;
byte HIWORDlow = ( byte ) ( Watches [ indexes [ i ] ] . Value / 0x10000 ) ;
byte LOWORDhigh = ( byte ) ( Watches [ indexes [ i ] ] . Value / 0x100 ) ;
byte LOWORDlow = ( byte ) ( Watches [ indexes [ i ] ] . Value ) ;
int a1 = Watches [ indexes [ i ] ] . Address ;
int a2 = Watches [ indexes [ i ] ] . Address + 1 ;
int a3 = Watches [ indexes [ i ] ] . Address + 2 ;
int a4 = Watches [ indexes [ i ] ] . Address + 3 ;
if ( Watches [ indexes [ i ] ] . BigEndian )
2011-08-07 00:32:22 +00:00
{
Cheat c1 = new Cheat ( "" , a1 , HIWORDhigh , true , Domain ) ;
Cheat c2 = new Cheat ( "" , a2 , HIWORDlow , true , Domain ) ;
Cheat c3 = new Cheat ( "" , a3 , LOWORDhigh , true , Domain ) ;
Cheat c4 = new Cheat ( "" , a4 , LOWORDlow , true , Domain ) ;
Global . MainForm . Cheats1 . AddCheat ( c1 ) ;
Global . MainForm . Cheats1 . AddCheat ( c2 ) ;
Global . MainForm . Cheats1 . AddCheat ( c3 ) ;
Global . MainForm . Cheats1 . AddCheat ( c4 ) ;
}
else
{
Cheat c1 = new Cheat ( "" , a1 , LOWORDlow , true , Domain ) ;
Cheat c2 = new Cheat ( "" , a2 , LOWORDhigh , true , Domain ) ;
Cheat c3 = new Cheat ( "" , a3 , HIWORDlow , true , Domain ) ;
Cheat c4 = new Cheat ( "" , a4 , HIWORDhigh , true , Domain ) ;
Global . MainForm . Cheats1 . AddCheat ( c1 ) ;
Global . MainForm . Cheats1 . AddCheat ( c2 ) ;
Global . MainForm . Cheats1 . AddCheat ( c3 ) ;
Global . MainForm . Cheats1 . AddCheat ( c4 ) ;
}
2011-06-16 02:39:35 +00:00
}
2011-08-07 00:32:22 +00:00
break ;
}
2011-06-16 02:39:35 +00:00
}
}
2012-09-23 15:37:25 +00:00
UpdateValues ( ) ;
Global . MainForm . RamSearch1 . UpdateValues ( ) ;
Global . MainForm . HexEditor1 . UpdateValues ( ) ;
Global . MainForm . Cheats1 . UpdateValues ( ) ;
2011-06-16 02:39:35 +00:00
}
2011-08-07 04:19:49 +00:00
private void UnfreezeAddress ( )
{
ListView . SelectedIndexCollection indexes = WatchListView . SelectedIndices ;
if ( indexes . Count > 0 )
{
for ( int i = 0 ; i < indexes . Count ; i + + )
{
2012-09-03 23:42:00 +00:00
switch ( Watches [ indexes [ i ] ] . Type )
2011-08-07 04:19:49 +00:00
{
2012-09-03 23:42:00 +00:00
case Watch . TYPE . BYTE :
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address ) ;
2011-08-07 04:19:49 +00:00
break ;
2012-09-03 23:42:00 +00:00
case Watch . TYPE . WORD :
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address ) ;
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address + 1 ) ;
2011-08-07 04:19:49 +00:00
break ;
2012-09-03 23:42:00 +00:00
case Watch . TYPE . DWORD :
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address ) ;
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address + 1 ) ;
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address + 2 ) ;
Global . CheatList . Remove ( Domain , Watches [ indexes [ i ] ] . Address + 3 ) ;
2011-08-07 04:19:49 +00:00
break ;
}
}
}
2012-09-23 15:37:25 +00:00
UpdateValues ( ) ;
Global . MainForm . RamSearch1 . UpdateValues ( ) ;
Global . MainForm . HexEditor1 . UpdateValues ( ) ;
Global . MainForm . Cheats1 . UpdateValues ( ) ;
2011-08-07 04:19:49 +00:00
}
2011-06-16 02:39:35 +00:00
private void freezeAddressToolStripMenuItem_Click ( object sender , EventArgs e )
{
FreezeAddress ( ) ;
}
private void FreezetoolStripButton2_Click ( object sender , EventArgs e )
{
FreezeAddress ( ) ;
}
private void SetPlatformAndMemoryDomainLabel ( )
{
string memoryDomain = Domain . ToString ( ) ;
systemID = Global . Emulator . SystemId ;
MemDomainLabel . Text = systemID + " " + memoryDomain ;
}
private void SetMemoryDomain ( int pos )
{
if ( pos < Global . Emulator . MemoryDomains . Count ) //Sanity check
{
Domain = Global . Emulator . MemoryDomains [ pos ] ;
}
2011-08-27 13:20:02 +00:00
addressFormatStr = "X" + GetNumDigits ( Domain . Size - 1 ) . ToString ( ) ;
2011-06-16 02:39:35 +00:00
SetPlatformAndMemoryDomainLabel ( ) ;
Update ( ) ;
}
private void SetMemoryDomainMenu ( )
{
memoryDomainsToolStripMenuItem . DropDownItems . Clear ( ) ;
if ( Global . Emulator . MemoryDomains . Count > 0 )
{
for ( int x = 0 ; x < Global . Emulator . MemoryDomains . Count ; x + + )
{
string str = Global . Emulator . MemoryDomains [ x ] . ToString ( ) ;
var item = new ToolStripMenuItem ( ) ;
item . Text = str ;
{
int z = x ;
item . Click + = ( o , ev ) = > SetMemoryDomain ( z ) ;
}
if ( x = = 0 )
{
SetMemoryDomain ( x ) ;
}
memoryDomainsToolStripMenuItem . DropDownItems . Add ( item ) ;
domainMenuItems . Add ( item ) ;
}
}
else
memoryDomainsToolStripMenuItem . Enabled = false ;
}
private void CheckDomainMenuItems ( )
{
for ( int x = 0 ; x < domainMenuItems . Count ; x + + )
{
if ( Domain . Name = = domainMenuItems [ x ] . Text )
domainMenuItems [ x ] . Checked = true ;
else
domainMenuItems [ x ] . Checked = false ;
}
}
private void memoryDomainsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
CheckDomainMenuItems ( ) ;
}
private void ColumnReorder ( object sender , ColumnReorderedEventArgs e )
{
ColumnHeader header = e . Header ;
int lowIndex = 0 ;
int highIndex = 0 ;
int changeIndex = 0 ;
if ( e . NewDisplayIndex > e . OldDisplayIndex )
{
changeIndex = - 1 ;
highIndex = e . NewDisplayIndex ;
lowIndex = e . OldDisplayIndex ;
}
else
{
changeIndex = 1 ;
highIndex = e . OldDisplayIndex ;
lowIndex = e . NewDisplayIndex ;
}
if ( Global . Config . RamWatchAddressIndex > = lowIndex & & Global . Config . RamWatchAddressIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchAddressIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchValueIndex > = lowIndex & & Global . Config . RamWatchValueIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchValueIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchPrevIndex > = lowIndex & & Global . Config . RamWatchPrevIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchPrevIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchChangeIndex > = lowIndex & & Global . Config . RamWatchChangeIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchChangeIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
2012-07-04 23:11:17 +00:00
if ( Global . Config . RamWatchDiffIndex > = lowIndex & & Global . Config . RamWatchDiffIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2012-07-04 23:11:17 +00:00
Global . Config . RamWatchDiffIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
if ( Global . Config . RamWatchDomainIndex > = lowIndex & & Global . Config . RamWatchDomainIndex < = highIndex )
{
Global . Config . RamWatchDomainIndex + = changeIndex ;
}
2011-06-16 02:39:35 +00:00
if ( Global . Config . RamWatchNotesIndex > = lowIndex & & Global . Config . RamWatchNotesIndex < = highIndex )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchNotesIndex + = changeIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
if ( header . Text = = "Address" )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchAddressIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
else if ( header . Text = = "Value" )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchValueIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
else if ( header . Text = = "Prev" )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchPrevIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
else if ( header . Text = = "Changes" )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchChangeIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
2012-07-04 23:11:17 +00:00
else if ( header . Text = = "Diff" )
2012-09-10 02:37:44 +00:00
{
2012-07-04 23:11:17 +00:00
Global . Config . RamWatchDiffIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
else if ( header . Text = = "Domain" )
{
Global . Config . RamWatchDomainIndex = e . NewDisplayIndex ;
}
2011-06-16 02:39:35 +00:00
else if ( header . Text = = "Notes" )
2012-09-10 02:37:44 +00:00
{
2011-06-16 02:39:35 +00:00
Global . Config . RamWatchNotesIndex = e . NewDisplayIndex ;
2012-09-10 02:37:44 +00:00
}
2011-06-16 02:39:35 +00:00
}
private void ColumnPositionSet ( )
{
List < ColumnHeader > columnHeaders = new List < ColumnHeader > ( ) ;
2012-07-05 03:05:23 +00:00
for ( int i = 0 ; i < WatchListView . Columns . Count ; i + + )
{
2011-06-16 02:39:35 +00:00
columnHeaders . Add ( WatchListView . Columns [ i ] ) ;
2012-07-05 03:05:23 +00:00
}
2011-06-16 02:39:35 +00:00
WatchListView . Columns . Clear ( ) ;
2012-07-05 03:05:23 +00:00
List < KeyValuePair < int , string > > columnSettings = new List < KeyValuePair < int , string > > ( ) ;
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchAddressIndex , "Address" ) ) ;
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchValueIndex , "Value" ) ) ;
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchPrevIndex , "Prev" ) ) ;
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchChangeIndex , "Changes" ) ) ;
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchDiffIndex , "Diff" ) ) ;
2012-09-10 02:37:44 +00:00
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchDomainIndex , "Domain" ) ) ;
2012-07-05 03:05:23 +00:00
columnSettings . Add ( new KeyValuePair < int , string > ( Global . Config . RamWatchNotesIndex , "Notes" ) ) ;
columnSettings = columnSettings . OrderBy ( s = > s . Key ) . ToList ( ) ;
for ( int i = 0 ; i < columnSettings . Count ; i + + )
2011-06-16 02:39:35 +00:00
{
2012-07-05 03:05:23 +00:00
for ( int j = 0 ; j < columnHeaders . Count ; j + + )
2011-06-16 02:39:35 +00:00
{
2012-07-05 03:05:23 +00:00
if ( columnSettings [ i ] . Value = = columnHeaders [ j ] . Text )
2011-06-16 02:39:35 +00:00
{
2012-07-05 03:05:23 +00:00
WatchListView . Columns . Add ( columnHeaders [ j ] ) ;
2011-06-16 02:39:35 +00:00
}
}
2012-07-05 03:05:23 +00:00
}
2011-06-16 02:39:35 +00:00
}
2011-06-19 19:10:01 +00:00
private void OrderColumn ( int columnToOrder )
{
string columnName = WatchListView . Columns [ columnToOrder ] . Text ;
if ( sortedCol . CompareTo ( columnName ) ! = 0 )
2012-09-10 02:37:44 +00:00
{
2011-06-19 19:10:01 +00:00
sortReverse = false ;
2012-09-10 02:37:44 +00:00
}
2012-09-03 23:42:00 +00:00
Watches . Sort ( ( x , y ) = > x . CompareTo ( y , columnName , Global . Config . RamWatchPrev_Type = = 1 ? Watch . PREVDEF . LASTFRAME : Watch . PREVDEF . LASTCHANGE ) * ( sortReverse ? - 1 : 1 ) ) ;
2011-06-19 19:20:43 +00:00
sortedCol = columnName ;
sortReverse = ! ( sortReverse ) ;
2011-06-19 19:10:01 +00:00
WatchListView . Refresh ( ) ;
}
private void WatchListView_ColumnClick ( object sender , ColumnClickEventArgs e )
{
OrderColumn ( e . Column ) ;
}
2011-06-26 19:13:52 +00:00
private void saveWindowPositionToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . RamWatchSaveWindowPosition ^ = true ;
}
2011-08-02 02:49:29 +00:00
private void RamWatch_Enter ( object sender , EventArgs e )
{
WatchListView . Focus ( ) ;
}
2011-08-07 00:43:04 +00:00
2011-08-07 00:56:21 +00:00
private void selectAllToolStripMenuItem_Click ( object sender , EventArgs e )
{
SelectAll ( ) ;
}
private void SelectAll ( )
{
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
2011-08-07 00:56:21 +00:00
WatchListView . SelectItem ( x , true ) ;
}
2011-08-20 15:35:16 +00:00
private void RamWatch_Activated ( object sender , EventArgs e )
{
WatchListView . Refresh ( ) ;
}
2011-09-12 23:08:42 +00:00
private void displayWatchesOnScreenToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . DisplayRamWatch ^ = true ;
if ( ! Global . Config . DisplayRamWatch )
2012-04-16 08:18:41 +00:00
Global . OSD . ClearGUIText ( ) ;
2011-09-12 23:08:42 +00:00
else
UpdateValues ( ) ;
}
2011-09-16 23:29:36 +00:00
private void WatchListView_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . KeyCode = = Keys . Delete & & ! e . Control & & ! e . Alt & & ! e . Shift )
{
RemoveWatch ( ) ;
}
else if ( e . KeyCode = = Keys . A & & e . Control & & ! e . Alt & & ! e . Shift ) //Select All
{
2012-09-03 23:42:00 +00:00
for ( int x = 0 ; x < Watches . Count ; x + + )
2011-09-16 23:29:36 +00:00
{
WatchListView . SelectItem ( x , true ) ;
}
}
}
2012-06-14 00:00:53 +00:00
private void showPreviousValueToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
Global . Config . RamWatchShowPrevColumn ^ = true ;
SetPrevColumn ( Global . Config . RamWatchShowPrevColumn ) ;
}
private void showChangeCountsToolStripMenuItem_Click_1 ( object sender , EventArgs e )
{
Global . Config . RamWatchShowChangeColumn ^ = true ;
SetChangesColumn ( Global . Config . RamWatchShowChangeColumn ) ;
}
2012-07-04 23:11:17 +00:00
private void diffToolStripMenuItem_Click ( object sender , EventArgs e )
{
ShowDifference ( ) ;
}
private void viewToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
showPreviousValueToolStripMenuItem . Checked = Global . Config . RamWatchShowPrevColumn ;
showChangeCountsToolStripMenuItem . Checked = Global . Config . RamWatchShowChangeColumn ;
diffToolStripMenuItem . Checked = Global . Config . RamWatchShowDiffColumn ;
2012-09-15 14:35:13 +00:00
domainToolStripMenuItem . Checked = Global . Config . RamWatchShowDomainColumn ;
2012-07-04 23:11:17 +00:00
}
private void showDifferenceToolStripMenuItem_Click ( object sender , EventArgs e )
{
ShowDifference ( ) ;
}
private void ShowDifference ( )
{
Global . Config . RamWatchShowDiffColumn ^ = true ;
SetDiffColumn ( Global . Config . RamWatchShowDiffColumn ) ;
}
2012-07-05 01:58:33 +00:00
private void previousFrameToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . RamWatchPrev_Type = 1 ;
2012-07-05 03:21:39 +00:00
WatchListView . Refresh ( ) ;
2012-07-05 01:58:33 +00:00
}
private void lastChangeToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . Config . RamWatchPrev_Type = 2 ;
2012-07-05 03:21:39 +00:00
WatchListView . Refresh ( ) ;
2012-07-05 01:58:33 +00:00
}
private void definePreviousValueAsToolStripMenuItem_DropDownOpened ( object sender , EventArgs e )
{
switch ( Global . Config . RamWatchPrev_Type )
{
case 1 :
previousFrameToolStripMenuItem . Checked = true ;
lastChangeToolStripMenuItem . Checked = false ;
break ;
case 2 :
previousFrameToolStripMenuItem . Checked = false ;
lastChangeToolStripMenuItem . Checked = true ;
break ;
}
}
2012-09-15 14:35:13 +00:00
2012-09-15 14:53:34 +00:00
private void SetDomain ( )
2012-09-15 14:35:13 +00:00
{
Global . Config . RamWatchShowDomainColumn ^ = true ;
SetDomainColumn ( Global . Config . RamWatchShowDomainColumn ) ;
}
2012-09-15 14:53:34 +00:00
private void domainToolStripMenuItem_Click ( object sender , EventArgs e )
{
SetDomain ( ) ;
}
private void showDomainToolStripMenuItem_Click ( object sender , EventArgs e )
{
SetDomain ( ) ;
}
2012-09-23 15:37:25 +00:00
private void unfreezeAllToolStripMenuItem_Click ( object sender , EventArgs e )
{
Global . MainForm . Cheats1 . RemoveAllCheats ( ) ;
UpdateValues ( ) ;
Global . MainForm . RamSearch1 . UpdateValues ( ) ;
Global . MainForm . HexEditor1 . UpdateValues ( ) ;
Global . MainForm . Cheats1 . UpdateValues ( ) ;
}
2011-06-16 02:39:35 +00:00
}
2011-02-21 15:23:30 +00:00
}