Working on 'split' subtitle

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1139 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-04-26 11:09:21 +00:00
parent 77f50b3a7e
commit 97a8a120a7
7 changed files with 561 additions and 146 deletions

View File

@ -1065,31 +1065,31 @@
// showHistoryforUndoToolStripMenuItem
//
this.showHistoryforUndoToolStripMenuItem.Name = "showHistoryforUndoToolStripMenuItem";
this.showHistoryforUndoToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.showHistoryforUndoToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.showHistoryforUndoToolStripMenuItem.Text = "Show history (for undo)";
this.showHistoryforUndoToolStripMenuItem.Click += new System.EventHandler(this.ShowHistoryforUndoToolStripMenuItemClick);
//
// toolStripSeparator14
//
this.toolStripSeparator14.Name = "toolStripSeparator14";
this.toolStripSeparator14.Size = new System.Drawing.Size(268, 6);
this.toolStripSeparator14.Size = new System.Drawing.Size(219, 6);
//
// toolStripMenuItemInsertUnicodeCharacter
//
this.toolStripMenuItemInsertUnicodeCharacter.Name = "toolStripMenuItemInsertUnicodeCharacter";
this.toolStripMenuItemInsertUnicodeCharacter.Size = new System.Drawing.Size(271, 22);
this.toolStripMenuItemInsertUnicodeCharacter.Size = new System.Drawing.Size(222, 22);
this.toolStripMenuItemInsertUnicodeCharacter.Text = "Insert unicode character";
//
// toolStripSeparatorInsertUnicodeCharacter
//
this.toolStripSeparatorInsertUnicodeCharacter.Name = "toolStripSeparatorInsertUnicodeCharacter";
this.toolStripSeparatorInsertUnicodeCharacter.Size = new System.Drawing.Size(268, 6);
this.toolStripSeparatorInsertUnicodeCharacter.Size = new System.Drawing.Size(219, 6);
//
// findToolStripMenuItem
//
this.findToolStripMenuItem.Name = "findToolStripMenuItem";
this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
this.findToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.findToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.findToolStripMenuItem.Text = "Find";
this.findToolStripMenuItem.Click += new System.EventHandler(this.FindToolStripMenuItemClick);
//
@ -1097,7 +1097,7 @@
//
this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem";
this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.findNextToolStripMenuItem.Text = "Find next";
this.findNextToolStripMenuItem.Click += new System.EventHandler(this.FindNextToolStripMenuItemClick);
//
@ -1105,14 +1105,14 @@
//
this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
this.replaceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H)));
this.replaceToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.replaceToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.replaceToolStripMenuItem.Text = "Replace";
this.replaceToolStripMenuItem.Click += new System.EventHandler(this.ReplaceToolStripMenuItemClick);
//
// multipleReplaceToolStripMenuItem
//
this.multipleReplaceToolStripMenuItem.Name = "multipleReplaceToolStripMenuItem";
this.multipleReplaceToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.multipleReplaceToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.multipleReplaceToolStripMenuItem.Text = "Multiple replace";
this.multipleReplaceToolStripMenuItem.Click += new System.EventHandler(this.MultipleReplaceToolStripMenuItemClick);
//
@ -1120,14 +1120,14 @@
//
this.gotoLineNumberToolStripMenuItem.Name = "gotoLineNumberToolStripMenuItem";
this.gotoLineNumberToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
this.gotoLineNumberToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.gotoLineNumberToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.gotoLineNumberToolStripMenuItem.Text = "Goto line number...";
this.gotoLineNumberToolStripMenuItem.Click += new System.EventHandler(this.GotoLineNumberToolStripMenuItemClick);
//
// toolStripSeparator25
//
this.toolStripSeparator25.Name = "toolStripSeparator25";
this.toolStripSeparator25.Size = new System.Drawing.Size(268, 6);
this.toolStripSeparator25.Size = new System.Drawing.Size(219, 6);
//
// toolStripMenuItemRightToLeftMode
//
@ -1139,12 +1139,12 @@
// toolStripSeparator21
//
this.toolStripSeparator21.Name = "toolStripSeparator21";
this.toolStripSeparator21.Size = new System.Drawing.Size(268, 6);
this.toolStripSeparator21.Size = new System.Drawing.Size(219, 6);
//
// editSelectAllToolStripMenuItem
//
this.editSelectAllToolStripMenuItem.Name = "editSelectAllToolStripMenuItem";
this.editSelectAllToolStripMenuItem.Size = new System.Drawing.Size(271, 22);
this.editSelectAllToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.editSelectAllToolStripMenuItem.Text = "Select all";
this.editSelectAllToolStripMenuItem.Click += new System.EventHandler(this.EditSelectAllToolStripMenuItemClick);
//

View File

@ -3588,14 +3588,40 @@ namespace Nikse.SubtitleEdit.Forms
if (_subtitle != null && _subtitle.Paragraphs.Count > 1)
{
ReloadFromSourceView();
var splitSubtitle = new SplitSubtitle();
double lengthInSeconds = 0;
if (mediaPlayer.VideoPlayer != null)
lengthInSeconds = mediaPlayer.Duration;
splitSubtitle.Initialize(_subtitle, _fileName , GetCurrentSubtitleFormat(), GetCurrentEncoding(), lengthInSeconds);
if (splitSubtitle.ShowDialog(this) == DialogResult.OK)
if (Configuration.Settings.Tools.SplitAdvanced)
{
ShowStatus(_language.SubtitleSplitted);
var split = new Split();
double lengthInSeconds = 0;
if (mediaPlayer.VideoPlayer != null)
lengthInSeconds = mediaPlayer.Duration;
split. Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat(), GetCurrentEncoding(), lengthInSeconds);
if (split.ShowDialog(this) == DialogResult.OK)
{
ShowStatus(_language.SubtitleSplitted);
}
else if (split.ShowBasic)
{
Configuration.Settings.Tools.SplitAdvanced = false;
SplitToolStripMenuItemClick(null, null);
}
}
else
{
var splitSubtitle = new SplitSubtitle();
double lengthInSeconds = 0;
if (mediaPlayer.VideoPlayer != null)
lengthInSeconds = mediaPlayer.Duration;
splitSubtitle.Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat(), GetCurrentEncoding(), lengthInSeconds);
if (splitSubtitle.ShowDialog(this) == DialogResult.OK)
{
ShowStatus(_language.SubtitleSplitted);
}
else if (splitSubtitle.ShowAdvanced)
{
Configuration.Settings.Tools.SplitAdvanced = true;
SplitToolStripMenuItemClick(null, null);
}
}
}
else

View File

@ -574,9 +574,6 @@
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -684,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAATgBEgE4ARIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAUABEgFAARIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -29,70 +29,65 @@
private void InitializeComponent()
{
this.groupBoxParts = new System.Windows.Forms.GroupBox();
this.RadioButtonLines = new System.Windows.Forms.RadioButton();
this.radioButtonTime = new System.Windows.Forms.RadioButton();
this.numericUpDownParts = new System.Windows.Forms.NumericUpDown();
this.labelNumberOfParts = new System.Windows.Forms.Label();
this.numericUpDownParts = new System.Windows.Forms.NumericUpDown();
this.radioButtonCharacters = new System.Windows.Forms.RadioButton();
this.RadioButtonLines = new System.Windows.Forms.RadioButton();
this.groupBoxOutput = new System.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.buttonChooseFolder = new System.Windows.Forms.Button();
this.labelChooseOutputFolder = new System.Windows.Forms.Label();
this.comboBoxEncoding = new System.Windows.Forms.ComboBox();
this.labelOutputFormat = new System.Windows.Forms.Label();
this.labelChooseOutputFolder = new System.Windows.Forms.Label();
this.buttonChooseFolder = new System.Windows.Forms.Button();
this.textBoxOutputFolder = new System.Windows.Forms.TextBox();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.groupBoxPreview = new System.Windows.Forms.GroupBox();
this.comboBoxOutputFormat = new System.Windows.Forms.ComboBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSplit = new System.Windows.Forms.Button();
this.listViewFixes = new System.Windows.Forms.ListView();
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.listViewParts = new System.Windows.Forms.ListView();
this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSplit = new System.Windows.Forms.Button();
this.buttonBasic = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.labelLines = new System.Windows.Forms.Label();
this.labelCharacters = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.comboBoxSubtitleFormats = new System.Windows.Forms.ComboBox();
this.groupBoxParts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).BeginInit();
this.groupBoxOutput.SuspendLayout();
this.groupBoxPreview.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBoxParts
//
this.groupBoxParts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxParts.Controls.Add(this.groupBox1);
this.groupBoxParts.Controls.Add(this.labelNumberOfParts);
this.groupBoxParts.Controls.Add(this.numericUpDownParts);
this.groupBoxParts.Controls.Add(this.radioButtonTime);
this.groupBoxParts.Controls.Add(this.radioButtonCharacters);
this.groupBoxParts.Controls.Add(this.RadioButtonLines);
this.groupBoxParts.Location = new System.Drawing.Point(13, 13);
this.groupBoxParts.Name = "groupBoxParts";
this.groupBoxParts.Size = new System.Drawing.Size(457, 71);
this.groupBoxParts.Size = new System.Drawing.Size(606, 86);
this.groupBoxParts.TabIndex = 0;
this.groupBoxParts.TabStop = false;
this.groupBoxParts.Text = "Number of parts";
this.groupBoxParts.Text = "Split options";
//
// RadioButtonLines
// labelNumberOfParts
//
this.RadioButtonLines.AutoSize = true;
this.RadioButtonLines.Checked = true;
this.RadioButtonLines.Location = new System.Drawing.Point(15, 20);
this.RadioButtonLines.Name = "RadioButtonLines";
this.RadioButtonLines.Size = new System.Drawing.Size(50, 17);
this.RadioButtonLines.TabIndex = 0;
this.RadioButtonLines.TabStop = true;
this.RadioButtonLines.Text = "Lines";
this.RadioButtonLines.UseVisualStyleBackColor = true;
//
// radioButtonTime
//
this.radioButtonTime.AutoSize = true;
this.radioButtonTime.Location = new System.Drawing.Point(15, 43);
this.radioButtonTime.Name = "radioButtonTime";
this.radioButtonTime.Size = new System.Drawing.Size(48, 17);
this.radioButtonTime.TabIndex = 1;
this.radioButtonTime.Text = "Time";
this.radioButtonTime.UseVisualStyleBackColor = true;
this.labelNumberOfParts.AutoSize = true;
this.labelNumberOfParts.Location = new System.Drawing.Point(148, 22);
this.labelNumberOfParts.Name = "labelNumberOfParts";
this.labelNumberOfParts.Size = new System.Drawing.Size(111, 13);
this.labelNumberOfParts.TabIndex = 3;
this.labelNumberOfParts.Text = "Number of equal parts";
//
// numericUpDownParts
//
this.numericUpDownParts.Location = new System.Drawing.Point(117, 38);
this.numericUpDownParts.Location = new System.Drawing.Point(151, 38);
this.numericUpDownParts.Minimum = new decimal(new int[] {
2,
0,
@ -106,47 +101,67 @@
0,
0,
0});
this.numericUpDownParts.ValueChanged += new System.EventHandler(this.numericUpDownParts_ValueChanged);
//
// labelNumberOfParts
// radioButtonCharacters
//
this.labelNumberOfParts.AutoSize = true;
this.labelNumberOfParts.Location = new System.Drawing.Point(114, 22);
this.labelNumberOfParts.Name = "labelNumberOfParts";
this.labelNumberOfParts.Size = new System.Drawing.Size(111, 13);
this.labelNumberOfParts.TabIndex = 3;
this.labelNumberOfParts.Text = "Number of equal parts";
this.radioButtonCharacters.AutoSize = true;
this.radioButtonCharacters.Location = new System.Drawing.Point(15, 43);
this.radioButtonCharacters.Name = "radioButtonCharacters";
this.radioButtonCharacters.Size = new System.Drawing.Size(76, 17);
this.radioButtonCharacters.TabIndex = 1;
this.radioButtonCharacters.Text = "Characters";
this.radioButtonCharacters.UseVisualStyleBackColor = true;
this.radioButtonCharacters.CheckedChanged += new System.EventHandler(this.radioButtonCharacters_CheckedChanged);
//
// RadioButtonLines
//
this.RadioButtonLines.AutoSize = true;
this.RadioButtonLines.Checked = true;
this.RadioButtonLines.Location = new System.Drawing.Point(15, 20);
this.RadioButtonLines.Name = "RadioButtonLines";
this.RadioButtonLines.Size = new System.Drawing.Size(50, 17);
this.RadioButtonLines.TabIndex = 0;
this.RadioButtonLines.TabStop = true;
this.RadioButtonLines.Text = "Lines";
this.RadioButtonLines.UseVisualStyleBackColor = true;
this.RadioButtonLines.CheckedChanged += new System.EventHandler(this.RadioButtonLines_CheckedChanged);
//
// groupBoxOutput
//
this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxOutput.Controls.Add(this.comboBoxOutputFormat);
this.groupBoxOutput.Controls.Add(this.comboBoxSubtitleFormats);
this.groupBoxOutput.Controls.Add(this.label1);
this.groupBoxOutput.Controls.Add(this.comboBoxEncoding);
this.groupBoxOutput.Controls.Add(this.labelOutputFormat);
this.groupBoxOutput.Controls.Add(this.labelChooseOutputFolder);
this.groupBoxOutput.Controls.Add(this.buttonChooseFolder);
this.groupBoxOutput.Controls.Add(this.textBox1);
this.groupBoxOutput.Location = new System.Drawing.Point(16, 90);
this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder);
this.groupBoxOutput.Location = new System.Drawing.Point(12, 105);
this.groupBoxOutput.Name = "groupBoxOutput";
this.groupBoxOutput.Size = new System.Drawing.Size(457, 106);
this.groupBoxOutput.Size = new System.Drawing.Size(610, 106);
this.groupBoxOutput.TabIndex = 1;
this.groupBoxOutput.TabStop = false;
this.groupBoxOutput.Text = "Output";
//
// textBox1
// comboBoxEncoding
//
this.textBox1.Location = new System.Drawing.Point(7, 39);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(402, 20);
this.textBox1.TabIndex = 0;
this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxEncoding.FormattingEnabled = true;
this.comboBoxEncoding.Location = new System.Drawing.Point(367, 69);
this.comboBoxEncoding.Name = "comboBoxEncoding";
this.comboBoxEncoding.Size = new System.Drawing.Size(221, 21);
this.comboBoxEncoding.TabIndex = 6;
//
// buttonChooseFolder
// labelOutputFormat
//
this.buttonChooseFolder.Location = new System.Drawing.Point(415, 37);
this.buttonChooseFolder.Name = "buttonChooseFolder";
this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23);
this.buttonChooseFolder.TabIndex = 1;
this.buttonChooseFolder.Text = "...";
this.buttonChooseFolder.UseVisualStyleBackColor = true;
this.labelOutputFormat.AutoSize = true;
this.labelOutputFormat.Location = new System.Drawing.Point(6, 72);
this.labelOutputFormat.Name = "labelOutputFormat";
this.labelOutputFormat.Size = new System.Drawing.Size(39, 13);
this.labelOutputFormat.TabIndex = 5;
this.labelOutputFormat.Text = "Format";
//
// labelChooseOutputFolder
//
@ -157,78 +172,57 @@
this.labelChooseOutputFolder.TabIndex = 4;
this.labelChooseOutputFolder.Text = "Choose output folder";
//
// labelOutputFormat
// buttonChooseFolder
//
this.labelOutputFormat.AutoSize = true;
this.labelOutputFormat.Location = new System.Drawing.Point(6, 72);
this.labelOutputFormat.Name = "labelOutputFormat";
this.labelOutputFormat.Size = new System.Drawing.Size(71, 13);
this.labelOutputFormat.TabIndex = 5;
this.labelOutputFormat.Text = "Output format";
this.buttonChooseFolder.Location = new System.Drawing.Point(566, 39);
this.buttonChooseFolder.Name = "buttonChooseFolder";
this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23);
this.buttonChooseFolder.TabIndex = 1;
this.buttonChooseFolder.Text = "...";
this.buttonChooseFolder.UseVisualStyleBackColor = true;
this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click);
//
// textBoxOutputFolder
//
this.textBoxOutputFolder.Location = new System.Drawing.Point(7, 39);
this.textBoxOutputFolder.Name = "textBoxOutputFolder";
this.textBoxOutputFolder.Size = new System.Drawing.Size(553, 20);
this.textBoxOutputFolder.TabIndex = 0;
this.textBoxOutputFolder.TextChanged += new System.EventHandler(this.textBoxOutputFolder_TextChanged);
//
// groupBoxPreview
//
this.groupBoxPreview.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.groupBoxPreview.Controls.Add(this.listViewFixes);
this.groupBoxPreview.Location = new System.Drawing.Point(13, 202);
this.groupBoxPreview.Controls.Add(this.listViewParts);
this.groupBoxPreview.Location = new System.Drawing.Point(12, 217);
this.groupBoxPreview.Name = "groupBoxPreview";
this.groupBoxPreview.Size = new System.Drawing.Size(460, 148);
this.groupBoxPreview.Size = new System.Drawing.Size(610, 148);
this.groupBoxPreview.TabIndex = 2;
this.groupBoxPreview.TabStop = false;
this.groupBoxPreview.Text = "Prevew";
//
// comboBoxOutputFormat
// listViewParts
//
this.comboBoxOutputFormat.FormattingEnabled = true;
this.comboBoxOutputFormat.Location = new System.Drawing.Point(84, 72);
this.comboBoxOutputFormat.Name = "comboBoxOutputFormat";
this.comboBoxOutputFormat.Size = new System.Drawing.Size(325, 21);
this.comboBoxOutputFormat.TabIndex = 6;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(398, 356);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// buttonSplit
//
this.buttonSplit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonSplit.Location = new System.Drawing.Point(317, 356);
this.buttonSplit.Name = "buttonSplit";
this.buttonSplit.Size = new System.Drawing.Size(75, 21);
this.buttonSplit.TabIndex = 3;
this.buttonSplit.Text = "&Split";
this.buttonSplit.UseVisualStyleBackColor = true;
//
// listViewFixes
//
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
this.listViewParts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader5,
this.columnHeader6});
this.listViewFixes.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewFixes.FullRowSelect = true;
this.listViewFixes.HideSelection = false;
this.listViewFixes.Location = new System.Drawing.Point(3, 16);
this.listViewFixes.Name = "listViewFixes";
this.listViewFixes.Size = new System.Drawing.Size(454, 129);
this.listViewFixes.TabIndex = 101;
this.listViewFixes.UseCompatibleStateImageBehavior = false;
this.listViewFixes.View = System.Windows.Forms.View.Details;
this.columnHeader6,
this.columnHeaderFileName});
this.listViewParts.Dock = System.Windows.Forms.DockStyle.Fill;
this.listViewParts.FullRowSelect = true;
this.listViewParts.HideSelection = false;
this.listViewParts.Location = new System.Drawing.Point(3, 16);
this.listViewParts.Name = "listViewParts";
this.listViewParts.Size = new System.Drawing.Size(604, 129);
this.listViewParts.TabIndex = 101;
this.listViewParts.UseCompatibleStateImageBehavior = false;
this.listViewParts.View = System.Windows.Forms.View.Details;
//
// columnHeader4
// columnHeaderFileName
//
this.columnHeader4.Text = "File name";
this.columnHeader4.Width = 280;
this.columnHeaderFileName.Text = "File name";
this.columnHeaderFileName.Width = 463;
//
// columnHeader5
//
@ -237,27 +231,120 @@
//
// columnHeader6
//
this.columnHeader6.Text = "Time";
this.columnHeader6.Width = 61;
this.columnHeader6.Text = "#Characters";
this.columnHeader6.Width = 75;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(547, 371);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonSplit
//
this.buttonSplit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonSplit.Location = new System.Drawing.Point(466, 371);
this.buttonSplit.Name = "buttonSplit";
this.buttonSplit.Size = new System.Drawing.Size(75, 21);
this.buttonSplit.TabIndex = 3;
this.buttonSplit.Text = "&Split";
this.buttonSplit.UseVisualStyleBackColor = true;
this.buttonSplit.Click += new System.EventHandler(this.buttonSplit_Click);
//
// buttonBasic
//
this.buttonBasic.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonBasic.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonBasic.Location = new System.Drawing.Point(362, 371);
this.buttonBasic.Name = "buttonBasic";
this.buttonBasic.Size = new System.Drawing.Size(98, 21);
this.buttonBasic.TabIndex = 24;
this.buttonBasic.Text = "&Basic";
this.buttonBasic.UseVisualStyleBackColor = true;
this.buttonBasic.Click += new System.EventHandler(this.buttonBasic_Click);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.labelCharacters);
this.groupBox1.Controls.Add(this.labelLines);
this.groupBox1.Location = new System.Drawing.Point(311, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(289, 67);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Subtitle info";
//
// labelLines
//
this.labelLines.AutoSize = true;
this.labelLines.Location = new System.Drawing.Point(7, 27);
this.labelLines.Name = "labelLines";
this.labelLines.Size = new System.Drawing.Size(93, 13);
this.labelLines.TabIndex = 0;
this.labelLines.Text = "Number of lines: X";
//
// labelCharacters
//
this.labelCharacters.AutoSize = true;
this.labelCharacters.Location = new System.Drawing.Point(7, 46);
this.labelCharacters.Name = "labelCharacters";
this.labelCharacters.Size = new System.Drawing.Size(122, 13);
this.labelCharacters.TabIndex = 1;
this.labelCharacters.Text = "Number of characters: X";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(309, 72);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(52, 13);
this.label1.TabIndex = 7;
this.label1.Text = "Encoding";
//
// comboBoxSubtitleFormats
//
this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSubtitleFormats.FormattingEnabled = true;
this.comboBoxSubtitleFormats.Location = new System.Drawing.Point(51, 69);
this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats";
this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(225, 21);
this.comboBoxSubtitleFormats.TabIndex = 8;
//
// Split
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(485, 388);
this.ClientSize = new System.Drawing.Size(634, 403);
this.Controls.Add(this.buttonBasic);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSplit);
this.Controls.Add(this.groupBoxPreview);
this.Controls.Add(this.groupBoxOutput);
this.Controls.Add(this.groupBoxParts);
this.MinimumSize = new System.Drawing.Size(640, 420);
this.Name = "Split";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Split";
this.Shown += new System.EventHandler(this.Split_Shown);
this.ResizeEnd += new System.EventHandler(this.Split_ResizeEnd);
this.groupBoxParts.ResumeLayout(false);
this.groupBoxParts.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).EndInit();
this.groupBoxOutput.ResumeLayout(false);
this.groupBoxOutput.PerformLayout();
this.groupBoxPreview.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
@ -267,21 +354,27 @@
private System.Windows.Forms.GroupBox groupBoxParts;
private System.Windows.Forms.Label labelNumberOfParts;
private System.Windows.Forms.NumericUpDown numericUpDownParts;
private System.Windows.Forms.RadioButton radioButtonTime;
private System.Windows.Forms.RadioButton radioButtonCharacters;
private System.Windows.Forms.RadioButton RadioButtonLines;
private System.Windows.Forms.GroupBox groupBoxOutput;
private System.Windows.Forms.ComboBox comboBoxOutputFormat;
private System.Windows.Forms.ComboBox comboBoxEncoding;
private System.Windows.Forms.Label labelOutputFormat;
private System.Windows.Forms.Label labelChooseOutputFolder;
private System.Windows.Forms.Button buttonChooseFolder;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBoxOutputFolder;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.GroupBox groupBoxPreview;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonSplit;
private System.Windows.Forms.ListView listViewFixes;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ListView listViewParts;
private System.Windows.Forms.ColumnHeader columnHeaderFileName;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.Button buttonBasic;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label labelCharacters;
private System.Windows.Forms.Label labelLines;
private System.Windows.Forms.ComboBox comboBoxSubtitleFormats;
private System.Windows.Forms.Label label1;
}
}

View File

@ -5,14 +5,287 @@ using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
namespace Nikse.SubtitleEdit.Forms
{
public partial class Split : Form
{
Subtitle _subtitle;
SubtitleFormat _format;
Encoding _encoding;
private string _fileName;
public bool ShowBasic { get; private set; }
int _totalNumberOfCharacters;
bool _loading = true;
List<Subtitle> _parts;
public Split()
{
InitializeComponent();
Text = Configuration.Settings.Language.SplitSubtitle.Title;
FixLargeFonts();
}
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString(buttonSplit.Text, this.Font);
if (textSize.Height > buttonSplit.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
Utilities.SetButtonHeight(this, newButtonHeight, 1);
}
}
public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format, Encoding encoding, double lengthInSeconds)
{
ShowBasic = false;
_subtitle = subtitle;
_fileName = fileName;
_format = format;
_encoding = encoding;
foreach (Paragraph p in _subtitle.Paragraphs)
_totalNumberOfCharacters += p.Text.Length;
labelLines.Text = string.Format("Number of lines: {0:#,###}", _subtitle.Paragraphs.Count);
labelCharacters.Text = string.Format("Number of characters: {0:#,###,###}", _totalNumberOfCharacters);
try
{
numericUpDownParts.Value = Configuration.Settings.Tools.SplitNumberOfParts;
}
catch
{
}
if (Configuration.Settings.Tools.SplitVia.Trim().ToLower() == "lines")
RadioButtonLines.Checked = true;
else
radioButtonCharacters.Checked = true;
foreach (SubtitleFormat f in SubtitleFormat.AllSubtitleFormats)
{
if (!f.IsVobSubIndexFile)
comboBoxSubtitleFormats.Items.Add(f.FriendlyName);
if (f.FriendlyName == format.FriendlyName)
comboBoxSubtitleFormats.SelectedIndex = comboBoxSubtitleFormats.Items.Count - 1;
}
comboBoxEncoding.Items.Clear();
int encodingSelectedIndex = 0;
comboBoxEncoding.Items.Add(Encoding.UTF8.EncodingName);
foreach (EncodingInfo ei in Encoding.GetEncodings())
{
if (ei.Name != Encoding.UTF8.BodyName)
{
if (ei.CodePage >= Configuration.Settings.General.EncodingMininumCodePage)
{
comboBoxEncoding.Items.Add(ei.CodePage + ": " + ei.DisplayName);
if (ei.Name == Configuration.Settings.General.DefaultEncoding)
encodingSelectedIndex = comboBoxEncoding.Items.Count - 1;
}
}
}
comboBoxEncoding.SelectedIndex = encodingSelectedIndex;
if (numericUpDownParts.Maximum > _subtitle.Paragraphs.Count)
numericUpDownParts.Maximum = _subtitle.Paragraphs.Count / 2;
if (string.IsNullOrEmpty(Configuration.Settings.Tools.SplitOutputFolder) || !System.IO.Directory.Exists(Configuration.Settings.Tools.SplitOutputFolder))
textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
else
textBoxOutputFolder.Text = Configuration.Settings.Tools.SplitOutputFolder;
}
private void CalculateParts()
{
if (_loading)
return;
_loading = true;
_parts = new List<Subtitle>();
if (string.IsNullOrEmpty(textBoxOutputFolder.Text) || !System.IO.Directory.Exists(textBoxOutputFolder.Text))
textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString());
string fileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(_fileName);
listViewParts.Items.Clear();
int startNumber = 0;
if (RadioButtonLines.Checked)
{
int partSize = (int) (_subtitle.Paragraphs.Count / numericUpDownParts.Value);
for (int i = 0; i < numericUpDownParts.Value; i++)
{
int noOfLines = partSize;
if (i == numericUpDownParts.Value -1)
noOfLines = (int) (_subtitle.Paragraphs.Count - ((numericUpDownParts.Value-1) * partSize));
Subtitle temp = new Subtitle();
int size = 0;
for (int number = 0; number < noOfLines; number++)
{
Paragraph p = _subtitle.Paragraphs[startNumber + number];
temp.Paragraphs.Add(new Paragraph(p));
size += p.Text.Length;
}
startNumber += noOfLines;
_parts.Add(temp);
ListViewItem lvi = new ListViewItem(string.Format("{0:#,###,###}", noOfLines));
lvi.SubItems.Add(string.Format("{0:#,###,###}", size));
lvi.SubItems.Add(fileNameNoExt + ".Part" + (i + 1) + format.Extension);
listViewParts.Items.Add(lvi);
}
}
else if (radioButtonCharacters.Checked)
{
int partSize = (int)(_totalNumberOfCharacters / numericUpDownParts.Value);
int nextLimit = partSize;
int currentSize = 0;
Subtitle temp = new Subtitle();
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
Paragraph p = _subtitle.Paragraphs[i];
int size = Utilities.RemoveHtmlTags(p.Text).Length;
if (currentSize + size > nextLimit && _parts.Count < numericUpDownParts.Value-1)
{
_parts.Add(temp);
ListViewItem lvi = new ListViewItem(string.Format("{0:#,###,###}", temp.Paragraphs.Count));
lvi.SubItems.Add(string.Format("{0:#,###,###}", currentSize));
lvi.SubItems.Add(fileNameNoExt + ".Part" + _parts.Count + format.Extension);
listViewParts.Items.Add(lvi);
currentSize = size;
temp = new Subtitle();
}
else
{
currentSize += size;
temp.Paragraphs.Add(new Paragraph(p));
}
}
_parts.Add(temp);
ListViewItem lvi2 = new ListViewItem(temp.Paragraphs.Count.ToString());
lvi2.SubItems.Add(currentSize.ToString());
lvi2.SubItems.Add(fileNameNoExt + ".Part" + numericUpDownParts.Value + ".srt");
listViewParts.Items.Add(lvi2);
}
_loading = false;
}
private void FormSplitSubtitle_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
DialogResult = DialogResult.Cancel;
}
private void buttonBasic_Click(object sender, EventArgs e)
{
ShowBasic = true;
DialogResult = DialogResult.Cancel;
}
private void buttonSplit_Click(object sender, EventArgs e)
{
bool overwrite = false;
var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString());
string fileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(_fileName);
int number = 1;
try
{
foreach (Subtitle sub in _parts)
{
string fileName = System.IO.Path.Combine(textBoxOutputFolder.Text, fileNameNoExt + ".Part" + number + format.Extension);
string allText = sub.ToText(format);
if (System.IO.File.Exists(fileName) && !overwrite)
{
if (MessageBox.Show( "Overwrite existing files?", "", MessageBoxButtons.YesNo) == DialogResult.No)
return;
overwrite = true;
}
System.IO.File.WriteAllText(fileName, allText, GetCurrentEncoding());
number++;
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
return;
}
Configuration.Settings.Tools.SplitNumberOfParts = (int)numericUpDownParts.Value;
Configuration.Settings.Tools.SplitOutputFolder = textBoxOutputFolder.Text;
if (RadioButtonLines.Checked)
Configuration.Settings.Tools.SplitVia = "Lines";
else
Configuration.Settings.Tools.SplitVia = "Characters";
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void numericUpDownParts_ValueChanged(object sender, EventArgs e)
{
CalculateParts();
}
private void radioButtonCharacters_CheckedChanged(object sender, EventArgs e)
{
CalculateParts();
}
private void RadioButtonLines_CheckedChanged(object sender, EventArgs e)
{
CalculateParts();
}
private void textBoxOutputFolder_TextChanged(object sender, EventArgs e)
{
CalculateParts();
}
private void Split_ResizeEnd(object sender, EventArgs e)
{
columnHeaderFileName.Width = -2;
}
private void buttonChooseFolder_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath;
}
}
private Encoding GetCurrentEncoding()
{
if (comboBoxEncoding.Text == Encoding.UTF8.BodyName || comboBoxEncoding.Text == Encoding.UTF8.EncodingName || comboBoxEncoding.Text == "utf-8")
{
return Encoding.UTF8;
}
foreach (EncodingInfo ei in Encoding.GetEncodings())
{
if (ei.CodePage + ": " + ei.DisplayName == comboBoxEncoding.Text)
return ei.GetEncoding();
}
return Encoding.UTF8;
}
private void Split_Shown(object sender, EventArgs e)
{
_loading = false;
CalculateParts();
}
}
}

View File

@ -37,6 +37,7 @@
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.labelHoursMinSecsMilliSecs = new System.Windows.Forms.Label();
this.splitTimeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.buttonAdvanced = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonGetFrameRate
@ -112,11 +113,23 @@
this.splitTimeUpDownAdjust.Size = new System.Drawing.Size(92, 25);
this.splitTimeUpDownAdjust.TabIndex = 21;
//
// buttonAdvanced
//
this.buttonAdvanced.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonAdvanced.Location = new System.Drawing.Point(54, 109);
this.buttonAdvanced.Name = "buttonAdvanced";
this.buttonAdvanced.Size = new System.Drawing.Size(98, 21);
this.buttonAdvanced.TabIndex = 23;
this.buttonAdvanced.Text = "&Advanced";
this.buttonAdvanced.UseVisualStyleBackColor = true;
this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click);
//
// SplitSubtitle
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(325, 140);
this.Controls.Add(this.buttonAdvanced);
this.Controls.Add(this.buttonGetFrameRate);
this.Controls.Add(this.splitTimeUpDownAdjust);
this.Controls.Add(this.labelHoursMinSecsMilliSecs);
@ -149,5 +162,6 @@
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private Nikse.SubtitleEdit.Controls.TimeUpDown splitTimeUpDownAdjust;
private System.Windows.Forms.Label labelHoursMinSecsMilliSecs;
private System.Windows.Forms.Button buttonAdvanced;
}
}

View File

@ -14,6 +14,7 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleFormat _format;
Encoding _encoding;
private string _fileName;
public bool ShowAdvanced { get; private set; }
public SplitSubtitle()
{
@ -24,6 +25,10 @@ namespace Nikse.SubtitleEdit.Forms
label2.Text = Configuration.Settings.Language.SplitSubtitle.Description2;
buttonSplit.Text = Configuration.Settings.Language.SplitSubtitle.Split;
buttonDone.Text = Configuration.Settings.Language.SplitSubtitle.Done;
//TODO: SE 3.3buttonAdvanced.Text = Configuration.Settings.Language.General.Advanced;
buttonAdvanced.Visible = Configuration.Settings.General.ShowBetaStuff;
labelHoursMinSecsMilliSecs.Text = Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds;
buttonGetFrameRate.Left = splitTimeUpDownAdjust.Left + splitTimeUpDownAdjust.Width;
FixLargeFonts();
@ -47,6 +52,7 @@ namespace Nikse.SubtitleEdit.Forms
public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format, Encoding encoding, double lengthInSeconds)
{
ShowAdvanced = false;
_subtitle = subtitle;
_fileName = fileName;
_format = format;
@ -156,5 +162,11 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void buttonAdvanced_Click(object sender, EventArgs e)
{
ShowAdvanced = true;
DialogResult = DialogResult.Cancel;
}
}
}