From 813d1b1669acdb0ca7ab92aadba95abd018da1dd Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 14 Aug 2014 23:10:56 +0000 Subject: [PATCH] Input Roll - FullRowSelect and MultiSelect properties, SelectedIndexChanged event --- .../tools/TAStudio/InputRoll.cs | 64 +++++++++++++++---- .../TAStudio/TasStudioExperiment.Designer.cs | 14 ++++ .../tools/TAStudio/TasStudioExperiment.cs | 7 ++ .../tools/Watch/RamWatch.Designer.cs | 2 +- 4 files changed, 75 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 00b34e45e3..7dfd5a8cf3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -84,8 +84,16 @@ namespace BizHawk.Client.EmuHawk /// Indicates whether the entire row will always be selected /// [Category("Appearance")] + [DefaultValue(false)] public bool FullRowSelect { get; set; } + /// + /// Allows multiple items to be selected + /// + [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; + /// + /// Occurs when a column header is clicked + /// [Category("Action")] public event ColumnClickEventHandler ColumnClick; + /// + /// Occurs whenever the 'SelectedItems' property for this control changes + /// + [Category("Behavior")] + public event SelectedIndexChangedHandler SelectedIndexChanged; + /// /// Retrieve the text for a cell /// @@ -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 diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs index e6435e6d0d..6c18d0cfc4 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs index bc16c256c0..94d4b38bb3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TasStudioExperiment.cs @@ -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()); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs index 5f76bbdd28..dc5285408f 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.Designer.cs @@ -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); //