Subtitle editor touchups - Make color cells the color they are representing, display color in hex, put try/catches + error messages if trying to parse erroneous data, tooltips for columns

This commit is contained in:
andres.delikat 2011-07-04 20:34:53 +00:00
parent 26569dab58
commit fed74b17b2
4 changed files with 40 additions and 26 deletions

View File

@ -36,7 +36,7 @@
this.X = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Y = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Length = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Color = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DispColor = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Message = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.SubGrid)).BeginInit();
this.SuspendLayout();
@ -76,7 +76,7 @@
this.X,
this.Y,
this.Length,
this.Color,
this.DispColor,
this.Message});
this.SubGrid.Location = new System.Drawing.Point(12, 12);
this.SubGrid.Name = "SubGrid";
@ -89,6 +89,7 @@
this.Frame.HeaderText = "Frame";
this.Frame.MaxInputLength = 7;
this.Frame.Name = "Frame";
this.Frame.ToolTipText = "The first frame the subtitle will be displayed (integer)";
this.Frame.Width = 75;
//
// X
@ -96,6 +97,7 @@
this.X.HeaderText = "X";
this.X.MaxInputLength = 3;
this.X.Name = "X";
this.X.ToolTipText = "Screen coordinate (absolute)";
this.X.Width = 30;
//
// Y
@ -103,6 +105,7 @@
this.Y.HeaderText = "Y";
this.Y.MaxInputLength = 3;
this.Y.Name = "Y";
this.Y.ToolTipText = "Screen coordinate (absolute)";
this.Y.Width = 30;
//
// Length
@ -110,14 +113,16 @@
this.Length.HeaderText = "Length";
this.Length.MaxInputLength = 5;
this.Length.Name = "Length";
this.Length.ToolTipText = "How long subtitle will be displayed";
this.Length.Width = 50;
//
// Color
// DispColor
//
this.Color.HeaderText = "Color";
this.Color.MaxInputLength = 8;
this.Color.Name = "Color";
this.Color.Width = 60;
this.DispColor.HeaderText = "Color";
this.DispColor.MaxInputLength = 8;
this.DispColor.Name = "DispColor";
this.DispColor.ToolTipText = "Color of subtitle text";
this.DispColor.Width = 60;
//
// Message
//
@ -126,6 +131,7 @@
this.Message.MaxInputLength = 255;
this.Message.MinimumWidth = 25;
this.Message.Name = "Message";
this.Message.ToolTipText = "What will be displayed";
//
// EditSubtitlesForm
//
@ -155,7 +161,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn X;
private System.Windows.Forms.DataGridViewTextBoxColumn Y;
private System.Windows.Forms.DataGridViewTextBoxColumn Length;
private System.Windows.Forms.DataGridViewTextBoxColumn Color;
private System.Windows.Forms.DataGridViewTextBoxColumn DispColor;
private System.Windows.Forms.DataGridViewTextBoxColumn Message;
}
}

View File

@ -14,10 +14,7 @@ namespace BizHawk.MultiClient
public bool ReadOnly;
private Movie selectedMovie = new Movie();
//TODO: Tooltips on cells explaining format
//TODO: Parse hex on color when saving
//TODO: try/catch on parsing int
//TODO: display color in hex when loading from movie
//TODO: color if color cell = value of color cell
public EditSubtitlesForm()
@ -44,6 +41,14 @@ namespace BizHawk.MultiClient
this.Close();
}
private void ShowError(int row, int column)
{
DataGridViewCell c = SubGrid.Rows[row].Cells[column];
string error = "Unable to parse value: " + c.Value.ToString();
string caption = "Parse Error Row " + row.ToString() + " Column " + column.ToString();
MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void OK_Click(object sender, EventArgs e)
{
if (!ReadOnly)
@ -52,18 +57,24 @@ namespace BizHawk.MultiClient
for (int x = 0; x < SubGrid.Rows.Count - 1; x++)
{
Subtitle s = new Subtitle();
DataGridViewCell c = SubGrid.Rows[x].Cells[0];
//TODO: try/catch parsing
s.Frame = int.Parse(c.Value.ToString());
try { s.Frame = int.Parse(c.Value.ToString()); }
catch { ShowError(x, 0); return; }
c = SubGrid.Rows[x].Cells[1];
s.X = int.Parse(c.Value.ToString());
try { s.X = int.Parse(c.Value.ToString()); }
catch { ShowError(x, 1); return; }
c = SubGrid.Rows[x].Cells[2];
s.Y = int.Parse(c.Value.ToString());
try { s.Y = int.Parse(c.Value.ToString()); }
catch { ShowError(x, 2); return; }
c = SubGrid.Rows[x].Cells[3];
s.Duration = int.Parse(c.Value.ToString());
try { s.Duration = int.Parse(c.Value.ToString()); }
catch { ShowError(x, 3); return; }
c = SubGrid.Rows[x].Cells[4];
s.Color = uint.Parse(c.Value.ToString());
c = SubGrid.Rows[x].Cells[5];
try { s.Color = uint.Parse(c.Value.ToString()); }
catch { ShowError(x, 4); return; }
try { c = SubGrid.Rows[x].Cells[5]; }
catch { ShowError(x, 5); return; }
s.Message = c.Value.ToString();
selectedMovie.Subtitles.AddSubtitle(s);
}
@ -91,7 +102,8 @@ namespace BizHawk.MultiClient
c = SubGrid.Rows[x].Cells[3];
c.Value = s.Duration;
c = SubGrid.Rows[x].Cells[4];
c.Value = s.Color; //TODO: view in hex
c.Value = String.Format("{0:X8}", s.Color);
c.Style.BackColor = Color.FromArgb((int)s.Color);
c = SubGrid.Rows[x].Cells[5];
c.Value = s.Message;
}
@ -109,7 +121,8 @@ namespace BizHawk.MultiClient
c = SubGrid.Rows[index].Cells[3];
c.Value = s.Duration;
c = SubGrid.Rows[index].Cells[4];
c.Value = s.Color; //TODO: view in hex
c.Value = String.Format("{0:X8}", s.Color);
c.Style.BackColor = Color.FromArgb((int)s.Color);
c = SubGrid.Rows[index].Cells[5];
c.Value = s.Message;
}

View File

@ -129,7 +129,7 @@
<metadata name="Length.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Color.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="DispColor.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Message.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -145,11 +145,6 @@
this.DurationNumeric.Name = "DurationNumeric";
this.DurationNumeric.Size = new System.Drawing.Size(56, 20);
this.DurationNumeric.TabIndex = 30;
this.DurationNumeric.Value = new decimal(new int[] {
9999,
0,
0,
0});
//
// label4
//