From 1bf8f80510724f55c280f12a295c6634b8b9009d Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 9 Jul 2020 19:24:44 -0500 Subject: [PATCH] Subtitle Editor - add a color picker for editing the subtitle color, fixes #1554 --- .../movie/EditSubtitlesForm.Designer.cs | 1 + .../movie/EditSubtitlesForm.cs | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs index bf517d9b8d..4f86c3962c 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.Designer.cs @@ -85,6 +85,7 @@ this.SubGrid.Name = "SubGrid"; this.SubGrid.Size = new System.Drawing.Size(548, 198); this.SubGrid.TabIndex = 2; + this.SubGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SubGrid_CellContentClick); this.SubGrid.DefaultValuesNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.SubGrid_DefaultValuesNeeded); this.SubGrid.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubGrid_MouseDoubleClick); // diff --git a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs index c57f5ea568..dfa81181f2 100644 --- a/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs +++ b/src/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using System.Globalization; using BizHawk.Client.Common; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Client.EmuHawk { @@ -256,5 +257,27 @@ namespace BizHawk.Client.EmuHawk { _selectedMovie.Subtitles.AddColorTag = AddColorTag.Checked; } + + private void SubGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + if (!_readOnly && e.ColumnIndex == 4) + { + var color = Color.White; + var val = SubGrid[e.ColumnIndex, e.RowIndex].Value; + if (val != null) + { + var hex = int.Parse(val.ToString(), NumberStyles.HexNumber); + color = Color.FromArgb(hex); + } + + using var picker = new ColorDialog { AllowFullOpen = true, AnyColor = true, Color = color }; + if (picker.ShowDialog().IsOk()) + { + SubGrid[e.ColumnIndex, e.RowIndex].Value = picker.Color.ToArgb().ToHexString(8); + SubGrid[e.ColumnIndex, e.RowIndex].Style.BackColor = picker.Color; + SubGrid.RefreshEdit(); + } + } + } } }