Tastudio - make comment editor always in edit mode, make it modeless, add a save button

This commit is contained in:
adelikat 2014-11-02 15:20:17 +00:00
parent b10ef0b1a4
commit 829ee72914
3 changed files with 107 additions and 82 deletions

View File

@ -33,6 +33,7 @@
this.OK = new System.Windows.Forms.Button(); this.OK = new System.Windows.Forms.Button();
this.CommentGrid = new System.Windows.Forms.DataGridView(); this.CommentGrid = new System.Windows.Forms.DataGridView();
this.Comment = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Comment = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SaveBtn = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.CommentGrid)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -40,9 +41,9 @@
// //
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(384, 267); this.Cancel.Location = new System.Drawing.Point(399, 267);
this.Cancel.Name = "Cancel"; this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23); this.Cancel.Size = new System.Drawing.Size(60, 23);
this.Cancel.TabIndex = 0; this.Cancel.TabIndex = 0;
this.Cancel.Text = "&Cancel"; this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true; this.Cancel.UseVisualStyleBackColor = true;
@ -51,9 +52,9 @@
// OK // OK
// //
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.Location = new System.Drawing.Point(333, 267);
this.OK.Name = "OK"; this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23); this.OK.Size = new System.Drawing.Size(60, 23);
this.OK.TabIndex = 1; this.OK.TabIndex = 1;
this.OK.Text = "&Ok"; this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
@ -83,6 +84,17 @@
this.Comment.MinimumWidth = 100; this.Comment.MinimumWidth = 100;
this.Comment.Name = "Comment"; 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 // EditCommentsForm
// //
this.AcceptButton = this.OK; this.AcceptButton = this.OK;
@ -90,6 +102,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel; this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(471, 302); this.ClientSize = new System.Drawing.Size(471, 302);
this.Controls.Add(this.SaveBtn);
this.Controls.Add(this.CommentGrid); this.Controls.Add(this.CommentGrid);
this.Controls.Add(this.OK); this.Controls.Add(this.OK);
this.Controls.Add(this.Cancel); this.Controls.Add(this.Cancel);
@ -110,5 +123,6 @@
private System.Windows.Forms.Button OK; private System.Windows.Forms.Button OK;
private System.Windows.Forms.DataGridView CommentGrid; private System.Windows.Forms.DataGridView CommentGrid;
private System.Windows.Forms.DataGridViewTextBoxColumn Comment; private System.Windows.Forms.DataGridViewTextBoxColumn Comment;
private System.Windows.Forms.Button SaveBtn;
} }
} }

View File

@ -20,9 +20,11 @@ namespace BizHawk.Client.EmuHawk
_sortReverse = false; _sortReverse = false;
} }
public bool ForceReadWrite { get; set; }
private void EditCommentsForm_Load(object sender, EventArgs e) private void EditCommentsForm_Load(object sender, EventArgs e)
{ {
if (Global.MovieSession.ReadOnly) if (!ForceReadWrite && Global.MovieSession.ReadOnly)
{ {
CommentGrid.Columns[0].ReadOnly = true; CommentGrid.Columns[0].ReadOnly = true;
Text = "View Comments"; 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) public void GetMovie(IMovie m)
{ {
_selectedMovie = m; _selectedMovie = m;
@ -58,19 +72,15 @@ namespace BizHawk.Client.EmuHawk
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
if (!Global.MovieSession.ReadOnly) Save();
{
_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();
}
Close(); Close();
} }
private void SaveBtn_Click(object sender, EventArgs e)
{
Save();
}
private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) private void OnColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{ {
SortColumn(CommentGrid.Columns[e.ColumnIndex]); SortColumn(CommentGrid.Columns[e.ColumnIndex]);

View File

@ -573,7 +573,8 @@ namespace BizHawk.Client.EmuHawk
{ {
var form = new EditCommentsForm(); var form = new EditCommentsForm();
form.GetMovie(CurrentTasMovie); form.GetMovie(CurrentTasMovie);
form.ShowDialog(); form.ForceReadWrite = true;
form.Show();
} }
private void SubtitlesMenuItem_Click(object sender, EventArgs e) private void SubtitlesMenuItem_Click(object sender, EventArgs e)