Migrate RAM Search to PAVLV
This commit is contained in:
parent
0f687ff84e
commit
b5d188ad5e
|
@ -163,6 +163,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compatibility method from VirtualListView
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
public void ensureVisible()
|
||||
{
|
||||
if (_selectedItems.Count != 0)
|
||||
MakeIndexVisible(_selectedItems.Last().RowIndex.Value);
|
||||
}
|
||||
|
||||
public void ClearSelectedRows()
|
||||
{
|
||||
_selectedItems.Clear();
|
||||
|
|
|
@ -75,14 +75,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (BorderSize > 0)
|
||||
{
|
||||
// paint parent border
|
||||
using (var gParent = this.Parent.CreateGraphics())
|
||||
// apparently mono can sometimes call OnPaint before attached to the parent??
|
||||
if (this.Parent != null)
|
||||
{
|
||||
Pen borderPen = new Pen(BorderColor);
|
||||
for (int b = 1, c = 1; b <= BorderSize; b++, c += 2)
|
||||
// paint parent border
|
||||
using (var gParent = this.Parent.CreateGraphics())
|
||||
{
|
||||
gParent.DrawRectangle(borderPen, this.Left - b, this.Top - b, this.Width + c, this.Height + c);
|
||||
}
|
||||
Pen borderPen = new Pen(BorderColor);
|
||||
for (int b = 1, c = 1; b <= BorderSize; b++, c += 2)
|
||||
{
|
||||
gParent.DrawRectangle(borderPen, this.Left - b, this.Top - b, this.Width + c, this.Height + c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +103,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
QueryItemTextAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY);
|
||||
|
||||
Color bgColor = ColumnHeaderBackgroundColor;
|
||||
QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);
|
||||
QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _columns.IndexOf(_draggingCell.Column), ref bgColor);
|
||||
QueryItemBkColorAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);
|
||||
|
||||
int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2);
|
||||
int y1 = _currentY.Value - (CellHeight / 2);
|
||||
|
@ -124,7 +129,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
QueryItemTextAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY);
|
||||
|
||||
Color bgColor = CellBackgroundColor;
|
||||
QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);
|
||||
QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _columns.IndexOf(_draggingCell.Column), ref bgColor);
|
||||
QueryItemBkColorAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);
|
||||
|
||||
int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2);
|
||||
int y1 = _currentY.Value - (CellHeight / 2);
|
||||
|
@ -144,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
var point = new Point(column.Left.Value + 2 * CellWidthPadding - _hBar.Value, CellHeightPadding); // TODO: fix this CellPadding issue (2 * CellPadding vs just CellPadding)
|
||||
var point = new Point(column.Left.Value + CellWidthPadding - _hBar.Value, CellHeightPadding);
|
||||
|
||||
string t = column.Text;
|
||||
ResizeTextToFit(ref t, column.Width.Value, ColumnHeaderFont);
|
||||
|
@ -448,7 +454,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
Color cellColor = rowColor;
|
||||
QueryItemBkColor?.Invoke(cell.RowIndex.Value, cell.Column, ref cellColor);
|
||||
QueryItemBkColor?.Invoke(cell.RowIndex.Value, _columns.IndexOf(cell.Column), ref cellColor);
|
||||
QueryItemBkColorAdvanced?.Invoke(cell.RowIndex.Value, cell.Column, ref cellColor);
|
||||
|
||||
// Alpha layering for cell before selection
|
||||
float alpha = (float)cellColor.A / 255;
|
||||
|
@ -494,7 +501,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
for (int j = FirstVisibleColumn; j <= lastVisible; j++) // Horizontal
|
||||
{
|
||||
Color itemColor = CellBackgroundColor;
|
||||
QueryItemBkColor(f + startIndex, visibleColumns[j], ref itemColor);
|
||||
QueryItemBkColor?.Invoke(f + startIndex, _columns.IndexOf(visibleColumns[j]), ref itemColor);
|
||||
QueryItemBkColorAdvanced?.Invoke(f + startIndex, visibleColumns[j], ref itemColor);
|
||||
if (itemColor == CellBackgroundColor)
|
||||
{
|
||||
itemColor = rowColor;
|
||||
|
|
|
@ -36,6 +36,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
[Category("Virtual")]
|
||||
public event QueryItemBkColorHandler QueryItemBkColor;
|
||||
|
||||
/// <summary>
|
||||
/// Fire the <see cref="QueryItemBkColorAdvanced"/> event which requests the background color for the passed cell
|
||||
/// </summary>
|
||||
[Category("Virtual")]
|
||||
public event QueryItemBkColorHandlerAdvanced QueryItemBkColorAdvanced;
|
||||
|
||||
[Category("Virtual")]
|
||||
public event QueryRowBkColorHandler QueryRowBkColor;
|
||||
|
||||
|
@ -110,7 +116,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <summary>
|
||||
/// Retrieve the background color for a cell
|
||||
/// </summary>
|
||||
public delegate void QueryItemBkColorHandler(int index, ListColumn column, ref Color color);
|
||||
public delegate void QueryItemBkColorHandlerAdvanced(int index, ListColumn column, ref Color color);
|
||||
public delegate void QueryItemBkColorHandler(int index, int column, ref Color color);
|
||||
public delegate void QueryRowBkColorHandler(int index, ref Color color);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -34,13 +34,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public PlatformAgnosticVirtualListView()
|
||||
{
|
||||
ColumnHeaderFont = new Font("Arial", 8, FontStyle.Bold);
|
||||
ColumnHeaderFont = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
ColumnHeaderFontColor = Color.Black;
|
||||
ColumnHeaderBackgroundColor = Color.LightGray;
|
||||
ColumnHeaderBackgroundHighlightColor = SystemColors.HighlightText;
|
||||
ColumnHeaderOutlineColor = Color.Black;
|
||||
|
||||
CellFont = new Font("Arial", 8, FontStyle.Regular);
|
||||
CellFont = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
CellFontColor = Color.Black;
|
||||
CellBackgroundColor = Color.White;
|
||||
CellBackgroundHighlightColor = Color.Blue;
|
||||
|
|
|
@ -119,6 +119,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
protected void LoadColumnInfo(PlatformAgnosticVirtualListView listView, ToolDialogSettings.ColumnList columns)
|
||||
{
|
||||
listView.AllColumns.Clear();
|
||||
|
||||
var cl = columns
|
||||
.Where(c => c.Visible)
|
||||
.OrderBy(c => c.Index);
|
||||
|
||||
foreach (var column in cl)
|
||||
{
|
||||
string colText = column.Name.Replace("Column", "");
|
||||
listView.AddColumn(column.Name, colText, column.Width, PlatformAgnosticVirtualListView.ListColumn.InputType.Text);
|
||||
}
|
||||
}
|
||||
|
||||
protected void SaveColumnInfo(VirtualListView listview, ToolDialogSettings.ColumnList columns)
|
||||
{
|
||||
foreach (ColumnHeader column in listview.Columns)
|
||||
|
@ -128,6 +143,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
protected void SaveColumnInfo(PlatformAgnosticVirtualListView listview, ToolDialogSettings.ColumnList columns)
|
||||
{
|
||||
foreach (var column in listview.AllColumns)
|
||||
{
|
||||
columns[column.Name].Index = listview.AllColumns.IndexOf(column);
|
||||
columns[column.Name].Width = column.Width.Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void RefreshFloatingWindowControl(bool floatingWindow)
|
||||
{
|
||||
Owner = floatingWindow ? null : GlobalWin.MainForm;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
System.Windows.Forms.ToolStripMenuItem SearchMenuItem;
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamSearch));
|
||||
this.TotalSearchLabel = new System.Windows.Forms.Label();
|
||||
this.WatchListView = new BizHawk.Client.EmuHawk.VirtualListView();
|
||||
this.WatchListView = new BizHawk.Client.EmuHawk.PlatformAgnosticVirtualListView();
|
||||
this.AddressColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.ValueColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.PreviousColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
|
@ -211,13 +211,10 @@
|
|||
this.WatchListView.UseCustomBackground = true;
|
||||
this.WatchListView.View = System.Windows.Forms.View.Details;
|
||||
this.WatchListView.VirtualMode = true;
|
||||
this.WatchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.WatchListView_ColumnClick);
|
||||
this.WatchListView.SelectedIndexChanged += new System.EventHandler(this.WatchListView_SelectedIndexChanged);
|
||||
this.WatchListView.VirtualItemsSelectionRangeChanged += new System.Windows.Forms.ListViewVirtualItemsSelectionRangeChangedEventHandler(this.WatchListView_VirtualItemsSelectionRangeChanged);
|
||||
this.WatchListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.NewRamSearch_DragDrop);
|
||||
this.WatchListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.DragEnterWrapper);
|
||||
this.WatchListView.Enter += new System.EventHandler(this.WatchListView_Enter);
|
||||
this.WatchListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WatchListView_KeyDown);
|
||||
this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick);
|
||||
//
|
||||
// AddressColumn
|
||||
|
@ -1422,7 +1419,7 @@
|
|||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label TotalSearchLabel;
|
||||
VirtualListView WatchListView;
|
||||
BizHawk.Client.EmuHawk.PlatformAgnosticVirtualListView WatchListView;
|
||||
private System.Windows.Forms.ColumnHeader AddressColumn;
|
||||
private System.Windows.Forms.ColumnHeader ValueColumn;
|
||||
private System.Windows.Forms.ColumnHeader PreviousColumn;
|
||||
|
|
|
@ -51,9 +51,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
InitializeComponent();
|
||||
WatchListView.QueryItemText += ListView_QueryItemText;
|
||||
WatchListView.QueryItemBkColor += ListView_QueryItemBkColor;
|
||||
WatchListView.VirtualMode = true;
|
||||
|
||||
SetupListViewSettings();
|
||||
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
|
||||
_sortedColumn = "";
|
||||
|
@ -62,6 +62,32 @@ namespace BizHawk.Client.EmuHawk
|
|||
Settings = new RamSearchSettings();
|
||||
}
|
||||
|
||||
private void SetupListViewSettings()
|
||||
{
|
||||
WatchListView.BorderColor = System.Drawing.Color.Black;
|
||||
WatchListView.BorderSize = 1;
|
||||
WatchListView.MultiSelect = true;
|
||||
WatchListView.CellWidthPadding = 2;
|
||||
WatchListView.CellHeightPadding = 1;
|
||||
WatchListView.ScrollSpeed = 3;
|
||||
WatchListView.AllowColumnResize = true;
|
||||
WatchListView.AllowColumnReorder = true;
|
||||
WatchListView.ColumnHeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 7.7F);
|
||||
WatchListView.ColumnHeaderFontColor = System.Drawing.Color.Black;
|
||||
WatchListView.ColumnHeaderBackgroundColor = System.Drawing.Color.White;
|
||||
WatchListView.ColumnHeaderBackgroundHighlightColor = System.Drawing.Color.LightSteelBlue;
|
||||
WatchListView.ColumnHeaderOutlineColor = System.Drawing.Color.LightGray;
|
||||
WatchListView.CellFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
WatchListView.CellFontColor = System.Drawing.Color.Black;
|
||||
WatchListView.CellBackgroundColor = System.Drawing.Color.White;
|
||||
|
||||
WatchListView.QueryItemText += ListView_QueryItemText;
|
||||
WatchListView.QueryItemBkColor += ListView_QueryItemBkColor;
|
||||
WatchListView.ColumnClick += WatchListView_ColumnClick;
|
||||
WatchListView.KeyDown += WatchListView_KeyDown;
|
||||
WatchListView.VirtualMode = true;
|
||||
}
|
||||
|
||||
[RequiredService]
|
||||
public IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
|
@ -163,33 +189,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
if (column == 0)
|
||||
if (_searches.Count > 0)
|
||||
{
|
||||
if (_searches.Count > 0 && column == 0)
|
||||
var nextColor = Color.White;
|
||||
|
||||
var isCheat = Global.CheatList.IsActive(_settings.Domain, _searches[index].Address);
|
||||
var isWeeded = Settings.PreviewMode && !_forcePreviewClear && _searches.Preview(_searches[index].Address);
|
||||
|
||||
if (_searches[index].Address >= _searches[index].Domain.Size)
|
||||
{
|
||||
var nextColor = Color.White;
|
||||
|
||||
var isCheat = Global.CheatList.IsActive(_settings.Domain, _searches[index].Address);
|
||||
var isWeeded = Settings.PreviewMode && !_forcePreviewClear && _searches.Preview(_searches[index].Address);
|
||||
|
||||
if (_searches[index].Address >= _searches[index].Domain.Size)
|
||||
{
|
||||
nextColor = Color.PeachPuff;
|
||||
}
|
||||
else if (isCheat)
|
||||
{
|
||||
nextColor = isWeeded ? Color.Lavender : Color.LightCyan;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isWeeded)
|
||||
{
|
||||
nextColor = Color.Pink;
|
||||
}
|
||||
}
|
||||
|
||||
color = nextColor;
|
||||
nextColor = Color.PeachPuff;
|
||||
}
|
||||
else if (isCheat)
|
||||
{
|
||||
nextColor = isWeeded ? Color.Lavender : Color.LightCyan;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isWeeded)
|
||||
{
|
||||
nextColor = Color.Pink;
|
||||
}
|
||||
}
|
||||
|
||||
color = nextColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +225,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
var columnName = WatchListView.Columns[column].Name;
|
||||
var columnName = WatchListView.AllColumns[column].Name;
|
||||
switch (columnName)
|
||||
{
|
||||
case WatchList.ADDRESS:
|
||||
|
@ -551,7 +574,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_forcePreviewClear = true;
|
||||
}
|
||||
|
||||
private IEnumerable<int> SelectedIndices => WatchListView.SelectedIndices.Cast<int>();
|
||||
private IEnumerable<int> SelectedIndices => WatchListView.SelectedRows;
|
||||
|
||||
private IEnumerable<Watch> SelectedItems
|
||||
{
|
||||
|
@ -771,7 +794,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DifferenceRadio.Enabled = true;
|
||||
DifferentByBox.Enabled = true;
|
||||
ClearChangeCountsToolBarItem.Enabled = true;
|
||||
WatchListView.Columns[WatchList.CHANGES].Width = Settings.Columns[WatchList.CHANGES].Width;
|
||||
WatchListView.AllColumns[WatchList.CHANGES].Width = Settings.Columns[WatchList.CHANGES].Width;
|
||||
SetReboot(true);
|
||||
}
|
||||
|
||||
|
@ -794,8 +817,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
PreviousValueRadio.Checked = true;
|
||||
}
|
||||
|
||||
Settings.Columns[WatchList.CHANGES].Width = WatchListView.Columns[WatchList.CHANGES].Width;
|
||||
WatchListView.Columns[WatchList.CHANGES].Width = 0;
|
||||
Settings.Columns[WatchList.CHANGES].Width = WatchListView.AllColumns[WatchList.CHANGES].Width.Value;
|
||||
WatchListView.AllColumns[WatchList.CHANGES].Width = 0;
|
||||
SetReboot(true);
|
||||
}
|
||||
|
||||
|
@ -808,7 +831,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_searches.RemoveRange(indices);
|
||||
|
||||
UpdateList();
|
||||
WatchListView.SelectedIndices.Clear();
|
||||
WatchListView.ClearSelectedRows();
|
||||
ToggleSearchDependentToolBarItems();
|
||||
}
|
||||
}
|
||||
|
@ -899,7 +922,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void GoToSpecifiedAddress()
|
||||
{
|
||||
WatchListView.SelectedIndices.Clear();
|
||||
WatchListView.ClearSelectedRows();
|
||||
var prompt = new InputPrompt
|
||||
{
|
||||
Text = "Go to Address",
|
||||
|
@ -1708,8 +1731,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (e.KeyCode == Keys.Escape && !e.Control && !e.Alt && !e.Shift)
|
||||
{
|
||||
WatchListView.SelectedIndices.Clear();
|
||||
WatchListView.ClearSelectedRows();
|
||||
}
|
||||
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
private void WatchListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
@ -1739,9 +1764,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
private void WatchListView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
private void WatchListView_ColumnClick(object sender, PlatformAgnosticVirtualListView.ColumnClickEventArgs e)
|
||||
{
|
||||
var column = WatchListView.Columns[e.Column];
|
||||
var column = WatchListView.AllColumns[WatchListView.AllColumns.IndexOf(e.Column)];
|
||||
if (column.Name != _sortedColumn)
|
||||
{
|
||||
_sortReverse = false;
|
||||
|
|
Loading…
Reference in New Issue