InputRoll - make custom column click event args that pass a RollColumn object rather than trying to shoehorn a ListView column click event args object for legacy support

This commit is contained in:
adelikat 2014-10-14 00:31:59 +00:00
parent 35fa11dc51
commit 56cb685d67
3 changed files with 23 additions and 14 deletions

View File

@ -245,19 +245,17 @@ namespace BizHawk.Client.EmuHawk
[Category("Mouse")] [Category("Mouse")]
public event CellChangeEventHandler PointedCellChanged; public event CellChangeEventHandler PointedCellChanged;
// TODO: do not use ColumnClickEventHandler, make a custom one that passes a column object
/// <summary> /// <summary>
/// Occurs when a column header is clicked /// Occurs when a column header is clicked
/// </summary> /// </summary>
[Category("Action")] [Category("Action")]
public event System.Windows.Forms.ColumnClickEventHandler ColumnClick; public event ColumnClickEventHandler ColumnClick;
// TODO: do not use ColumnClickEventHandler, make a custom one that passes a column object
/// <summary> /// <summary>
/// Occurs when a column header is right-clicked /// Occurs when a column header is right-clicked
/// </summary> /// </summary>
[Category("Action")] [Category("Action")]
public event System.Windows.Forms.ColumnClickEventHandler ColumnRightClick; public event ColumnClickEventHandler ColumnRightClick;
/// <summary> /// <summary>
/// Occurs whenever the 'SelectedItems' property for this control changes /// Occurs whenever the 'SelectedItems' property for this control changes
@ -290,6 +288,8 @@ namespace BizHawk.Client.EmuHawk
public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e); public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e);
public delegate void ColumnClickEventHandler(object sender, ColumnClickEventArgs e);
public class CellEventArgs public class CellEventArgs
{ {
public CellEventArgs(Cell oldCell, Cell newCell) public CellEventArgs(Cell oldCell, Cell newCell)
@ -302,6 +302,16 @@ namespace BizHawk.Client.EmuHawk
public Cell NewCell { get; private set; } public Cell NewCell { get; private set; }
} }
public class ColumnClickEventArgs
{
public ColumnClickEventArgs(RollColumn column)
{
Column = column;
}
public RollColumn Column { get; private set; }
}
#endregion #endregion
#region Api #region Api
@ -1195,7 +1205,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (ColumnClick != null) if (ColumnClick != null)
{ {
ColumnClick(this, new ColumnClickEventArgs(_columns.IndexOf(column))); ColumnClick(this, new ColumnClickEventArgs(column));
} }
} }
@ -1203,7 +1213,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (ColumnRightClick != null) if (ColumnRightClick != null)
{ {
ColumnRightClick(this, new ColumnClickEventArgs(_columns.IndexOf(column))); ColumnRightClick(this, new ColumnClickEventArgs(column));
} }
} }

View File

@ -745,8 +745,8 @@ namespace BizHawk.Client.EmuHawk
this.TasView.RowCount = 0; this.TasView.RowCount = 0;
this.TasView.Size = new System.Drawing.Size(288, 471); this.TasView.Size = new System.Drawing.Size(288, 471);
this.TasView.TabIndex = 1; this.TasView.TabIndex = 1;
this.TasView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.TasView_ColumnClick); this.TasView.ColumnClick += new InputRoll.ColumnClickEventHandler(this.TasView_ColumnClick);
this.TasView.ColumnRightClick += new System.Windows.Forms.ColumnClickEventHandler(this.TasView_ColumnRightClick); this.TasView.ColumnRightClick += new InputRoll.ColumnClickEventHandler(this.TasView_ColumnRightClick);
this.TasView.SelectedIndexChanged += new System.EventHandler(this.TasView_SelectedIndexChanged); this.TasView.SelectedIndexChanged += new System.EventHandler(this.TasView_SelectedIndexChanged);
this.TasView.RightMouseScrolled += new BizHawk.Client.EmuHawk.InputRoll.RightMouseScrollEventHandler(this.TasView_MouseWheel); this.TasView.RightMouseScrolled += new BizHawk.Client.EmuHawk.InputRoll.RightMouseScrollEventHandler(this.TasView_MouseWheel);
this.TasView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TasView_KeyDown); this.TasView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TasView_KeyDown);

View File

@ -188,11 +188,11 @@ namespace BizHawk.Client.EmuHawk
#region Events #region Events
private void TasView_ColumnClick(object sender, ColumnClickEventArgs e) private void TasView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e)
{ {
if (TasView.SelectedRows.Any()) if (TasView.SelectedRows.Any())
{ {
var columnName = TasView.VisibleColumns.ToList()[e.Column].Name; // TODO: e var columnName = e.Column.Name;
if (columnName == FrameColumnName) if (columnName == FrameColumnName)
{ {
@ -212,12 +212,11 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void TasView_ColumnRightClick(object sender, ColumnClickEventArgs e) private void TasView_ColumnRightClick(object sender, InputRoll.ColumnClickEventArgs e)
{ {
var column = TasView.AllColumns[e.Column]; e.Column.Emphasis ^= true;
column.Emphasis ^= true;
Global.StickyXORAdapter.SetSticky(column.Name, column.Emphasis); Global.StickyXORAdapter.SetSticky(e.Column.Name, e.Column.Emphasis);
TasView.Refresh(); TasView.Refresh();
} }