Added Tools -> Split long lines

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@225 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-06 19:03:13 +00:00
parent 46adbf34d7
commit 4c258475ae
12 changed files with 1111 additions and 238 deletions

File diff suppressed because it is too large Load Diff

View File

@ -500,6 +500,7 @@ namespace Nikse.SubtitleEdit.Forms
toolStripMenuItemCompare.Text = _language.Menu.File.Compare;
toolStripMenuItemImportDvdSubtitles.Text = _language.Menu.File.ImportOcrFromDvd;
toolStripMenuItemSubIdx.Text = _language.Menu.File.ImportOcrVobSubSubtitle;
toolStripButtonGetFrameRate.ToolTipText = _language.GetFrameRateFromVideoFile;
toolStripMenuItemImportBluRaySup.Text = _language.Menu.File.ImportBluRaySupFile;
@ -529,6 +530,7 @@ namespace Nikse.SubtitleEdit.Forms
ChangeCasingToolStripMenuItem.Text = _language.Menu.Tools.ChangeCasing;
toolStripMenuItemChangeFramerate.Text = _language.Menu.Tools.ChangeFrameRate;
toolStripMenuItemAutoMergeShortLines.Text = _language.Menu.Tools.MergeShortLines;
toolStripMenuItemAutoSplitLongLines.Text = _language.Menu.Tools.SplitLongLines;
setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = _language.Menu.Tools.MinimumDisplayTimeBetweenParagraphs;
toolStripMenuItem1.Text = _language.Menu.Tools.SortBy;
sortNumberToolStripMenuItem.Text = _languageGeneral.Number;
@ -5479,6 +5481,33 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void toolStripMenuItemAutoSplitLongLines_Click(object sender, EventArgs e)
{
if (_subtitle != null && _subtitle.Paragraphs.Count > 1)
{
ReloadFromSourceView();
var splitLongLines = new SplitLongLines();
_formPositionsAndSizes.SetPositionAndSize(splitLongLines);
splitLongLines.Initialize(_subtitle);
if (splitLongLines.ShowDialog(this) == DialogResult.OK)
{
MakeHistoryForUndo(_language.BeforeMergeShortLines);
_subtitle = splitLongLines.SplittedSubtitle;
ShowStatus(string.Format(_language.MergedShortLinesX, splitLongLines.NumberOfSplits));
SaveSubtitleListviewIndexes();
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndexes();
_change = true;
}
_formPositionsAndSizes.SavePositionAndSize(splitLongLines);
}
else
{
MessageBox.Show(_language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void setMinimalDisplayTimeDifferenceToolStripMenuItem_Click(object sender, EventArgs e)
{
SetMinimumDisplayTimeBetweenParagraphs setMinDisplayDiff = new SetMinimumDisplayTimeBetweenParagraphs();

View File

@ -127,7 +127,7 @@
<data name="toolStripButtonFileNew.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAATQSURBVFhH7ZfbT1xVFMax+qQv6l9h0sQHffNFHwxNpTNi
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAATQSURBVFhH7ZfbT1xVFMax+qQv6l9h0sQHffNFHwxNpTNi
MRQpNLFFWiOUWnWstgajNSEaaxvrpSFyGWSEgsAAUjMdBpC0QygkJcUmarjfL8N9uA34ub+drnHP6Rxs
Ex98cJIve591zlrfb+29wzkkJPz/+y+tQFdX1xPd3d1LwWAQzc3NWoFAAC0tLdGxtbUVVFtbW4wkbj7L
XKnDmqxND9ue+UBvb+/W5uYmVldXtdbW1rC+vo6NjQ0wzjESiWBrawvb29tanDNmPsMc5kod5rI2PWwB
@ -154,7 +154,7 @@
<data name="toolStripButtonFileOpen.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAXJSURBVFhH7VRrbJMFFMVoTCT+MNE//hIU8QUIUTaZPIeK
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAXJSURBVFhH7VRrbJMFFMVoTCT+MNE//hIU8QUIUTaZPIeK
DJAg8hLEsQDyMJk8FBgExgaKIJCITBNeMWQOmBtbKXuU2Y3Sje7JYKxd27Vb1617de3WdRsQkuM939YC
VhOJ7h9NTr67e8/jfndphwx59Hl0gUcX+MsFsrOzL+v1emRmZiI9PT0E7HNO3qAcT6fT3aXx7du30dfX
FwL2OQ/w/rclVCrVZfncTUtL8/f29oLo6ekJQWCmVqu7hY/U1NR/DV6UGmaFLK7VapU38/v9ILq7u/8R
@ -185,7 +185,7 @@
<data name="toolStripButtonSave.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAWoSURBVFhH1ZZrTJdlGMZttrU+1Prq5ke/5BpbfmyWuMkH
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWoSURBVFhH1ZZrTJdlGMZttrU+1Prq5ke/5BpbfmyWuMkH
rEinsabzVIhJlIdsNSEEAjyAiggYm5wUnUghKJD/qUzloGEIcQ78y0nwDHLS0rar9/fMh4Hvf31o8KF3
u/Y+PPd9X9f1PM/9vH9mzPg/PXnX3/nop8Ylyq2Zr4wqPx2qmmvAmLmChiCRM21ryq9bosq+aDUPZKhj
8Lg6h4sMGDNX3R+jE7VLNW0GMq7MV3nvVp3rcdC9ZTKcOWIZV+f/NwNZWVnbysrKlJeXJ2c8juzsbOXk
@ -215,7 +215,7 @@
<data name="toolStripButtonSaveAs.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAX7SURBVFhHzZbZT5VXFMVv0yaN6ZC+2MTER1/aNKb6BzTy
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAX7SURBVFhHzZbZT5VXFMVv0yaN6ZC+2MTER1/aNKb6BzTy
gNaCmFZbrVeLUYLWatrEEbleECHSIkJQqhapRNSWWpnKIEFqWgEtdUBAQRQHnEdEARWE1fM78BHshzUm
mPRLVs655+y91jr72+fe6/H8n57VRa8v2FEVrDV7X1NkgUc+g1WFBkUe+Ys9itprxpLeMcqM0X1gPnCP
WHLIhQMuOOFG46lnzqgMljr1XE9PT4+6u7v1+PFjdXV1qbOzU48ePdLDhw/14MEDdXR0qL29Xd0PDa3h
@ -247,7 +247,7 @@
<data name="toolStripButtonFind.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAjfSURBVFhH1ZcJUBRXGsfNqlHxBgaYAQpEzkHCISDCOI2A
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAjfSURBVFhH1ZcJUBRXGsfNqlHxBgaYAQpEzkHCISDCOI2A
CHIpDILMMDMwDLfAcIgSdcRAeeCNRlAMwSsoKh6geAV0w2FEOcKimdVQEmU9KrgaV1QG/vteSrNbqa0I
7lG1XfWr7up53d/vfd/Xr6dHjPh/3AJPDk78n3n7bB8cw02oibKOqSqcmXhWZRd3FtbyKtjGVmNW/MUf
ZsjP7eHGnY/7r0iZx5zysJWdhK9CObiioA27Sh+gruol2muBlrp+VFc/xda9XZBIGvttok/BXFK98D+S
@ -291,7 +291,7 @@
<data name="toolStripButtonReplace.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAlySURBVFhH1VcJVJNXGo1TrTsqkLDpBAERAgjIIpsEERGE
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAlySURBVFhH1VcJVJNXGo1TrTsqkLDpBAERAgjIIpsEERGE
iEIwQEIICcEIAgKuiAYstCJqK2oBcUppqxWFoowoLi2olUWigGVAGSkDlTq2FatFhbLcvmfV2lar9vTM
OfOfc8+/5Hv/vd/9vvfyfgbj//FwWvX5+P+ZbqOY1pFGkWXh7LDSndqhJa3mshIYS4pgFl6MsYuLv2QK
j+wxkJQudVq1968XZRBxxH2GtBje8cqhdZmN2J3fhcqj93G5Aqiv7EdZ2W28ndeOsLDqfpPwI2CLShf9
@ -338,7 +338,7 @@
<data name="toolStripButtonVisualSync.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAbzSURBVFhH7VZnTFZXGCbaH036o4lN0zalKtHGWgOUJVAB
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAbzSURBVFhH7VZnTFZXGCbaH036o4lN0zalKtHGWgOUJVAB
B8pSFBQ3onGgGAei4IqYiorIUEDcmoAVahFHVHAwBAoOZEitCQZQxIkIKgoi4+l53nrvh9QfbZMm/dGT
PHnPuefe8z7vvMfI6P/xvwf+Cx7IyMiwXL9+fWfJ1KkoXboUpUuW4LfAQPySlobci3lIzPoZU0pXIbBs
C4J+DccPJfHIz8tHQVYeAmOKEBBRhoAtpQgIL0PCj5eQn5+L48ePw83NDfPnzxcsWrQIp0+fRk5ODs6e
@ -374,7 +374,7 @@
<data name="toolStripButtonSpellCheck.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAASkSURBVFhH7ZVZTGNlGIYZl2j0zisTY8yEC+ON8WKiN0a8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAASkSURBVFhH7ZVZTGNlGIYZl2j0zisTY8yEC+ON8WKiN0a8
MWZCmdJSli7QhVJogQIFSlvaHijQUhhACsMiHYrAMGyltGUpW+kM67AMFMIyMDpxJo7B6IWXxujrfxAS
gvFiOnQujCd5859/Od/3vN932hMR8f/1X6xA7yLD5AqmYGiDi67luIcv3ONQUIrNox7s/+KCZ1uJ3jUe
bt1lNr4QkL5V8SPvVgH2fh7C4pNa7Bw5ce9xM/pXZOi8x0FYIRyOqNcHVzOI+y4s/XAD098ZMfnQgLnH
@ -400,7 +400,7 @@
<data name="toolStripButtonSettings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAVrSURBVFhHrZdHSG1XFIZfyoMUyCQho2QeyVAiJCQhgwTC
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAVrSURBVFhHrZdHSG1XFIZfyoMUyCQho2QeyVAiJCQhgwTC
e5Nk4FicCI4cGBELiCKCPU/sFTtib2DvvXcRwV6wYI332ZKd9W3uvjka9SooLM46a/3/v9au9/jixRP/
Ojs7v+zt7a3p6+u76u/vVxg+MXJPlHs6vL29/W8M5uXlpcLwrfGnq97DaG5u/qmpqSlwZGTkpYF0dXWp
6+trdXx8rA4PD7XhEyNncHBaWloC0XhyQ5Cl8DmCMrILmVol769qamo+Imaz2dT+/r46ODjQhk+MHJjW
@ -429,7 +429,7 @@
<data name="toolStripButtonHelp.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAeXSURBVFhH7Vd7UNNXFkbbnV3bmd3pdnZb21pnO90+wgo2
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAeXSURBVFhH7Vd7UNNXFkbbnV3bmd3pdnZb21pnO90+wgo2
Glh8wFZBjKBoeUhACBApAhECGkQsRCWUh2J4ykMFLSooImpBQEWgBUXF6joOUwfqtC6rq1ZnRSUJQb49
50fCrA8e3b83M9/kzr3f951zzz3390usrP7/GW8FgAneyW0yWWZbk0jTMrBAU9/nnHgSDB7zHK8xx4q4
47Udm8eBtQ05flsaEZHXZNTV/oDd3/Sg/vIdXLzeK4DHPJdFa9EF7QZZ+mks0TZs12g0E8cOMApDmlI7
@ -468,7 +468,7 @@
<data name="toolStripButtonToogleWaveForm.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAf2SURBVFhH7Zd5TNTpHcaHpNkeAko8uQRUBBZnuAfm4JiB
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAf2SURBVFhH7Zd5TNTpHcaHpNkeAko8uQRUBBZnuAfm4JiB
uZj7PhgYYEQRr26NrXWzbuqmaWI2mvVIjGt3G++w1qibrPEo3uKiiGgRXY1aNfG+Tf9oa55+vy8Opdvd
/+r2n5I8ee/n88z7vr/5DRLJ///+1zuwb9++TNLTPXv2YMuWLdi8ebMQ17du3Sq0bdu24XLHjh3Yvn07
uBypWN/IubH13/ZlFjOZLTlw4MAX/f39/3j27BkePnwo9OjRI1E+fvwYT548wdOnT8HjrOfPn+PFixd4
@ -508,7 +508,7 @@
<data name="toolStripButtonToogleVideo.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAWRSURBVFhH7ZZLSFZbFMcDkS5paeaj8pGa7zQr7W1p+X6/
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWRSURBVFhH7ZZLSFZbFMcDkS5paeaj8pGa7zQr7W1p+X6/
UjPNhAyyJCGC4BKCBE3KwKJBCQ1qlDhQooGRYKZmopaTBkJpNImoQQgWaK7Ob133ud+X93YnCnfQgT9n
n73WXv+111p77bNixe/ndwT+DxFYuXLl2K5du2T37t2SlJQkBw8elAMHDsj+/ftl1apVsnPnTkG+d+9e
Gzt27JDw8HD93rNnjwK9hIQECQoKkm3btsm+ffvUBraMjouLi9qy9j1m7z0sLEw+f/6siocPH9ZFx48f
@ -538,7 +538,7 @@
<data name="toolStripButtonGetFrameRate.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI
ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9
HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN
rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K
@ -583,7 +583,7 @@
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAHUSURBVDhPrZLfS1NhHMb9f6Sb6A8IvQvCguqiGyHTMuiX
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHUSURBVDhPrZLfS1NhHMb9f6Sb6A8IvQvCguqiGyHTMuiX
zTG1YDHHGMcp81gTzyzdnFtsMVsaYiC5tWOsRVirXBfijTaE1tJNKrFPvi8ow3MUhL7w3r3P53m+D9+a
mv855com6UyW0UgMV+8ATo+X4bEwSf0NG+Uyh3oV1tYIReNEE1PkPi+yvr4h34fcpx1gFP9IkG+FgjlE
fBTi2VSa/fN76y+lyjaRiWl8ml9CDUlEbOF8kHiluMXX1T8o6jDJVMoIEBFF7OrZdd4Vv1/6RfCZzqCm
@ -597,7 +597,7 @@
<data name="toolStripButtonWaveFormZoomIn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAHhSURBVDhPrZPfS1NxGMb9f6Kb6A8Iu4lALKgughA0TYVl
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHhSURBVDhPrZPfS1NxGMb9f6Kb6A8Iu4lALKgughA0TYVl
2RKxgsUcY5z9YMxYOVfq3GZuMrUmskTC3NFWEbNV0sUW0bxrHldGKvWp90DDPGsQ9ML38vk8z/vwfuvq
/udom2XSmeeMjMexuwewubwEx6IsqitsaBo1vT58LBKOJYjNJMm9WaNc/qy/1dzrX8AYQ8Mh8oX31SHi
LOKFJ2n2z/buD7St74xPzeEPDPGpVDJCJLY4750+dxR5Ii6Wdnm3voPiC5KanzcCJKLE3g+46hitiF/m
@ -611,7 +611,7 @@
<data name="toolStripButtonWaveFormPause.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAACvSURBVDhPY2AYBRgh0Lv57/+uDb/+Z09++Akkic4nGGQg
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACvSURBVDhPY2AYBRgh0Lv57/+uDb/+Z09++Akkic4nGGQg
zVcf/vmvG7rqP0gxOp+gAW1rv/2/9fT3f1W/RWAD0PkEDWhc8fn/5Ye//8u5zQIbgM4naEDt4vf/T1z/
/V/MbhLYAHQ+QQMq5r36v/vCz//8Zt1gA9D5BA0omf38//qTP/9zGrSCDUDnEzSgYPrj/wv2fP7PqtMI
NgCdT9AAUPyz6TbBDUDnEzRg6CkAAJHglk8ZsGXnAAAAAElFTkSuQmCC
@ -620,7 +620,7 @@
<data name="toolStripButtonWaveFormPlay.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAD+SURBVDhPY2DAAkJX/WfGJk60WErHY5n6+v9MRGtAV1g4
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAD+SURBVDhPY2DAAkJX/WfGJk60WErHY5n6+v9MRGtAV1g4
6/n/xGkflMg2JHfms/8J3ff+x096rUGWdzKmPP0/b//v/0ENN18ndD61JdmQhJ4n/2fv+/W/c+vf/26l
l/8n9j6yJ8mQyK5H/6ds+/W/ZOnf/wnT//63yT1LmiGBzQ//t659D9ZsXPLlv3T0tf/Gkcv+OxScjifK
JR5V9/+XzH0H16zo0vNfxntlINHRal96939gyzOwzSDN0t4rvIjWDFJokXfnv03BFbBmSZ9VNiRpBik2
@ -631,7 +631,7 @@
<data name="toolStripButtonLockCenter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAJeSURBVDhPnZJbT1NBFIX5Rz75H7wkxsQYE2OMgonGYDQG
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJeSURBVDhPnZJbT1NBFIX5Rz75H7wkxsQYE2OMgonGYDQG
44XUVDQEJRWjhra0PfYCtLQUaPGWUrCgbXngxRgffIDaUEpAbKG3c3raM8s9c2o59dFJVuZhz3yz15rd
5YuuwhdJwxsl0e6JpHDlRV6oZ0RX9/MtUh7S9ApcQstwhhJwBj+hyxtZxb+LX4p/0xBdY7DFNZiDCo50
r4Ix1qGjx3t0gLFQqzNcphfn1zQEkgwv3zdg8ncC6g2GL1/zaAHSHYCywnDJksNUSoO0xGB528CDcVl0

309
src/Forms/SplitLongLines.Designer.cs generated Normal file
View File

@ -0,0 +1,309 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class SplitLongLines
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBoxLinesFound = new System.Windows.Forms.GroupBox();
this.listViewFixes = new System.Windows.Forms.ListView();
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.numericUpDownSingleLineMaxCharacters = new System.Windows.Forms.NumericUpDown();
this.labelLineMaxLength = new System.Windows.Forms.Label();
this.labelSingleLineMaxLength = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.numericUpDownLineMaxCharacters = new System.Windows.Forms.NumericUpDown();
this.labelMaxSingleLineLengthIs = new System.Windows.Forms.Label();
this.labelMaxLineLengthIs = new System.Windows.Forms.Label();
this.comboBoxLineContinuationBegin = new System.Windows.Forms.ComboBox();
this.labelLineContinuationBeginEnd = new System.Windows.Forms.Label();
this.comboBoxLineContinuationEnd = new System.Windows.Forms.ComboBox();
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.groupBoxLinesFound.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).BeginInit();
this.SuspendLayout();
//
// groupBoxLinesFound
//
this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxLinesFound.Controls.Add(this.listViewFixes);
this.groupBoxLinesFound.Location = new System.Drawing.Point(6, 64);
this.groupBoxLinesFound.Name = "groupBoxLinesFound";
this.groupBoxLinesFound.Size = new System.Drawing.Size(756, 200);
this.groupBoxLinesFound.TabIndex = 4;
this.groupBoxLinesFound.TabStop = false;
this.groupBoxLinesFound.Text = "Lines that will be splittet";
//
// listViewFixes
//
this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewFixes.CheckBoxes = true;
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
this.columnHeader5,
this.columnHeader7});
this.listViewFixes.FullRowSelect = true;
this.listViewFixes.Location = new System.Drawing.Point(6, 23);
this.listViewFixes.Name = "listViewFixes";
this.listViewFixes.Size = new System.Drawing.Size(744, 171);
this.listViewFixes.TabIndex = 0;
this.listViewFixes.UseCompatibleStateImageBehavior = false;
this.listViewFixes.View = System.Windows.Forms.View.Details;
this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged);
//
// columnHeader4
//
this.columnHeader4.Text = "Apply";
this.columnHeader4.Width = 45;
//
// columnHeader5
//
this.columnHeader5.Text = "Line#";
this.columnHeader5.Width = 122;
//
// columnHeader7
//
this.columnHeader7.Text = "New text";
this.columnHeader7.Width = 500;
//
// numericUpDownSingleLineMaxCharacters
//
this.numericUpDownSingleLineMaxCharacters.Location = new System.Drawing.Point(250, 35);
this.numericUpDownSingleLineMaxCharacters.Maximum = new decimal(new int[] {
200,
0,
0,
0});
this.numericUpDownSingleLineMaxCharacters.Minimum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDownSingleLineMaxCharacters.Name = "numericUpDownSingleLineMaxCharacters";
this.numericUpDownSingleLineMaxCharacters.Size = new System.Drawing.Size(64, 20);
this.numericUpDownSingleLineMaxCharacters.TabIndex = 0;
this.numericUpDownSingleLineMaxCharacters.Value = new decimal(new int[] {
50,
0,
0,
0});
this.numericUpDownSingleLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged);
//
// labelLineMaxLength
//
this.labelLineMaxLength.AutoSize = true;
this.labelLineMaxLength.Location = new System.Drawing.Point(428, 18);
this.labelLineMaxLength.Name = "labelLineMaxLength";
this.labelLineMaxLength.Size = new System.Drawing.Size(105, 13);
this.labelLineMaxLength.TabIndex = 43;
this.labelLineMaxLength.Text = "Line maximum length";
//
// labelSingleLineMaxLength
//
this.labelSingleLineMaxLength.AutoSize = true;
this.labelSingleLineMaxLength.Location = new System.Drawing.Point(247, 18);
this.labelSingleLineMaxLength.Name = "labelSingleLineMaxLength";
this.labelSingleLineMaxLength.Size = new System.Drawing.Size(133, 13);
this.labelSingleLineMaxLength.TabIndex = 42;
this.labelSingleLineMaxLength.Text = "Single line maximum length";
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(600, 577);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 6;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(681, 577);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// numericUpDownLineMaxCharacters
//
this.numericUpDownLineMaxCharacters.Location = new System.Drawing.Point(431, 35);
this.numericUpDownLineMaxCharacters.Maximum = new decimal(new int[] {
200,
0,
0,
0});
this.numericUpDownLineMaxCharacters.Minimum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDownLineMaxCharacters.Name = "numericUpDownLineMaxCharacters";
this.numericUpDownLineMaxCharacters.Size = new System.Drawing.Size(64, 20);
this.numericUpDownLineMaxCharacters.TabIndex = 1;
this.numericUpDownLineMaxCharacters.Value = new decimal(new int[] {
90,
0,
0,
0});
this.numericUpDownLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged);
//
// labelMaxSingleLineLengthIs
//
this.labelMaxSingleLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelMaxSingleLineLengthIs.AutoSize = true;
this.labelMaxSingleLineLengthIs.Location = new System.Drawing.Point(3, 577);
this.labelMaxSingleLineLengthIs.Name = "labelMaxSingleLineLengthIs";
this.labelMaxSingleLineLengthIs.Size = new System.Drawing.Size(133, 13);
this.labelMaxSingleLineLengthIs.TabIndex = 45;
this.labelMaxSingleLineLengthIs.Text = "Single line maximum length";
this.labelMaxSingleLineLengthIs.Click += new System.EventHandler(this.labelMaxSingleLineLengthIs_Click);
//
// labelMaxLineLengthIs
//
this.labelMaxLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelMaxLineLengthIs.AutoSize = true;
this.labelMaxLineLengthIs.Location = new System.Drawing.Point(3, 592);
this.labelMaxLineLengthIs.Name = "labelMaxLineLengthIs";
this.labelMaxLineLengthIs.Size = new System.Drawing.Size(83, 13);
this.labelMaxLineLengthIs.TabIndex = 46;
this.labelMaxLineLengthIs.Text = "Maximum length";
this.labelMaxLineLengthIs.Click += new System.EventHandler(this.labelMaxLineLengthIs_Click);
//
// comboBoxLineContinuationBegin
//
this.comboBoxLineContinuationBegin.FormattingEnabled = true;
this.comboBoxLineContinuationBegin.Items.AddRange(new object[] {
"- ",
"..."});
this.comboBoxLineContinuationBegin.Location = new System.Drawing.Point(570, 33);
this.comboBoxLineContinuationBegin.Name = "comboBoxLineContinuationBegin";
this.comboBoxLineContinuationBegin.Size = new System.Drawing.Size(80, 21);
this.comboBoxLineContinuationBegin.TabIndex = 2;
//
// labelLineContinuationBeginEnd
//
this.labelLineContinuationBeginEnd.AutoSize = true;
this.labelLineContinuationBeginEnd.Location = new System.Drawing.Point(567, 17);
this.labelLineContinuationBeginEnd.Name = "labelLineContinuationBeginEnd";
this.labelLineContinuationBeginEnd.Size = new System.Drawing.Size(173, 13);
this.labelLineContinuationBeginEnd.TabIndex = 48;
this.labelLineContinuationBeginEnd.Text = "Line continuation begin/end strings";
//
// comboBoxLineContinuationEnd
//
this.comboBoxLineContinuationEnd.FormattingEnabled = true;
this.comboBoxLineContinuationEnd.Items.AddRange(new object[] {
" -",
"..."});
this.comboBoxLineContinuationEnd.Location = new System.Drawing.Point(656, 33);
this.comboBoxLineContinuationEnd.Name = "comboBoxLineContinuationEnd";
this.comboBoxLineContinuationEnd.Size = new System.Drawing.Size(80, 21);
this.comboBoxLineContinuationEnd.TabIndex = 3;
//
// SubtitleListview1
//
this.SubtitleListview1.AllowDrop = true;
this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.SubtitleListview1.FirstVisibleIndex = -1;
this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SubtitleListview1.FullRowSelect = true;
this.SubtitleListview1.GridLines = true;
this.SubtitleListview1.HideSelection = false;
this.SubtitleListview1.Location = new System.Drawing.Point(4, 270);
this.SubtitleListview1.Name = "SubtitleListview1";
this.SubtitleListview1.Size = new System.Drawing.Size(758, 301);
this.SubtitleListview1.TabIndex = 5;
this.SubtitleListview1.UseCompatibleStateImageBehavior = false;
this.SubtitleListview1.View = System.Windows.Forms.View.Details;
//
// SplitLongLines
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(774, 614);
this.Controls.Add(this.comboBoxLineContinuationEnd);
this.Controls.Add(this.labelLineContinuationBeginEnd);
this.Controls.Add(this.comboBoxLineContinuationBegin);
this.Controls.Add(this.labelMaxLineLengthIs);
this.Controls.Add(this.labelMaxSingleLineLengthIs);
this.Controls.Add(this.numericUpDownLineMaxCharacters);
this.Controls.Add(this.groupBoxLinesFound);
this.Controls.Add(this.numericUpDownSingleLineMaxCharacters);
this.Controls.Add(this.labelLineMaxLength);
this.Controls.Add(this.labelSingleLineMaxLength);
this.Controls.Add(this.SubtitleListview1);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Name = "SplitLongLines";
this.ShowIcon = false;
this.Text = "Split long lines";
this.Shown += new System.EventHandler(this.SplitLongLines_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SplitLongLines_KeyDown);
this.groupBoxLinesFound.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox groupBoxLinesFound;
private System.Windows.Forms.ListView listViewFixes;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.NumericUpDown numericUpDownSingleLineMaxCharacters;
private System.Windows.Forms.Label labelLineMaxLength;
private System.Windows.Forms.Label labelSingleLineMaxLength;
private Controls.SubtitleListView SubtitleListview1;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.NumericUpDown numericUpDownLineMaxCharacters;
private System.Windows.Forms.Label labelMaxSingleLineLengthIs;
private System.Windows.Forms.Label labelMaxLineLengthIs;
private System.Windows.Forms.ComboBox comboBoxLineContinuationBegin;
private System.Windows.Forms.Label labelLineContinuationBeginEnd;
private System.Windows.Forms.ComboBox comboBoxLineContinuationEnd;
}
}

359
src/Forms/SplitLongLines.cs Normal file
View File

@ -0,0 +1,359 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class SplitLongLines : Form
{
Subtitle _subtitle;
private Subtitle _splittedSubtitle;
public int NumberOfSplits { get; private set; }
public Subtitle SplittedSubtitle
{
get { return _splittedSubtitle; }
}
public SplitLongLines()
{
InitializeComponent();
FixLargeFonts();
}
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
if (textSize.Height > buttonOK.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
Utilities.SetButtonHeight(this, newButtonHeight, 1);
}
}
private void SplitLongLines_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
DialogResult = DialogResult.Cancel;
}
public void Initialize(Subtitle subtitle)
{
if (subtitle.Paragraphs.Count > 0)
subtitle.Renumber(subtitle.Paragraphs[0].Number);
Text = Configuration.Settings.Language.SplitLongLines.Title;
labelSingleLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.SingleLineMaximumLength;
labelLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.LineMaximumLength;
labelLineContinuationBeginEnd.Text = Configuration.Settings.Language.SplitLongLines.LineContinuationBeginEndStrings;
listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply;
listViewFixes.Columns[1].Text = Configuration.Settings.Language.MergedShortLines.LineNumber;
listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText;
buttonOK.Text = Configuration.Settings.Language.General.OK;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
SubtitleListview1.InitializeTimeStampColumWidths(this);
NumberOfSplits = 0;
numericUpDownSingleLineMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength;
_subtitle = subtitle;
}
private void AddToListView(Paragraph p, string lineNumbers, string newText)
{
var item = new ListViewItem(string.Empty) { Tag = p, Checked = true };
var subItem = new ListViewItem.ListViewSubItem(item, lineNumbers);
item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem(item, newText.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
item.SubItems.Add(subItem);
listViewFixes.Items.Add(item);
}
private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e)
{
GeneratePreview(false);
}
private void GeneratePreview(bool clearFixes)
{
if (_subtitle == null)
return;
var splittedIndexes = new List<int>();
var autoBreakedIndexes = new List<int>();
NumberOfSplits = 0;
SubtitleListview1.Items.Clear();
SubtitleListview1.BeginUpdate();
int count;
_splittedSubtitle = SplitLongLinesInSubtitle(_subtitle, splittedIndexes, autoBreakedIndexes, out count, (int)numericUpDownLineMaxCharacters.Value, (int)numericUpDownSingleLineMaxCharacters.Value, clearFixes);
NumberOfSplits = count;
SubtitleListview1.Fill(_splittedSubtitle);
foreach (var index in splittedIndexes)
SubtitleListview1.SetBackgroundColor(index, Color.Green);
foreach (var index in autoBreakedIndexes)
SubtitleListview1.SetBackgroundColor(index, Color.LightGreen);
SubtitleListview1.EndUpdate();
groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.SplitLongLines.NumberOfSplits, NumberOfSplits);
UpdateLongestLinesInfo(_splittedSubtitle);
}
private void UpdateLongestLinesInfo(Subtitle subtitle)
{
int maxLength = -1;
int maxLengthIndex = -1;
int singleLineMaxLength = -1;
int singleLineMaxLengthIndex = -1;
int i = 0;
foreach (Paragraph p in subtitle.Paragraphs)
{
string s = Utilities.RemoveHtmlTags(p.Text);
if (s.Length > maxLength)
{
maxLength = s.Length;
maxLengthIndex = i;
}
string[] arr = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
foreach (string line in arr)
{
if (line.Length > singleLineMaxLengthIndex)
{
singleLineMaxLength = line.Length;
singleLineMaxLengthIndex = i;
}
}
i++;
}
labelMaxSingleLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestSingleLineIsXAtY, singleLineMaxLength, singleLineMaxLengthIndex + 1);
labelMaxSingleLineLengthIs.Tag = singleLineMaxLengthIndex.ToString();
labelMaxLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestLineIsXAtY, maxLength, maxLengthIndex + 1);
labelMaxLineLengthIs.Tag = maxLengthIndex.ToString();
}
private bool IsFixAllowed(Paragraph p)
{
foreach (ListViewItem item in listViewFixes.Items)
{
if ((item.Tag as Paragraph) == p)
return item.Checked;
}
return true;
}
public Subtitle SplitLongLinesInSubtitle(Subtitle subtitle, List<int> splittedIndexes, List<int> autoBreakedIndexes, out int numberOfSplits, int totalLineMaxCharacters, int singleLineMaxCharacters, bool clearFixes)
{
listViewFixes.ItemChecked -= listViewFixes_ItemChecked;
if (clearFixes)
listViewFixes.Items.Clear();
numberOfSplits = 0;
Subtitle splittedSubtitle = new Subtitle();
Paragraph p = null;
StringBuilder lineNumbers = new StringBuilder();
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
bool added = false;
p = subtitle.GetParagraphOrDefault(i);
if (p != null && p.Text != null)
{
string oldText = Utilities.RemoveHtmlTags(p.Text);
if (QualifiesForSplit(p.Text, singleLineMaxCharacters, totalLineMaxCharacters) && IsFixAllowed(p))
{
if (!QualifiesForSplit(Utilities.AutoBreakLine(p.Text), singleLineMaxCharacters, totalLineMaxCharacters))
{
Paragraph newParagraph = new Paragraph(p);
newParagraph.Text = Utilities.AutoBreakLine(p.Text);
if (clearFixes)
AddToListView(p, (splittedSubtitle.Paragraphs.Count + 1).ToString(), oldText);
autoBreakedIndexes.Add(splittedSubtitle.Paragraphs.Count);
splittedSubtitle.Paragraphs.Add(newParagraph);
added = true;
numberOfSplits++;
}
else
{
string text = Utilities.AutoBreakLine(p.Text);
if (text.Contains(Environment.NewLine))
{
string[] arr = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 2)
{
double duration = p.Duration.TotalMilliseconds / 2.0;
Paragraph newParagraph1 = new Paragraph(p);
Paragraph newParagraph2 = new Paragraph(p);
newParagraph1.Text = Utilities.AutoBreakLine(arr[0]);
newParagraph1.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration;
newParagraph2.Text = Utilities.AutoBreakLine(arr[1]);
newParagraph2.StartTime.TotalMilliseconds = newParagraph1.EndTime.TotalMilliseconds + 1;
if (clearFixes)
AddToListView(p, (splittedSubtitle.Paragraphs.Count + 1).ToString(), oldText);
splittedIndexes.Add(splittedSubtitle.Paragraphs.Count);
splittedIndexes.Add(splittedSubtitle.Paragraphs.Count + 1);
string p1 = Utilities.RemoveHtmlTags(newParagraph1.Text);
bool p1Ends = false;
if (p1.EndsWith(".") || p1.EndsWith("!") || p1.EndsWith("?") || p1.EndsWith(":") || p1.EndsWith(")") || p1.EndsWith("]") || p1.EndsWith("♪"))
p1Ends = true;
if (!p1Ends)
{
string post = string.Empty;
if (newParagraph1.Text.EndsWith("</i>"))
{
post = "</i>";
newParagraph1.Text = newParagraph1.Text.Remove(newParagraph1.Text.Length - post.Length);
}
newParagraph1.Text += comboBoxLineContinuationEnd.Text.TrimEnd() + post;
string pre = string.Empty;
if (newParagraph2.Text.StartsWith("<i>"))
{
pre = "<i>";
newParagraph2.Text = newParagraph2.Text.Remove(0, pre.Length);
}
newParagraph2.Text = pre + comboBoxLineContinuationBegin.Text + newParagraph2.Text;
}
if (newParagraph1.Text.IndexOf("<i>") >= 0 && newParagraph1.Text.IndexOf("<i>") < 10 & newParagraph1.Text.IndexOf("</i>") < 0 &&
newParagraph2.Text.Contains("</i>") && newParagraph2.Text.IndexOf("<i>") < 0)
{
newParagraph1.Text += "</i>";
newParagraph2.Text = "<i>" + newParagraph2.Text;
}
splittedSubtitle.Paragraphs.Add(newParagraph1);
splittedSubtitle.Paragraphs.Add(newParagraph2);
added = true;
numberOfSplits++;
}
}
}
}
}
if (!added)
splittedSubtitle.Paragraphs.Add(new Paragraph(p));
}
listViewFixes.ItemChecked += listViewFixes_ItemChecked;
splittedSubtitle.Renumber(1);
return splittedSubtitle;
}
private static string GetEndTag(string text)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
text = text.Trim();
if (!text.EndsWith(">"))
return string.Empty;
string endTag = string.Empty;
int start = text.LastIndexOf("</");
if (start > 0 && start >= text.Length - 8)
{
endTag = text.Substring(start);
}
return endTag;
}
private static string GetStartTag(string text)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
text = text.Trim();
if (!text.StartsWith("<"))
return string.Empty;
string startTag = string.Empty;
int end = text.IndexOf(">");
if (end > 0 && end < 25)
{
startTag = text.Substring(0, end + 1);
}
return startTag;
}
private static bool QualifiesForSplit(string text, int singleLineMaxCharacters, int totalLineMaxCharacters)
{
string s = Utilities.RemoveHtmlTags(text.Trim());
if (s.Length > totalLineMaxCharacters)
return true;
string[] arr = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
foreach (string line in arr)
{
if (line.Length > singleLineMaxCharacters)
return true;
}
return false;
}
private void NumericUpDownMaxCharactersValueChanged(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
GeneratePreview(true);
Cursor = Cursors.Default;
}
private void NumericUpDownMaxMillisecondsBetweenLinesValueChanged(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
GeneratePreview(true);
Cursor = Cursors.Default;
}
private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewFixes.SelectedIndices.Count > 0)
{
int index = listViewFixes.SelectedIndices[0];
ListViewItem item = listViewFixes.Items[index];
index = int.Parse(item.SubItems[1].Text);
SubtitleListview1.EnsureVisible(index);
}
}
private void SplitLongLines_Shown(object sender, EventArgs e)
{
GeneratePreview(true);
listViewFixes.Focus();
if (listViewFixes.Items.Count > 0)
listViewFixes.Items[0].Selected = true;
}
private void buttonOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void labelMaxSingleLineLengthIs_Click(object sender, EventArgs e)
{
int index = int.Parse(labelMaxSingleLineLengthIs.Tag.ToString());
SubtitleListview1.SelectIndexAndEnsureVisible(index);
}
private void labelMaxLineLengthIs_Click(object sender, EventArgs e)
{
int index = int.Parse(labelMaxLineLengthIs.Tag.ToString());
SubtitleListview1.SelectIndexAndEnsureVisible(index);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -50,6 +50,7 @@ namespace Nikse.SubtitleEdit.Logic
public LanguageStructure.ShowEarlierLater ShowEarlierLater;
public LanguageStructure.ShowHistory ShowHistory;
public LanguageStructure.SpellCheck SpellCheck;
public LanguageStructure.SplitLongLines SplitLongLines;
public LanguageStructure.SplitSubtitle SplitSubtitle;
public LanguageStructure.StartNumberingFrom StartNumberingFrom;
public LanguageStructure.PointSync PointSync;
@ -636,6 +637,7 @@ namespace Nikse.SubtitleEdit.Logic
UnicodeMusicSymbolsAnsiWarning = "Subtitle contains unicode music notes. Saving using ANSI file encoding will lose these. Continue with saving?",
NegativeTimeWarning = "Subtitle contains negative time codes. Continue with saving?",
BeforeMergeShortLines = "Before merge short lines",
BeforeSplitLongLines = "Before split long lines",
MergedShortLinesX = "Number of lines merged: {0}",
BeforeSetMinimumDisplayTimeBetweenParagraphs = "Before set minimum display time between paragraphs",
XMinimumDisplayTimeBetweenParagraphsChanged = "Number of lines with minimum display time between paragraphs changed: {0}",
@ -707,6 +709,7 @@ namespace Nikse.SubtitleEdit.Logic
ChangeCasing = "Change casing...",
ChangeFrameRate = "Change frame rate...",
MergeShortLines = "Merge short lines...",
SplitLongLines = "Split long lines...",
MinimumDisplayTimeBetweenParagraphs = "Minimum display time between paragraphs...",
SortBy = "Sort by",
TextAlphabetically = "Text - alphabetically",
@ -1157,6 +1160,17 @@ can edit in same subtitle file (collaboration)",
SpellCheckAborted = "Spell check aborted",
};
SplitLongLines = new LanguageStructure.SplitLongLines
{
Title = "Split long lines",
SingleLineMaximumLength = "Single line maximum length",
LineMaximumLength = "Line maximum length",
LineContinuationBeginEndStrings = "Line continuation begin/end strings",
NumberOfSplits = "Number of splits: {0}",
LongestSingleLineIsXAtY = "Longest single line length is {0} at line {1}",
LongestLineIsXAtY = "Longest total line length is {0} at line {1}",
};
SplitSubtitle = new LanguageStructure.SplitSubtitle
{
Title = "Split subtitle",

View File

@ -565,6 +565,7 @@
public string UnicodeMusicSymbolsAnsiWarning { get; set; }
public string NegativeTimeWarning { get; set; }
public string BeforeMergeShortLines { get; set; }
public string BeforeSplitLongLines { get; set; }
public string MergedShortLinesX { get; set; }
public string BeforeSetMinimumDisplayTimeBetweenParagraphs { get; set; }
public string XMinimumDisplayTimeBetweenParagraphsChanged { get; set; }
@ -634,6 +635,7 @@
public string ChangeCasing { get; set; }
public string ChangeFrameRate { get; set; }
public string MergeShortLines { get; set; }
public string SplitLongLines { get; set; }
public string MinimumDisplayTimeBetweenParagraphs { get; set; }
public string SortBy { get; set; }
public string TextAlphabetically { get; set; }
@ -840,7 +842,6 @@
public string MaximumMillisecondsBetween { get; set; }
public string NumberOfMergesX { get; set; }
public string LineNumber { get; set; }
public string MergedText { get; set; }
}
@ -1094,6 +1095,17 @@
public string SpellCheckAborted { get; set; }
}
public class SplitLongLines
{
public string Title { get; set; }
public string SingleLineMaximumLength { get; set; }
public string LineMaximumLength { get; set; }
public string LineContinuationBeginEndStrings { get; set; }
public string NumberOfSplits { get; set; }
public string LongestSingleLineIsXAtY { get; set; }
public string LongestLineIsXAtY { get; set; }
}
public class SplitSubtitle
{
public string Title { get; set; }

View File

@ -271,7 +271,7 @@ namespace Nikse.SubtitleEdit.Logic
public static string AutoBreakLine(string text, int mininumLength)
{
if (text.Length < 5)
if (text.Length < mininumLength)
return text;
string temp = RemoveHtmlTags(text);

View File

@ -408,6 +408,7 @@
<ChangeCasing>Skift store/små bogstaver...</ChangeCasing>
<ChangeFrameRate>Skift frame rate...</ChangeFrameRate>
<MergeShortLines>Flet korte linjer...</MergeShortLines>
<SplitLongLines>Split lange linjer...</SplitLongLines>
<MinimumDisplayTimeBetweenParagraphs>Minimum visningstid mellem tekster...</MinimumDisplayTimeBetweenParagraphs>
<SortBy>Sorter efter</SortBy>
<TextAlphabetically>Tekst - alfabetisk</TextAlphabetically>
@ -718,6 +719,7 @@ Fortsæt?</SubtitleAppendPrompt>
<UnicodeMusicSymbolsAnsiWarning>Undertekst indeholder unicode tegn. Gemmes i ANSI filformat vil disse gå tabt. Fortsæt?</UnicodeMusicSymbolsAnsiWarning>
<NegativeTimeWarning>Undertekst indeholder negative tidskoder. Gem?</NegativeTimeWarning>
<BeforeMergeShortLines>Før fusionere korte linjer</BeforeMergeShortLines>
<BeforeSplitLongLines>Før split lange linjer</BeforeSplitLongLines>
<MergedShortLinesX>Antal linjer fusionerede: {0}</MergedShortLinesX>
<BeforeSetMinimumDisplayTimeBetweenParagraphs>Før ret minimum visningstid mellem tekster</BeforeSetMinimumDisplayTimeBetweenParagraphs>
<XMinimumDisplayTimeBetweenParagraphsChanged>Antallet af linjer med minimum visningstid mellem tekster ændret: {0}</XMinimumDisplayTimeBetweenParagraphsChanged>
@ -982,6 +984,15 @@ Fortsæt?</SubtitleAppendPrompt>
<SpellCheckCompleted>Stavekontrol færdig</SpellCheckCompleted>
<SpellCheckAborted>Stavekontrol afbrudt</SpellCheckAborted>
</SpellCheck>
<SplitLongLines>
<Title>Split lange linjer</Title>
<SingleLineMaximumLength>Enkelt linje maksimale længde</SingleLineMaximumLength>
<LineMaximumLength>Line maksimale længde</LineMaximumLength>
<LineContinuationBeginEndStrings>Line fortsæt begynd/slut tekst</LineContinuationBeginEndStrings>
<NumberOfSplits>Antal splits: {0}</NumberOfSplits>
<LongestSingleLineIsXAtY>Længste enkelt linje længde er {0} på linie {1}</LongestSingleLineIsXAtY>
<LongestLineIsXAtY>Længste samlet linjelængde er {0} på linie {1}</LongestLineIsXAtY>
</SplitLongLines>
<SplitSubtitle>
<Title>Split undertekst</Title>
<Description1>Indtast længden af første del af video-eller browse</Description1>

Binary file not shown.

View File

@ -343,6 +343,12 @@
<Compile Include="Forms\SpellCheck.Designer.cs">
<DependentUpon>SpellCheck.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SplitLongLines.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SplitLongLines.Designer.cs">
<DependentUpon>SplitLongLines.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SplitSubtitle.cs">
<SubType>Form</SubType>
</Compile>
@ -702,6 +708,9 @@
<DependentUpon>SpellCheck.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SplitLongLines.resx">
<DependentUpon>SplitLongLines.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SplitSubtitle.resx">
<DependentUpon>SplitSubtitle.cs</DependentUpon>
<SubType>Designer</SubType>