Input Roll - FullRowSelect and MultiSelect properties, SelectedIndexChanged event

This commit is contained in:
adelikat 2014-08-14 23:10:56 +00:00
parent 53a765ec7c
commit 813d1b1669
4 changed files with 75 additions and 12 deletions

View File

@ -84,8 +84,16 @@ namespace BizHawk.Client.EmuHawk
/// Indicates whether the entire row will always be selected
/// </summary>
[Category("Appearance")]
[DefaultValue(false)]
public bool FullRowSelect { get; set; }
/// <summary>
/// Allows multiple items to be selected
/// </summary>
[Category("Behavior")]
[DefaultValue(true)]
public bool MultiSelect { get; set; }
#endregion
#region Event Handlers
@ -108,9 +116,18 @@ namespace BizHawk.Client.EmuHawk
[Category("Mouse")]
public event CellChangeEventHandler PointedCellChanged;
/// <summary>
/// Occurs when a column header is clicked
/// </summary>
[Category("Action")]
public event ColumnClickEventHandler ColumnClick;
/// <summary>
/// Occurs whenever the 'SelectedItems' property for this control changes
/// </summary>
[Category("Behavior")]
public event SelectedIndexChangedHandler SelectedIndexChanged;
/// <summary>
/// Retrieve the text for a cell
/// </summary>
@ -125,6 +142,8 @@ namespace BizHawk.Client.EmuHawk
public delegate void ColumnClickEventHandler(object sender, ColumnClickEventArgs e);
public delegate void SelectedIndexChangedHandler(object sender, EventArgs e);
public class CellEventArgs
{
public CellEventArgs(Cell oldCell, Cell newCell)
@ -194,7 +213,8 @@ namespace BizHawk.Client.EmuHawk
{
return SelectedItems
.Where(cell => cell.RowIndex.HasValue)
.Select(cell => cell.RowIndex.Value);
.Select(cell => cell.RowIndex.Value)
.Distinct();
}
}
@ -578,13 +598,11 @@ namespace BizHawk.Client.EmuHawk
}
else if (IsHoveringOnDataCell)
{
// Alt+Click
if (ModifierKeys.HasFlag(Keys.Shift) && !ModifierKeys.HasFlag(Keys.Control) && !ModifierKeys.HasFlag(Keys.Alt))
if (ModifierKeys == Keys.Alt)
{
MessageBox.Show("Alt click logic is not yet implemented");
}
// Shift Click
else if (ModifierKeys.HasFlag(Keys.Shift) && !ModifierKeys.HasFlag(Keys.Control) && !ModifierKeys.HasFlag(Keys.Alt))
else if (ModifierKeys == Keys.Shift)
{
if (SelectedItems.Any())
{
@ -592,21 +610,19 @@ namespace BizHawk.Client.EmuHawk
}
else
{
SelectedItems.Add(CurrentCell);
SelectCell(CurrentCell);
}
}
// Ctrl Click
else if (ModifierKeys.HasFlag(Keys.Control) && !ModifierKeys.HasFlag(Keys.Shift) && !ModifierKeys.HasFlag(Keys.Alt))
else if (ModifierKeys == Keys.Control)
{
SelectedItems.Add(CurrentCell);
SelectCell(CurrentCell);
}
else
{
SelectedItems.Clear();
SelectedItems.Add(CurrentCell);
SelectCell(CurrentCell);
}
// TODO: selected index changed event
Refresh();
}
@ -617,6 +633,32 @@ namespace BizHawk.Client.EmuHawk
#region Helpers
private void SelectCell(Cell cell)
{
if (!MultiSelect)
{
SelectedItems.Clear();
}
if (FullRowSelect)
{
foreach (var column in Columns)
{
SelectedItems.Add(new Cell
{
RowIndex = cell.RowIndex,
Column = column
});
}
}
else
{
SelectedItems.Add(CurrentCell);
}
SelectedIndexChanged(this, new EventArgs());
}
private bool IsHoveringOnColumnCell
{
get

View File

@ -34,6 +34,7 @@
this.label1 = new System.Windows.Forms.Label();
this.CurrentCellLabel = new System.Windows.Forms.Label();
this.InputView = new BizHawk.Client.EmuHawk.InputRoll();
this.OutputLabel = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -92,6 +93,7 @@
this.InputView.HorizontalOrientation = false;
this.InputView.ItemCount = 0;
this.InputView.Location = new System.Drawing.Point(12, 103);
this.InputView.MultiSelect = false;
this.InputView.Name = "InputView";
this.InputView.Size = new System.Drawing.Size(380, 303);
this.InputView.TabIndex = 1;
@ -99,12 +101,23 @@
this.InputView.VirtualMode = false;
this.InputView.PointedCellChanged += new BizHawk.Client.EmuHawk.InputRoll.CellChangeEventHandler(this.InputView_PointedCellChanged);
this.InputView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.InputView_ColumnClick);
this.InputView.SelectedIndexChanged += new BizHawk.Client.EmuHawk.InputRoll.SelectedIndexChangedHandler(this.InputView_SelectedIndexChanged);
//
// OutputLabel
//
this.OutputLabel.AutoSize = true;
this.OutputLabel.Location = new System.Drawing.Point(12, 51);
this.OutputLabel.Name = "OutputLabel";
this.OutputLabel.Size = new System.Drawing.Size(35, 13);
this.OutputLabel.TabIndex = 4;
this.OutputLabel.Text = "label2";
//
// TasStudioExperiment
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(404, 418);
this.Controls.Add(this.OutputLabel);
this.Controls.Add(this.CurrentCellLabel);
this.Controls.Add(this.label1);
this.Controls.Add(this.InputView);
@ -128,5 +141,6 @@
private InputRoll InputView;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label CurrentCellLabel;
private System.Windows.Forms.Label OutputLabel;
}
}

View File

@ -58,6 +58,8 @@ namespace BizHawk.Client.EmuHawk
InputView.QueryItemText += TasView_QueryItemText;
InputView.QueryItemBkColor += TasView_QueryItemBkColor;
r = new Random((int)DateTime.Now.Ticks);
InputView.FullRowSelect = true;
InputView.MultiSelect = false;
}
private int? columnClicked = null;
@ -283,5 +285,10 @@ namespace BizHawk.Client.EmuHawk
columnClicked = e.Column;
InputView.Refresh();
}
private void InputView_SelectedIndexChanged(object sender, EventArgs e)
{
OutputLabel.Text = string.Join(",", InputView.SelectedIndices.ToArray());
}
}
}

View File

@ -510,7 +510,7 @@
this.pauseToolStripButton.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Pause;
this.pauseToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.pauseToolStripButton.Name = "pauseToolStripButton";
this.pauseToolStripButton.Size = new System.Drawing.Size(23, 20);
this.pauseToolStripButton.Size = new System.Drawing.Size(23, 22);
this.pauseToolStripButton.Text = "Pause";
this.pauseToolStripButton.Click += new System.EventHandler(this.PauseMenuItem_Click);
//