From 663bd9d554266c994de8ecbde1741daebcc35c00 Mon Sep 17 00:00:00 2001 From: "Martijn van Berkel (Flitskikker)" Date: Mon, 13 Apr 2020 19:32:35 +0200 Subject: [PATCH] Add total pixel width in main window --- src/Forms/Main.cs | 63 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 325cd5ef3..cd536b94b 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -8793,7 +8793,15 @@ namespace Nikse.SubtitleEdit.Forms { if (!textBoxHasFocus) { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", s.Length, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + } } buttonSplitLine.Visible = true; @@ -8804,7 +8812,15 @@ namespace Nikse.SubtitleEdit.Forms lineTotal.ForeColor = UiUtil.ForeColor; if (!textBoxHasFocus) { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", s.Length, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + } } } else @@ -8812,14 +8828,30 @@ namespace Nikse.SubtitleEdit.Forms lineTotal.ForeColor = Color.Red; if (!textBoxHasFocus) { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, s.Length); + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, string.Format("{0} {1}", s.Length, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, s.Length); + } } if (buttonUnBreak.Visible) { if (!textBoxHasFocus) { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", s.Length, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + } } var abl = Utilities.AutoBreakLine(s, "en").SplitToLines(); @@ -8834,7 +8866,15 @@ namespace Nikse.SubtitleEdit.Forms { if (!textBoxHasFocus) { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", s.Length, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, s.Length); + } } var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); @@ -23963,7 +24003,18 @@ namespace Nikse.SubtitleEdit.Forms int pos = textBox.SelectionStart; var s = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Replace(Environment.NewLine, string.Empty); // we don't count new line in total length... correct? int totalLength = s.Length; - string totalL = " " + string.Format(_languageGeneral.TotalLengthX, totalLength); + string totalL; + + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + totalL = " " + string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", totalLength, totalLengthPixels)); + } + else + { + totalL = " " + string.Format(_languageGeneral.TotalLengthX, totalLength); + } + if (lineBreakPos < 0 || pos <= lineBreakPos) { lineTotal.Text = "1," + (pos + 1) + totalL;