From 829ee729142b6287cf735275e3c28c2df1f2ec68 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 2 Nov 2014 15:20:17 +0000 Subject: [PATCH] Tastudio - make comment editor always in edit mode, make it modeless, add a save button --- .../movie/EditCommentsForm.Designer.cs | 154 ++++++++++-------- .../movie/EditCommentsForm.cs | 32 ++-- .../tools/TAStudio/TAStudio.MenuItems.cs | 3 +- 3 files changed, 107 insertions(+), 82 deletions(-) diff --git a/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs b/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs index 68cdd9c729..a228b0f19e 100644 --- a/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/movie/EditCommentsForm.Designer.cs @@ -28,79 +28,92 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditCommentsForm)); - this.Cancel = new System.Windows.Forms.Button(); - this.OK = new System.Windows.Forms.Button(); - this.CommentGrid = new System.Windows.Forms.DataGridView(); - this.Comment = new System.Windows.Forms.DataGridViewTextBoxColumn(); - ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).BeginInit(); - this.SuspendLayout(); - // - // Cancel - // - this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(384, 267); - this.Cancel.Name = "Cancel"; - this.Cancel.Size = new System.Drawing.Size(75, 23); - this.Cancel.TabIndex = 0; - this.Cancel.Text = "&Cancel"; - this.Cancel.UseVisualStyleBackColor = true; - this.Cancel.Click += new System.EventHandler(this.Cancel_Click); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(303, 267); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 1; - this.OK.Text = "&Ok"; - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.OK_Click); - // - // CommentGrid - // - this.CommentGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditCommentsForm)); + this.Cancel = new System.Windows.Forms.Button(); + this.OK = new System.Windows.Forms.Button(); + this.CommentGrid = new System.Windows.Forms.DataGridView(); + this.Comment = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SaveBtn = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).BeginInit(); + this.SuspendLayout(); + // + // Cancel + // + this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Cancel.Location = new System.Drawing.Point(399, 267); + this.Cancel.Name = "Cancel"; + this.Cancel.Size = new System.Drawing.Size(60, 23); + this.Cancel.TabIndex = 0; + this.Cancel.Text = "&Cancel"; + this.Cancel.UseVisualStyleBackColor = true; + this.Cancel.Click += new System.EventHandler(this.Cancel_Click); + // + // OK + // + this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OK.Location = new System.Drawing.Point(333, 267); + this.OK.Name = "OK"; + this.OK.Size = new System.Drawing.Size(60, 23); + this.OK.TabIndex = 1; + this.OK.Text = "&Ok"; + this.OK.UseVisualStyleBackColor = true; + this.OK.Click += new System.EventHandler(this.OK_Click); + // + // CommentGrid + // + this.CommentGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.CommentGrid.BackgroundColor = System.Drawing.SystemColors.ControlLight; - this.CommentGrid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - this.CommentGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.CommentGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.CommentGrid.BackgroundColor = System.Drawing.SystemColors.ControlLight; + this.CommentGrid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; + this.CommentGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.CommentGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Comment}); - this.CommentGrid.Location = new System.Drawing.Point(12, 12); - this.CommentGrid.Name = "CommentGrid"; - this.CommentGrid.Size = new System.Drawing.Size(447, 249); - this.CommentGrid.TabIndex = 2; - this.CommentGrid.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.OnColumnHeaderMouseClick); - // - // Comment - // - this.Comment.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Comment.HeaderText = "Comment"; - this.Comment.MaxInputLength = 512; - this.Comment.MinimumWidth = 100; - this.Comment.Name = "Comment"; - // - // EditCommentsForm - // - this.AcceptButton = this.OK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(471, 302); - this.Controls.Add(this.CommentGrid); - this.Controls.Add(this.OK); - this.Controls.Add(this.Cancel); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(188, 121); - this.Name = "EditCommentsForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Edit Comments"; - this.Load += new System.EventHandler(this.EditCommentsForm_Load); - ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).EndInit(); - this.ResumeLayout(false); + this.CommentGrid.Location = new System.Drawing.Point(12, 12); + this.CommentGrid.Name = "CommentGrid"; + this.CommentGrid.Size = new System.Drawing.Size(447, 249); + this.CommentGrid.TabIndex = 2; + this.CommentGrid.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.OnColumnHeaderMouseClick); + // + // Comment + // + this.Comment.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Comment.HeaderText = "Comment"; + this.Comment.MaxInputLength = 512; + this.Comment.MinimumWidth = 100; + this.Comment.Name = "Comment"; + // + // SaveBtn + // + this.SaveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.SaveBtn.Location = new System.Drawing.Point(12, 267); + this.SaveBtn.Name = "SaveBtn"; + this.SaveBtn.Size = new System.Drawing.Size(75, 23); + this.SaveBtn.TabIndex = 3; + this.SaveBtn.Text = "&Save"; + this.SaveBtn.UseVisualStyleBackColor = true; + this.SaveBtn.Click += new System.EventHandler(this.SaveBtn_Click); + // + // EditCommentsForm + // + this.AcceptButton = this.OK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.Cancel; + this.ClientSize = new System.Drawing.Size(471, 302); + this.Controls.Add(this.SaveBtn); + this.Controls.Add(this.CommentGrid); + this.Controls.Add(this.OK); + this.Controls.Add(this.Cancel); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(188, 121); + this.Name = "EditCommentsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Edit Comments"; + this.Load += new System.EventHandler(this.EditCommentsForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).EndInit(); + this.ResumeLayout(false); } @@ -110,5 +123,6 @@ private System.Windows.Forms.Button OK; private System.Windows.Forms.DataGridView CommentGrid; private System.Windows.Forms.DataGridViewTextBoxColumn Comment; + private System.Windows.Forms.Button SaveBtn; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs b/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs index 5d6aab31aa..922137b526 100644 --- a/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs +++ b/BizHawk.Client.EmuHawk/movie/EditCommentsForm.cs @@ -20,9 +20,11 @@ namespace BizHawk.Client.EmuHawk _sortReverse = false; } + public bool ForceReadWrite { get; set; } + private void EditCommentsForm_Load(object sender, EventArgs e) { - if (Global.MovieSession.ReadOnly) + if (!ForceReadWrite && Global.MovieSession.ReadOnly) { CommentGrid.Columns[0].ReadOnly = true; Text = "View Comments"; @@ -35,6 +37,18 @@ namespace BizHawk.Client.EmuHawk } } + private void Save() + { + _selectedMovie.Comments.Clear(); + for (int i = 0; i < CommentGrid.Rows.Count - 1; i++) + { + var c = CommentGrid.Rows[i].Cells[0]; + _selectedMovie.Comments.Add(c.Value.ToString()); + } + + _selectedMovie.Save(); + } + public void GetMovie(IMovie m) { _selectedMovie = m; @@ -58,19 +72,15 @@ namespace BizHawk.Client.EmuHawk private void OK_Click(object sender, EventArgs e) { - if (!Global.MovieSession.ReadOnly) - { - _selectedMovie.Comments.Clear(); - for (int i = 0; i < CommentGrid.Rows.Count - 1; i++) - { - var c = CommentGrid.Rows[i].Cells[0]; - _selectedMovie.Comments.Add("comment " + c.Value); - } - _selectedMovie.Save(); - } + Save(); Close(); } + private void SaveBtn_Click(object sender, EventArgs e) + { + Save(); + } + private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { SortColumn(CommentGrid.Columns[e.ColumnIndex]); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 2a25ae0986..11c38d6f02 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -573,7 +573,8 @@ namespace BizHawk.Client.EmuHawk { var form = new EditCommentsForm(); form.GetMovie(CurrentTasMovie); - form.ShowDialog(); + form.ForceReadWrite = true; + form.Show(); } private void SubtitlesMenuItem_Click(object sender, EventArgs e)