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

@ -28,79 +28,92 @@
/// </summary>
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;
}
}

View File

@ -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]);

View File

@ -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)