From d8216ae0fc8373b82dc913e187caaa3204fef340 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 16 Jul 2014 02:17:19 +0000 Subject: [PATCH] Tastudio - remove marker button --- .../movie/tasproj/TasMovieMarker.cs | 2 +- .../tools/TAStudio/MarkerControl.Designer.cs | 16 ++++++++ .../tools/TAStudio/MarkerControl.cs | 40 +++++++++++++++++-- .../tools/TAStudio/TAStudio.Designer.cs | 3 +- .../tools/TAStudio/TAStudio.cs | 5 +-- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs index 7b06e2c869..a6e5d11558 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs @@ -76,7 +76,7 @@ namespace BizHawk.Client.Common { public override string ToString() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); foreach (var marker in this) { sb.AppendLine(marker.ToString()); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.Designer.cs index 1d8cec1eb8..51996b4715 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.AddBtn = new System.Windows.Forms.Button(); + this.RemoveBtn = new System.Windows.Forms.Button(); this.MarkerView = new BizHawk.Client.EmuHawk.VirtualListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -45,6 +46,18 @@ this.AddBtn.UseVisualStyleBackColor = true; this.AddBtn.Click += new System.EventHandler(this.AddBtn_Click); // + // RemoveBtn + // + this.RemoveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.RemoveBtn.Enabled = false; + this.RemoveBtn.Location = new System.Drawing.Point(3, 214); + this.RemoveBtn.Name = "RemoveBtn"; + this.RemoveBtn.Size = new System.Drawing.Size(58, 23); + this.RemoveBtn.TabIndex = 7; + this.RemoveBtn.Text = "Remove"; + this.RemoveBtn.UseVisualStyleBackColor = true; + this.RemoveBtn.Click += new System.EventHandler(this.RemoveBtn_Click); + // // MarkerView // this.MarkerView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -69,6 +82,7 @@ this.MarkerView.TabStop = false; this.MarkerView.UseCompatibleStateImageBehavior = false; this.MarkerView.View = System.Windows.Forms.View.Details; + this.MarkerView.SelectedIndexChanged += new System.EventHandler(this.MarkerView_SelectedIndexChanged); // // columnHeader1 // @@ -84,6 +98,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.RemoveBtn); this.Controls.Add(this.AddBtn); this.Controls.Add(this.MarkerView); this.Name = "MarkerControl"; @@ -99,6 +114,7 @@ public System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.Button AddBtn; + private System.Windows.Forms.Button RemoveBtn; } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index b6048bad13..000ba836ea 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -14,10 +14,12 @@ namespace BizHawk.Client.EmuHawk public partial class MarkerControl : UserControl { public TasMovieMarkerList Markers {get; set; } - public Action AddCallback { get; set; } - public MarkerControl() + private readonly TAStudio _tastudio; + + public MarkerControl(TAStudio tastudio) { + _tastudio = tastudio; InitializeComponent(); MarkerView.QueryItemBkColor += MarkerView_QueryItemBkColor; MarkerView.QueryItemText += MarkerView_QueryItemText; @@ -41,7 +43,7 @@ namespace BizHawk.Client.EmuHawk { if (index == Markers.IndexOf(prev)) { - color = Color.LightGreen; + color = Color.FromArgb(0xE0FBE0); } } } @@ -62,7 +64,7 @@ namespace BizHawk.Client.EmuHawk private void AddBtn_Click(object sender, EventArgs e) { - AddCallback(null); + _tastudio.CallAddMarkerPopUp(); } public new void Refresh() @@ -74,5 +76,35 @@ namespace BizHawk.Client.EmuHawk base.Refresh(); } + + private void MarkerView_SelectedIndexChanged(object sender, EventArgs e) + { + RemoveBtn.Enabled = SelectedIndices.Any(); + } + + private void RemoveBtn_Click(object sender, EventArgs e) + { + SelectedMarkers.ForEach(i => Markers.Remove(i)); + _tastudio.RefreshDialog(); + } + + private IEnumerable SelectedIndices + { + get + { + return MarkerView.SelectedIndices + .OfType(); + } + } + + private List SelectedMarkers + { + get + { + return SelectedIndices + .Select(index => Markers[index]) + .ToList(); + } + } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 7b5a516c44..6f0ed1678f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -107,7 +107,7 @@ namespace BizHawk.Client.EmuHawk this.MessageStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.SplicerStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.TasPlaybackBox = new BizHawk.Client.EmuHawk.PlaybackBox(); - this.MarkerControl = new BizHawk.Client.EmuHawk.MarkerControl(); + this.MarkerControl = new BizHawk.Client.EmuHawk.MarkerControl(this); this.TASMenu.SuspendLayout(); this.TasStatusStrip.SuspendLayout(); this.SuspendLayout(); @@ -740,7 +740,6 @@ namespace BizHawk.Client.EmuHawk // // MarkerControl // - this.MarkerControl.AddCallback = null; this.MarkerControl.Location = new System.Drawing.Point(302, 151); this.MarkerControl.Markers = null; this.MarkerControl.Name = "MarkerControl"; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 96027e2a0c..ae8f4d4815 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -68,7 +68,6 @@ namespace BizHawk.Client.EmuHawk public TAStudio() { InitializeComponent(); - MarkerControl.AddCallback = CallAddMarkerPopUp; TasView.QueryItemText += TasView_QueryItemText; TasView.QueryItemBkColor += TasView_QueryItemBkColor; TasView.VirtualMode = true; @@ -210,7 +209,7 @@ namespace BizHawk.Client.EmuHawk } } - private void RefreshDialog() + public void RefreshDialog() { TasView.ItemCount = _tas.InputLogLength; if (MarkerControl != null) @@ -327,7 +326,7 @@ namespace BizHawk.Client.EmuHawk Owner = Global.Config.TAStudioSettings.FloatingWindow ? null : GlobalWin.MainForm; } - private void CallAddMarkerPopUp(int? frame = null) + public void CallAddMarkerPopUp(int? frame = null) { var markerFrame = frame ?? TasView.LastSelectedIndex ?? Global.Emulator.Frame; InputPrompt i = new InputPrompt