Add color picker from main window (assa context menu or shortcut)

This commit is contained in:
niksedk 2022-09-03 18:51:55 +02:00
parent f9d42ead11
commit 58a1d69b7f
10 changed files with 111 additions and 39 deletions

View File

@ -2196,6 +2196,7 @@ $HorzAlign = Center
public string GeneralApplyAssaOverrideTags { get; set; }
public string GeneralSetAssaPosition { get; set; }
public string GeneralSetAssaResolution { get; set; }
public string GeneralColorPicker { get; set; }
public string GeneralTakeAutoBackup { get; set; }
public string GeneralHelp { get; set; }
@ -8933,6 +8934,12 @@ $HorzAlign = Center
shortcuts.GeneralSetAssaResolution = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralColorPicker");
if (subNode != null)
{
shortcuts.GeneralColorPicker = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralTakeAutoBackup");
if (subNode != null)
{
@ -10860,6 +10867,7 @@ $HorzAlign = Center
textWriter.WriteElementString("GeneralApplyAssaOverrideTags", shortcuts.GeneralApplyAssaOverrideTags);
textWriter.WriteElementString("GeneralSetAssaPosition", shortcuts.GeneralSetAssaPosition);
textWriter.WriteElementString("GeneralSetAssaResolution", shortcuts.GeneralSetAssaResolution);
textWriter.WriteElementString("GeneralColorPicker", shortcuts.GeneralColorPicker);
textWriter.WriteElementString("GeneralTakeAutoBackup", shortcuts.GeneralTakeAutoBackup);
textWriter.WriteElementString("MainListViewRemoveTimeCodes", shortcuts.MainListViewRemoveTimeCodes);
textWriter.WriteElementString("MainEditFixRTLViaUnicodeChars", shortcuts.MainEditFixRTLViaUnicodeChars);

View File

@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private bool _loading = true;
private string _assaBox;
private readonly Random _random = new Random();
private string _boxStyleName;
private readonly string _boxStyleName;
private int _top;
private int _bottom;
private int _left;
@ -57,7 +57,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
private long _totalFrames;
private FileSystemWatcher _drawingFileWatcher;
private readonly Subtitle _wholeSubtitle;
private static bool _bt601Bt709On = false;
private static bool _bt601Bt709On = true;
public AssSetBackground(Subtitle subtitle, int[] selectedIndices, string videoFileName, VideoInfo videoInfo, double videoPositionSeconds)
{

View File

@ -1,6 +1,6 @@
namespace Nikse.SubtitleEdit.Forms.Assa
{
partial class ImageColorPicker
sealed partial class ImageColorPicker
{
/// <summary>
/// Required designer variable.

View File

@ -2,10 +2,11 @@
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Forms.Ocr;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms.Assa
{
public partial class ImageColorPicker : Form
public sealed partial class ImageColorPicker : Form
{
private readonly Bitmap _bitmap;
private bool _colorPickerOn = true;
@ -32,6 +33,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
Width = _bitmap.Width + 10;
Height = _bitmap.Height + (Height - pictureBoxImage.Height);
Text = LanguageSettings.Current.ImageColorPicker.Title;
}
private void pictureBoxImage_MouseMove(object sender, MouseEventArgs e)

View File

@ -40,9 +40,9 @@ namespace Nikse.SubtitleEdit.Forms
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode4 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode5 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode6 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode2 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode3 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.labelStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripSelected = new System.Windows.Forms.ToolStripStatusLabel();
@ -564,6 +564,7 @@ namespace Nikse.SubtitleEdit.Forms
this.timerOriginalTextUndo = new System.Windows.Forms.Timer(this.components);
this.contextMenuStripShowVideoControls = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemShowVideoControls = new System.Windows.Forms.ToolStripMenuItem();
this.colorPickerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
@ -2630,7 +2631,8 @@ namespace Nikse.SubtitleEdit.Forms
this.setPositionToolStripMenuItem,
this.progressBarToolStripMenuItem,
this.videoResolutionResamplerToolStripMenuItem,
this.generateBackgroundBoxToolStripMenuItem});
this.generateBackgroundBoxToolStripMenuItem,
this.colorPickerToolStripMenuItem});
this.toolStripMenuItemAssaTools.Name = "toolStripMenuItemAssaTools";
this.toolStripMenuItemAssaTools.Size = new System.Drawing.Size(284, 22);
this.toolStripMenuItemAssaTools.Text = "ASSA tools";
@ -3655,14 +3657,14 @@ namespace Nikse.SubtitleEdit.Forms
this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition";
this.timeUpDownVideoPosition.Size = new System.Drawing.Size(113, 27);
this.timeUpDownVideoPosition.TabIndex = 12;
timeCode4.Hours = 0;
timeCode4.Milliseconds = 0;
timeCode4.Minutes = 0;
timeCode4.Seconds = 0;
timeCode4.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode4.TotalMilliseconds = 0D;
timeCode4.TotalSeconds = 0D;
this.timeUpDownVideoPosition.TimeCode = timeCode4;
timeCode1.Hours = 0;
timeCode1.Milliseconds = 0;
timeCode1.Minutes = 0;
timeCode1.Seconds = 0;
timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode1.TotalMilliseconds = 0D;
timeCode1.TotalSeconds = 0D;
this.timeUpDownVideoPosition.TimeCode = timeCode1;
this.timeUpDownVideoPosition.UseVideoOffset = false;
//
// buttonGotoSub
@ -3895,14 +3897,14 @@ namespace Nikse.SubtitleEdit.Forms
this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust";
this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(113, 27);
this.timeUpDownVideoPositionAdjust.TabIndex = 13;
timeCode5.Hours = 0;
timeCode5.Milliseconds = 0;
timeCode5.Minutes = 0;
timeCode5.Seconds = 0;
timeCode5.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode5.TotalMilliseconds = 0D;
timeCode5.TotalSeconds = 0D;
this.timeUpDownVideoPositionAdjust.TimeCode = timeCode5;
timeCode2.Hours = 0;
timeCode2.Milliseconds = 0;
timeCode2.Minutes = 0;
timeCode2.Seconds = 0;
timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode2.TotalMilliseconds = 0D;
timeCode2.TotalSeconds = 0D;
this.timeUpDownVideoPositionAdjust.TimeCode = timeCode2;
this.timeUpDownVideoPositionAdjust.UseVideoOffset = false;
//
// buttonAdjustSetEndTime
@ -5122,14 +5124,14 @@ namespace Nikse.SubtitleEdit.Forms
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(113, 27);
this.timeUpDownStartTime.TabIndex = 0;
timeCode6.Hours = 0;
timeCode6.Milliseconds = 0;
timeCode6.Minutes = 0;
timeCode6.Seconds = 0;
timeCode6.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode6.TotalMilliseconds = 0D;
timeCode6.TotalSeconds = 0D;
this.timeUpDownStartTime.TimeCode = timeCode6;
timeCode3.Hours = 0;
timeCode3.Milliseconds = 0;
timeCode3.Minutes = 0;
timeCode3.Seconds = 0;
timeCode3.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode3.TotalMilliseconds = 0D;
timeCode3.TotalSeconds = 0D;
this.timeUpDownStartTime.TimeCode = timeCode3;
this.timeUpDownStartTime.UseVideoOffset = false;
//
// numericUpDownDuration
@ -5437,6 +5439,7 @@ namespace Nikse.SubtitleEdit.Forms
this.mediaPlayer.SubtitleText = "";
this.mediaPlayer.TabIndex = 5;
this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No;
this.mediaPlayer.UsingFrontCenterAudioChannelOnly = false;
this.mediaPlayer.VideoHeight = 0;
this.mediaPlayer.VideoPlayer = null;
this.mediaPlayer.VideoWidth = 0;
@ -5499,6 +5502,13 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripMenuItemShowVideoControls.Text = "Show video controls";
this.toolStripMenuItemShowVideoControls.Click += new System.EventHandler(this.toolStripMenuItemShowVideoControls_Click);
//
// colorPickerToolStripMenuItem
//
this.colorPickerToolStripMenuItem.Name = "colorPickerToolStripMenuItem";
this.colorPickerToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
this.colorPickerToolStripMenuItem.Text = "Color picker...";
this.colorPickerToolStripMenuItem.Click += new System.EventHandler(this.colorPickerToolStripMenuItem_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -6107,5 +6117,6 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.ToolStripButton toolStripButtonBurnIn;
private System.Windows.Forms.ToolStripButton toolStripButtonSpellCheck;
private System.Windows.Forms.ToolStripMenuItem wordListsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem colorPickerToolStripMenuItem;
}
}

View File

@ -1821,6 +1821,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBarToolStripMenuItem.Text = _language.Menu.ContextMenu.GenerateProgressBar;
videoResolutionResamplerToolStripMenuItem.Text = _language.Menu.ContextMenu.AssaResolutionChanger;
generateBackgroundBoxToolStripMenuItem.Text = _language.Menu.ContextMenu.AssaGenerateBackgroundBox;
colorPickerToolStripMenuItem.Text = _language.Menu.ContextMenu.ImageColorPicker;
toolStripMenuItemDelete.Text = _language.Menu.ContextMenu.Delete;
insertLineToolStripMenuItem.Text = _language.Menu.ContextMenu.InsertFirstLine;
@ -24803,6 +24804,7 @@ namespace Nikse.SubtitleEdit.Forms
translateToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateAuto);
applyCustomStylesToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralApplyAssaOverrideTags);
setPositionToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralSetAssaPosition);
colorPickerToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralColorPicker);
audioVisualizer.InsertAtVideoPositionShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition);
audioVisualizer.Move100MsLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform100MsLeft);
@ -34309,5 +34311,42 @@ namespace Nikse.SubtitleEdit.Forms
form.ShowDialog(this);
}
}
private void colorPickerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_videoFileName))
{
MessageBox.Show(_languageGeneral.NoVideoLoaded);
return;
}
try
{
Cursor = Cursors.WaitCursor;
var timeCode = new TimeCode(mediaPlayer.CurrentPosition * 1000.0 + 1000).ToHHMMSS();
var colorMatrix = "bt601:bt709"; // ffmpeg bug with assa color?
var bmpFileName = VideoPreviewGenerator.GetScreenShot(_videoFileName, timeCode, colorMatrix);
using (var bmp = new Bitmap(bmpFileName))
{
Cursor = Cursors.Default;
using (var form = new ImageColorPicker(bmp))
{
if (form.ShowDialog(this) != DialogResult.OK)
{
return;
}
ColorChooser.SetLastColor(form.Color);
ShowStatus(string.Format(LanguageSettings.Current.AssaSetBackgroundBox.ColorPickerSetLastColor, Utilities.ColorToHexWithTransparency(form.Color)));
}
}
_filesToDelete.Add(bmpFileName);
}
finally
{
Cursor = Cursors.Default;
}
}
}
}

View File

@ -715,9 +715,6 @@
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>652, 56</value>
</metadata>
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>652, 56</value>
</metadata>
<data name="toolStripButtonWaveformZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -813,12 +810,12 @@
<metadata name="imageListBookmarks.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>981, 56</value>
</metadata>
<metadata name="contextMenuStripTextBoxSourceView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>193, 17</value>
</metadata>
<metadata name="contextMenuStripTextBoxListView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>668, 17</value>
</metadata>
<metadata name="contextMenuStripTextBoxSourceView.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>193, 17</value>
</metadata>
<metadata name="contextMenuStripEmpty.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 95</value>
</metadata>
@ -830,7 +827,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAZwBLQGcAS0BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAaQBLQGkAS0BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -1279,6 +1279,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
AddNode(generalNode, language.ApplyAssaOverrideTags, nameof(Configuration.Settings.Shortcuts.GeneralApplyAssaOverrideTags), true);
AddNode(generalNode, language.SetAssaPosition, nameof(Configuration.Settings.Shortcuts.GeneralSetAssaPosition), true);
AddNode(generalNode, language.SetAssaResolution, nameof(Configuration.Settings.Shortcuts.GeneralSetAssaResolution));
AddNode(generalNode, LanguageSettings.Current.ImageColorPicker.Title, nameof(Configuration.Settings.Shortcuts.GeneralColorPicker));
AddNode(generalNode, language.TakeAutoBackup, nameof(Configuration.Settings.Shortcuts.GeneralTakeAutoBackup));
AddNode(generalNode, language.Help, nameof(Configuration.Settings.Shortcuts.GeneralHelp), true);
_shortcuts.Nodes.Add(generalNode);

View File

@ -23,6 +23,7 @@ namespace Nikse.SubtitleEdit.Logic
public LanguageStructure.AssaOverrideTags AssaOverrideTags;
public LanguageStructure.AssaProgressBarGenerator AssaProgressBarGenerator;
public LanguageStructure.AssaResulationChanger AssaResulationChanger;
public LanguageStructure.ImageColorPicker ImageColorPicker;
public LanguageStructure.AssaSetBackgroundBox AssaSetBackgroundBox;
public LanguageStructure.AssaSetPosition AssaSetPosition;
public LanguageStructure.AutoBreakUnbreakLines AutoBreakUnbreakLines;
@ -389,6 +390,11 @@ namespace Nikse.SubtitleEdit.Logic
SourceAndTargetEqual = "Source and target resolution is the same - nothing to do.",
};
ImageColorPicker = new LanguageStructure.ImageColorPicker
{
Title = "Image color picker",
};
AssaSetBackgroundBox = new LanguageStructure.AssaSetBackgroundBox
{
Title = "Generate background box",
@ -1945,6 +1951,7 @@ namespace Nikse.SubtitleEdit.Logic
GenerateProgressBar = "Generate progress bar...",
AssaResolutionChanger = "Change ASSA script resolution...",
AssaGenerateBackgroundBox = "Generate background box...",
ImageColorPicker = "Image color picker...",
FixCommonErrorsInSelectedLines = "Fix common errors in selected lines...",
ChangeCasingForSelectedLines = "Change casing for selected lines...",
SaveSelectedLines = "Save selected lines as...",

View File

@ -247,6 +247,11 @@
public string SourceAndTargetEqual { get; set; }
}
public class ImageColorPicker
{
public string Title { get; set; }
}
public class AssaSetBackgroundBox
{
public string Title { get; set; }
@ -1790,6 +1795,7 @@
public string GenerateProgressBar { get; set; }
public string AssaResolutionChanger { get; set; }
public string AssaGenerateBackgroundBox { get; set; }
public string ImageColorPicker { get; set; }
public string FixCommonErrorsInSelectedLines { get; set; }
public string ChangeCasingForSelectedLines { get; set; }
public string SaveSelectedLines { get; set; }