Added sorting by chars/sec

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@627 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-09-13 05:46:13 +00:00
parent 712c5bd85b
commit 4013323105
7 changed files with 51 additions and 20 deletions

View File

@ -126,6 +126,7 @@
this.sortTextMaxLineLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sortTextMaxLineLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sortTextTotalLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sortTextTotalLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sortTextNumberOfLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.sortTextNumberOfLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textCharssecToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemShowOriginalInPreview = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemShowOriginalInPreview = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemMakeEmptyFromCurrent = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemMakeEmptyFromCurrent = new System.Windows.Forms.ToolStripMenuItem();
@ -156,8 +157,8 @@
this.pointSyncViaOtherSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pointSyncViaOtherSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemChangeFrameRate2 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemChangeFrameRate2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemAutoTranslate = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemAutoTranslate = new System.Windows.Forms.ToolStripMenuItem();
this.translateByGoogleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.translatepoweredByMicrosoftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.translatepoweredByMicrosoftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.translateByGoogleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.translateFromSwedishToDanishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.translateFromSwedishToDanishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -1196,7 +1197,8 @@
this.sortTextAlphabeticallytoolStripMenuItem, this.sortTextAlphabeticallytoolStripMenuItem,
this.sortTextMaxLineLengthToolStripMenuItem, this.sortTextMaxLineLengthToolStripMenuItem,
this.sortTextTotalLengthToolStripMenuItem, this.sortTextTotalLengthToolStripMenuItem,
this.sortTextNumberOfLinesToolStripMenuItem}); this.sortTextNumberOfLinesToolStripMenuItem,
this.textCharssecToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(346, 22); this.toolStripMenuItem1.Size = new System.Drawing.Size(346, 22);
this.toolStripMenuItem1.Text = "Sort by"; this.toolStripMenuItem1.Text = "Sort by";
@ -1257,6 +1259,14 @@
this.sortTextNumberOfLinesToolStripMenuItem.Text = "Text - number of lines"; this.sortTextNumberOfLinesToolStripMenuItem.Text = "Text - number of lines";
this.sortTextNumberOfLinesToolStripMenuItem.Click += new System.EventHandler(this.SortTextNumberOfLinesToolStripMenuItemClick); this.sortTextNumberOfLinesToolStripMenuItem.Click += new System.EventHandler(this.SortTextNumberOfLinesToolStripMenuItemClick);
// //
// textCharssecToolStripMenuItem
//
this.textCharssecToolStripMenuItem.Name = "textCharssecToolStripMenuItem";
this.textCharssecToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
this.textCharssecToolStripMenuItem.Text = "Text - chars/sec";
this.textCharssecToolStripMenuItem.Visible = false;
this.textCharssecToolStripMenuItem.Click += new System.EventHandler(this.textCharssecToolStripMenuItem_Click);
//
// toolStripSeparator23 // toolStripSeparator23
// //
this.toolStripSeparator23.Name = "toolStripSeparator23"; this.toolStripSeparator23.Name = "toolStripSeparator23";
@ -1488,13 +1498,20 @@
// toolStripMenuItemAutoTranslate // toolStripMenuItemAutoTranslate
// //
this.toolStripMenuItemAutoTranslate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItemAutoTranslate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.translateByGoogleToolStripMenuItem,
this.translatepoweredByMicrosoftToolStripMenuItem, this.translatepoweredByMicrosoftToolStripMenuItem,
this.translateByGoogleToolStripMenuItem,
this.translateFromSwedishToDanishToolStripMenuItem}); this.translateFromSwedishToDanishToolStripMenuItem});
this.toolStripMenuItemAutoTranslate.Name = "toolStripMenuItemAutoTranslate"; this.toolStripMenuItemAutoTranslate.Name = "toolStripMenuItemAutoTranslate";
this.toolStripMenuItemAutoTranslate.Size = new System.Drawing.Size(97, 20); this.toolStripMenuItemAutoTranslate.Size = new System.Drawing.Size(97, 20);
this.toolStripMenuItemAutoTranslate.Text = "Auto-translate"; this.toolStripMenuItemAutoTranslate.Text = "Auto-translate";
// //
// translatepoweredByMicrosoftToolStripMenuItem
//
this.translatepoweredByMicrosoftToolStripMenuItem.Name = "translatepoweredByMicrosoftToolStripMenuItem";
this.translatepoweredByMicrosoftToolStripMenuItem.Size = new System.Drawing.Size(414, 22);
this.translatepoweredByMicrosoftToolStripMenuItem.Text = "Translate (powered by Microsoft)...";
this.translatepoweredByMicrosoftToolStripMenuItem.Click += new System.EventHandler(this.translatepoweredByMicrosoftToolStripMenuItem_Click);
//
// translateByGoogleToolStripMenuItem // translateByGoogleToolStripMenuItem
// //
this.translateByGoogleToolStripMenuItem.Name = "translateByGoogleToolStripMenuItem"; this.translateByGoogleToolStripMenuItem.Name = "translateByGoogleToolStripMenuItem";
@ -1504,13 +1521,6 @@
this.translateByGoogleToolStripMenuItem.Text = "Translate (powered by Google)..."; this.translateByGoogleToolStripMenuItem.Text = "Translate (powered by Google)...";
this.translateByGoogleToolStripMenuItem.Click += new System.EventHandler(this.TranslateByGoogleToolStripMenuItemClick); this.translateByGoogleToolStripMenuItem.Click += new System.EventHandler(this.TranslateByGoogleToolStripMenuItemClick);
// //
// translatepoweredByMicrosoftToolStripMenuItem
//
this.translatepoweredByMicrosoftToolStripMenuItem.Name = "translatepoweredByMicrosoftToolStripMenuItem";
this.translatepoweredByMicrosoftToolStripMenuItem.Size = new System.Drawing.Size(414, 22);
this.translatepoweredByMicrosoftToolStripMenuItem.Text = "Translate (powered by Microsoft)...";
this.translatepoweredByMicrosoftToolStripMenuItem.Click += new System.EventHandler(this.translatepoweredByMicrosoftToolStripMenuItem_Click);
//
// translateFromSwedishToDanishToolStripMenuItem // translateFromSwedishToDanishToolStripMenuItem
// //
this.translateFromSwedishToDanishToolStripMenuItem.Name = "translateFromSwedishToDanishToolStripMenuItem"; this.translateFromSwedishToDanishToolStripMenuItem.Name = "translateFromSwedishToDanishToolStripMenuItem";
@ -2862,7 +2872,7 @@
this.showOnlyWaveformToolStripMenuItem, this.showOnlyWaveformToolStripMenuItem,
this.showOnlySpectrogramToolStripMenuItem}); this.showOnlySpectrogramToolStripMenuItem});
this.contextMenuStripWaveForm.Name = "contextMenuStripWaveForm"; this.contextMenuStripWaveForm.Name = "contextMenuStripWaveForm";
this.contextMenuStripWaveForm.Size = new System.Drawing.Size(253, 236); this.contextMenuStripWaveForm.Size = new System.Drawing.Size(253, 214);
this.contextMenuStripWaveForm.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripWaveForm_Opening); this.contextMenuStripWaveForm.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripWaveForm_Opening);
// //
// addParagraphHereToolStripMenuItem // addParagraphHereToolStripMenuItem
@ -4005,6 +4015,7 @@
private System.Windows.Forms.ToolStripMenuItem pACScreenElectronicsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pACScreenElectronicsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCavena890; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCavena890;
private Controls.SETextBox textBoxListViewTextAlternate; private Controls.SETextBox textBoxListViewTextAlternate;
private System.Windows.Forms.ToolStripMenuItem textCharssecToolStripMenuItem;
} }
} }

View File

@ -115,7 +115,7 @@ namespace Nikse.SubtitleEdit.Forms
if (versionInfo.Length >= 3 && versionInfo[2] != "0") if (versionInfo.Length >= 3 && versionInfo[2] != "0")
_title += "." + versionInfo[2]; _title += "." + versionInfo[2];
} }
return _title + " RC2"; return _title;
} }
} }
@ -940,6 +940,7 @@ namespace Nikse.SubtitleEdit.Forms
sortTextMaxLineLengthToolStripMenuItem.Text = _language.Menu.Tools.TextSingleLineMaximumLength; sortTextMaxLineLengthToolStripMenuItem.Text = _language.Menu.Tools.TextSingleLineMaximumLength;
sortTextTotalLengthToolStripMenuItem.Text = _language.Menu.Tools.TextTotalLength; sortTextTotalLengthToolStripMenuItem.Text = _language.Menu.Tools.TextTotalLength;
sortTextNumberOfLinesToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfLines; sortTextNumberOfLinesToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfLines;
textCharssecToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfCharactersPerSeconds;
toolStripMenuItemShowOriginalInPreview.Text = _language.Menu.Tools.ShowOriginalTextInAudioAndVideoPreview; toolStripMenuItemShowOriginalInPreview.Text = _language.Menu.Tools.ShowOriginalTextInAudioAndVideoPreview;
toolStripMenuItemMakeEmptyFromCurrent.Text = _language.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle; toolStripMenuItemMakeEmptyFromCurrent.Text = _language.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle;
splitToolStripMenuItem.Text = _language.Menu.Tools.SplitSubtitle; splitToolStripMenuItem.Text = _language.Menu.Tools.SplitSubtitle;
@ -4329,14 +4330,9 @@ namespace Nikse.SubtitleEdit.Forms
private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph) private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph)
{ {
const string zeroWhiteSpace = "\u200B";
const string zeroWidthNoBreakSpace = "\uFEFF";
// string s = Utilities.RemoveHtmlTags(paragraph.Text).Replace(" ", string.Empty).Replace(Environment.NewLine, string.Empty).Replace(zeroWhiteSpace, string.Empty).Replace(zeroWidthNoBreakSpace, string.Empty);
string s = Utilities.RemoveHtmlTags(paragraph.Text).Replace(Environment.NewLine, string.Empty).Replace(zeroWhiteSpace, string.Empty).Replace(zeroWidthNoBreakSpace, string.Empty);
if (paragraph.Duration.TotalSeconds > 0) if (paragraph.Duration.TotalSeconds > 0)
{ {
double charactersPerSecond = s.Length / paragraph.Duration.TotalSeconds; double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph);
if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds + 7) if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds + 7)
charsPerSecond.ForeColor = System.Drawing.Color.Red; charsPerSecond.ForeColor = System.Drawing.Color.Red;
else if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) else if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
@ -6831,6 +6827,11 @@ namespace Nikse.SubtitleEdit.Forms
SortSubtitle(SubtitleSortCriteria.Text, (sender as ToolStripItem).Text); SortSubtitle(SubtitleSortCriteria.Text, (sender as ToolStripItem).Text);
} }
private void textCharssecToolStripMenuItem_Click(object sender, EventArgs e)
{
SortSubtitle(SubtitleSortCriteria.TextCharactersPerSeconds, (sender as ToolStripItem).Text);
}
private void ChangeLanguageToolStripMenuItemClick(object sender, EventArgs e) private void ChangeLanguageToolStripMenuItemClick(object sender, EventArgs e)
{ {
var cl = new ChooseLanguage(); var cl = new ChooseLanguage();

View File

@ -681,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAfgBCgH4AQoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo CAAAAk1TRnQBSQFMAgEBAgEAASgBCwEoAQsBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -11,5 +11,6 @@ namespace Nikse.SubtitleEdit.Logic.Enums
TextMaxLineLength, TextMaxLineLength,
TextTotalLength, TextTotalLength,
TextNumberOfLines, TextNumberOfLines,
TextCharactersPerSeconds,
} }
} }

View File

@ -428,6 +428,12 @@ namespace Nikse.SubtitleEdit.Logic
return p1.NumberOfLines.CompareTo(p2.NumberOfLines); return p1.NumberOfLines.CompareTo(p2.NumberOfLines);
}); });
break; break;
case SubtitleSortCriteria.TextCharactersPerSeconds:
_paragraphs.Sort(delegate(Paragraph p1, Paragraph p2)
{
return Utilities.GetCharactersPerSecond(p1).CompareTo(Utilities.GetCharactersPerSecond(p2));
});
break;
default: default:
break; break;
} }

View File

@ -1006,6 +1006,18 @@ namespace Nikse.SubtitleEdit.Logic
return maxLength; return maxLength;
} }
public static double GetCharactersPerSecond(Paragraph paragraph)
{
if (paragraph.Duration.TotalMilliseconds < 1)
return 999;
const string zeroWhiteSpace = "\u200B";
const string zeroWidthNoBreakSpace = "\uFEFF";
string s = Utilities.RemoveHtmlTags(paragraph.Text).Replace(Environment.NewLine, string.Empty).Replace(zeroWhiteSpace, string.Empty).Replace(zeroWidthNoBreakSpace, string.Empty);
return s.Length / paragraph.Duration.TotalSeconds;
}
public static bool IsRunningOnMono() public static bool IsRunningOnMono()
{ {
return Type.GetType("Mono.Runtime") != null; return Type.GetType("Mono.Runtime") != null;

View File

@ -937,8 +937,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Languages\bg-BG.xml"> <Content Include="Languages\bg-BG.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Languages\cs-CZ.xml"> <Content Include="Languages\cs-CZ.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>