From 45a80a11040aaaa1c954a3b3a1e6a802ebb7b456 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 22 Jan 2011 19:40:23 +0000 Subject: [PATCH] Fixed bug (introduced in 3.1 beta 2) in Show earlier/later (delay tool) - thx Wolf git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@277 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/Main.Designer.cs | 216 ++++++++++++------------- src/Forms/Main.cs | 52 +++--- src/Forms/Main.resx | 2 +- src/Forms/ShowEarlierLater.Designer.cs | 42 ++++- src/Forms/ShowEarlierLater.cs | 24 ++- 5 files changed, 184 insertions(+), 152 deletions(-) diff --git a/src/Forms/Main.Designer.cs b/src/Forms/Main.Designer.cs index dd34613cc..18f587ecd 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/Forms/Main.Designer.cs @@ -226,6 +226,7 @@ this.toolStripMenuItemPlayRateNormal = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemPlayRateFast = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemPlayRateVeryFast = new System.Windows.Forms.ToolStripMenuItem(); + this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm(); this.tabControlButtons = new System.Windows.Forms.TabControl(); this.tabPageTranslate = new System.Windows.Forms.TabPage(); this.labelTranslateTip = new System.Windows.Forms.Label(); @@ -247,6 +248,7 @@ this.buttonPlayCurrent = new System.Windows.Forms.Button(); this.buttonPlayNext = new System.Windows.Forms.Button(); this.tabPageCreate = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonGotoSub = new System.Windows.Forms.Button(); this.buttonBeforeText = new System.Windows.Forms.Button(); this.buttonSetEnd = new System.Windows.Forms.Button(); @@ -265,6 +267,7 @@ this.labelVideoPosition = new System.Windows.Forms.Label(); this.buttonSecBack1 = new System.Windows.Forms.Button(); this.tabPageAdjust = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonAdjustSetEndTime = new System.Windows.Forms.Button(); this.buttonSetEndAndGoToNext = new System.Windows.Forms.Button(); this.buttonSetStartAndOffsetRest = new System.Windows.Forms.Button(); @@ -314,6 +317,7 @@ this.labelTextLineTotal = new System.Windows.Forms.Label(); this.labelCharactersPerSecond = new System.Windows.Forms.Label(); this.buttonUnBreak = new System.Windows.Forms.Button(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonUndoListViewChanges = new System.Windows.Forms.Button(); this.labelStartTimeWarning = new System.Windows.Forms.Label(); this.labelDurationWarning = new System.Windows.Forms.Label(); @@ -324,18 +328,14 @@ this.textBoxListViewText = new System.Windows.Forms.TextBox(); this.labelDuration = new System.Windows.Forms.Label(); this.labelAutoDuration = new System.Windows.Forms.Label(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.textBoxSource = new System.Windows.Forms.TextBox(); this.panelVideoPlayer = new System.Windows.Forms.Panel(); + this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.contextMenuStripEmpty = new System.Windows.Forms.ContextMenuStrip(this.components); this.insertLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm(); - this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.statusStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -2029,6 +2029,34 @@ this.toolStripMenuItemPlayRateVeryFast.Text = "Very fast"; this.toolStripMenuItemPlayRateVeryFast.Click += new System.EventHandler(this.veryFastToolStripMenuItem_Click); // + // AudioWaveForm + // + this.AudioWaveForm.AllowDrop = true; + this.AudioWaveForm.AllowNewSelection = true; + this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black; + this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black; + this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow; + this.AudioWaveForm.DrawGridLines = true; + this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); + this.AudioWaveForm.Location = new System.Drawing.Point(472, 32); + this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0); + this.AudioWaveForm.Name = "AudioWaveForm"; + this.AudioWaveForm.NewSelectionParagraph = null; + this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red; + this.AudioWaveForm.Size = new System.Drawing.Size(768, 229); + this.AudioWaveForm.StartPositionSeconds = 0D; + this.AudioWaveForm.TabIndex = 6; + this.AudioWaveForm.TextColor = System.Drawing.Color.Gray; + this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form"; + this.AudioWaveForm.WavePeaks = null; + this.AudioWaveForm.ZoomFactor = 1D; + this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click); + this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop); + this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter); + // // tabControlButtons // this.tabControlButtons.Controls.Add(this.tabPageTranslate); @@ -2304,6 +2332,16 @@ this.tabPageCreate.Text = "Create"; this.tabPageCreate.UseVisualStyleBackColor = true; // + // timeUpDownVideoPosition + // + this.timeUpDownVideoPosition.AutoSize = true; + this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192); + this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; + this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25); + this.timeUpDownVideoPosition.TabIndex = 12; + // // buttonGotoSub // this.buttonGotoSub.Location = new System.Drawing.Point(6, 58); @@ -2527,6 +2565,16 @@ this.tabPageAdjust.Text = "Adjust"; this.tabPageAdjust.UseVisualStyleBackColor = true; // + // timeUpDownVideoPositionAdjust + // + this.timeUpDownVideoPositionAdjust.AutoSize = true; + this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214); + this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; + this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25); + this.timeUpDownVideoPositionAdjust.TabIndex = 13; + // // buttonAdjustSetEndTime // this.buttonAdjustSetEndTime.Location = new System.Drawing.Point(6, 84); @@ -3045,6 +3093,16 @@ this.buttonUnBreak.UseVisualStyleBackColor = true; this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25); + this.timeUpDownStartTime.TabIndex = 0; + // // buttonUndoListViewChanges // this.buttonUndoListViewChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -3165,6 +3223,31 @@ this.labelAutoDuration.TabIndex = 30; this.labelAutoDuration.Text = "Auto"; // + // 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.ContextMenuStrip = this.contextMenuStripListview; + 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(1, 3); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.Size = new System.Drawing.Size(932, 148); + this.SubtitleListview1.SmallImageList = this.imageList1; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); + this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); + this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); + this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown); + this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); + // // tabPage2 // this.tabPage2.Controls.Add(this.textBoxSource); @@ -3209,6 +3292,25 @@ this.panelVideoPlayer.Size = new System.Drawing.Size(282, 278); this.panelVideoPlayer.TabIndex = 5; // + // mediaPlayer + // + this.mediaPlayer.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.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); + this.mediaPlayer.CurrentPosition = 0D; + this.mediaPlayer.Location = new System.Drawing.Point(0, 0); + this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); + this.mediaPlayer.Name = "mediaPlayer"; + this.mediaPlayer.ShowStopButton = true; + this.mediaPlayer.Size = new System.Drawing.Size(281, 278); + this.mediaPlayer.SubtitleText = ""; + this.mediaPlayer.TabIndex = 5; + this.mediaPlayer.VideoPlayer = null; + this.mediaPlayer.Volume = 0D; + this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); + this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); + // // contextMenuStripEmpty // this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -3230,108 +3332,6 @@ this.imageListPlayRate.Images.SetKeyName(0, "FastForward.png"); this.imageListPlayRate.Images.SetKeyName(1, "FastForwardHighLight.png"); // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25); - this.timeUpDownStartTime.TabIndex = 0; - // - // 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.ContextMenuStrip = this.contextMenuStripListview; - 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(1, 3); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.Size = new System.Drawing.Size(932, 148); - this.SubtitleListview1.SmallImageList = this.imageList1; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); - this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); - this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); - this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown); - this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); - // - // mediaPlayer - // - this.mediaPlayer.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.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); - this.mediaPlayer.CurrentPosition = 0D; - this.mediaPlayer.Location = new System.Drawing.Point(0, 0); - this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); - this.mediaPlayer.Name = "mediaPlayer"; - this.mediaPlayer.ShowStopButton = true; - this.mediaPlayer.Size = new System.Drawing.Size(281, 278); - this.mediaPlayer.SubtitleText = ""; - this.mediaPlayer.TabIndex = 5; - this.mediaPlayer.VideoPlayer = null; - this.mediaPlayer.Volume = 0D; - this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); - this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); - // - // AudioWaveForm - // - this.AudioWaveForm.AllowDrop = true; - this.AudioWaveForm.AllowNewSelection = true; - this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black; - this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black; - this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow; - this.AudioWaveForm.DrawGridLines = true; - this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); - this.AudioWaveForm.Location = new System.Drawing.Point(472, 32); - this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0); - this.AudioWaveForm.Name = "AudioWaveForm"; - this.AudioWaveForm.NewSelectionParagraph = null; - this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red; - this.AudioWaveForm.Size = new System.Drawing.Size(768, 229); - this.AudioWaveForm.StartPositionSeconds = 0D; - this.AudioWaveForm.TabIndex = 6; - this.AudioWaveForm.TextColor = System.Drawing.Color.Gray; - this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form"; - this.AudioWaveForm.WavePeaks = null; - this.AudioWaveForm.ZoomFactor = 1D; - this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click); - this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop); - this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter); - // - // timeUpDownVideoPosition - // - this.timeUpDownVideoPosition.AutoSize = true; - this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192); - this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; - this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25); - this.timeUpDownVideoPosition.TabIndex = 12; - // - // timeUpDownVideoPositionAdjust - // - this.timeUpDownVideoPositionAdjust.AutoSize = true; - this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214); - this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; - this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25); - this.timeUpDownVideoPositionAdjust.TabIndex = 13; - // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 4f72ca6c5..cff8d1b20 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -105,7 +105,7 @@ namespace Nikse.SubtitleEdit.Forms if (versionInfo.Length >= 3 && versionInfo[2] != "0") _title += "." + versionInfo[2]; } - return _title + " Beta 9"; + return _title + " Beta 10"; } } @@ -5157,9 +5157,9 @@ namespace Nikse.SubtitleEdit.Forms timer1.Stop(); _showEarlierOrLater = new ShowEarlierLater(); - _showEarlierOrLater.Initialize(ShowEarlierOrLaterSelectedLinesOnly, true); + _showEarlierOrLater.Initialize(ShowEarlierOrLater, true); MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater); - _showEarlierOrLater.ShowDialog(this); + _showEarlierOrLater.Show(this); timerWaveForm.Enabled = waveFormEnabled; videoTimer.Enabled = videoTimerEnabled; @@ -6816,7 +6816,6 @@ namespace Nikse.SubtitleEdit.Forms TimeCode tc = new TimeCode(TimeSpan.FromMilliseconds(totalMilliseconds)); MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc.ToString()); - // find index where to insert int index = 0; foreach (Paragraph p in _subtitle.Paragraphs) @@ -6872,10 +6871,8 @@ namespace Nikse.SubtitleEdit.Forms mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; mediaPlayer.Play(); } - } - private void GotoSubPositionAndPause() { if (SubtitleListview1.SelectedItems.Count > 0) @@ -6956,40 +6953,37 @@ namespace Nikse.SubtitleEdit.Forms Refresh(); } - public void ShowEarlierOrLater(double adjustMilliseconds) + public void ShowEarlierOrLater(double adjustMilliseconds, bool onlySelected) { - double frameRate = CurrentFrameRate; - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(adjustMilliseconds)); - SubtitleListview1.BeginUpdate(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - Paragraph p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - SubtitleListview1.SetStartTime(i, p); - if (_subtitle.WasLoadedWithFrameNumbers) - p.CalculateFrameNumbersFromTimeCodes(frameRate); - } - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - } + TimeCode tc = new TimeCode(TimeSpan.FromMilliseconds(adjustMilliseconds)); + MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater + ": " + tc.ToString()); - public void ShowEarlierOrLaterSelectedLinesOnly(double adjustMilliseconds) - { - double frameRate = CurrentFrameRate; - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(adjustMilliseconds)); + double frameRate = CurrentFrameRate; SubtitleListview1.BeginUpdate(); for (int i = 0; i < _subtitle.Paragraphs.Count; i++) { - if (SubtitleListview1.Items[i].Selected) + if (SubtitleListview1.Items[i].Selected || !onlySelected) { Paragraph p = _subtitle.GetParagraphOrDefault(i); if (p != null) + { + p.StartTime.TotalMilliseconds += adjustMilliseconds; + p.EndTime.TotalMilliseconds += adjustMilliseconds; SubtitleListview1.SetStartTime(i, p); - if (_subtitle.WasLoadedWithFrameNumbers) - p.CalculateFrameNumbersFromTimeCodes(frameRate); + } } } SubtitleListview1.EndUpdate(); + if (_subtitle.WasLoadedWithFrameNumbers) + _subtitle.CalculateFrameNumbersFromTimeCodes(frameRate); + RefreshSelectedParagraph(); + UpdateSourceView(); + } + + private void UpdateSourceView() + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + ShowSource(); } private void toolStripMenuItemAdjustAllTimes_Click(object sender, EventArgs e) @@ -7006,7 +7000,7 @@ namespace Nikse.SubtitleEdit.Forms _showEarlierOrLater = new ShowEarlierLater(); SaveSubtitleListviewIndexes(); _showEarlierOrLater.Initialize(ShowEarlierOrLater, false); - _showEarlierOrLater.ShowDialog(this); + _showEarlierOrLater.Show(this); } else { diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index cbebf4be7..d4d7b697d 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -684,7 +684,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAWgBAAFoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAXgBAAF4AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/Forms/ShowEarlierLater.Designer.cs b/src/Forms/ShowEarlierLater.Designer.cs index 254d81031..be132b302 100644 --- a/src/Forms/ShowEarlierLater.Designer.cs +++ b/src/Forms/ShowEarlierLater.Designer.cs @@ -36,6 +36,8 @@ namespace Nikse.SubtitleEdit.Forms this.buttonShowEarlier = new System.Windows.Forms.Button(); this.labelTotalAdjustment = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.radioButtonAllLines = new System.Windows.Forms.RadioButton(); + this.radioButtonSelectedLinesOnly = new System.Windows.Forms.RadioButton(); this.timeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.SuspendLayout(); // @@ -44,7 +46,7 @@ namespace Nikse.SubtitleEdit.Forms this.labelHoursMinSecsMilliSecs.AutoSize = true; this.labelHoursMinSecsMilliSecs.Location = new System.Drawing.Point(11, 6); this.labelHoursMinSecsMilliSecs.Name = "labelHoursMinSecsMilliSecs"; - this.labelHoursMinSecsMilliSecs.Size = new System.Drawing.Size(169, 21); + this.labelHoursMinSecsMilliSecs.Size = new System.Drawing.Size(108, 13); this.labelHoursMinSecsMilliSecs.TabIndex = 18; this.labelHoursMinSecsMilliSecs.Text = "Hours:min:sec.msecs"; // @@ -71,9 +73,9 @@ namespace Nikse.SubtitleEdit.Forms // labelTotalAdjustment // this.labelTotalAdjustment.AutoSize = true; - this.labelTotalAdjustment.Location = new System.Drawing.Point(12, 90); + this.labelTotalAdjustment.Location = new System.Drawing.Point(12, 128); this.labelTotalAdjustment.Name = "labelTotalAdjustment"; - this.labelTotalAdjustment.Size = new System.Drawing.Size(169, 21); + this.labelTotalAdjustment.Size = new System.Drawing.Size(108, 13); this.labelTotalAdjustment.TabIndex = 38; this.labelTotalAdjustment.Text = "labelTotalAdjustment"; // @@ -81,6 +83,30 @@ namespace Nikse.SubtitleEdit.Forms // this.timer1.Interval = 250; // + // radioButtonAllLines + // + this.radioButtonAllLines.AutoSize = true; + this.radioButtonAllLines.Location = new System.Drawing.Point(14, 70); + this.radioButtonAllLines.Name = "radioButtonAllLines"; + this.radioButtonAllLines.Size = new System.Drawing.Size(60, 17); + this.radioButtonAllLines.TabIndex = 39; + this.radioButtonAllLines.TabStop = true; + this.radioButtonAllLines.Text = "All lines"; + this.radioButtonAllLines.UseVisualStyleBackColor = true; + this.radioButtonAllLines.CheckedChanged += new System.EventHandler(this.radioButtonAllLines_CheckedChanged); + // + // radioButtonSelectedLinesOnly + // + this.radioButtonSelectedLinesOnly.AutoSize = true; + this.radioButtonSelectedLinesOnly.Location = new System.Drawing.Point(14, 93); + this.radioButtonSelectedLinesOnly.Name = "radioButtonSelectedLinesOnly"; + this.radioButtonSelectedLinesOnly.Size = new System.Drawing.Size(113, 17); + this.radioButtonSelectedLinesOnly.TabIndex = 40; + this.radioButtonSelectedLinesOnly.TabStop = true; + this.radioButtonSelectedLinesOnly.Text = "Selected lines only"; + this.radioButtonSelectedLinesOnly.UseVisualStyleBackColor = true; + this.radioButtonSelectedLinesOnly.CheckedChanged += new System.EventHandler(this.radioButtonAllLines_CheckedChanged); + // // timeUpDownAdjust // this.timeUpDownAdjust.AutoSize = true; @@ -88,14 +114,16 @@ namespace Nikse.SubtitleEdit.Forms this.timeUpDownAdjust.Location = new System.Drawing.Point(12, 23); this.timeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); this.timeUpDownAdjust.Name = "timeUpDownAdjust"; - this.timeUpDownAdjust.Size = new System.Drawing.Size(137, 34); + this.timeUpDownAdjust.Size = new System.Drawing.Size(92, 25); this.timeUpDownAdjust.TabIndex = 21; // // ShowEarlierLater // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(278, 113); + this.ClientSize = new System.Drawing.Size(291, 150); + this.Controls.Add(this.radioButtonSelectedLinesOnly); + this.Controls.Add(this.radioButtonAllLines); this.Controls.Add(this.buttonShowLater); this.Controls.Add(this.buttonShowEarlier); this.Controls.Add(this.labelTotalAdjustment); @@ -122,5 +150,7 @@ namespace Nikse.SubtitleEdit.Forms private System.Windows.Forms.Button buttonShowEarlier; private System.Windows.Forms.Label labelTotalAdjustment; private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.RadioButton radioButtonAllLines; + private System.Windows.Forms.RadioButton radioButtonSelectedLinesOnly; } } \ No newline at end of file diff --git a/src/Forms/ShowEarlierLater.cs b/src/Forms/ShowEarlierLater.cs index f6b462386..b3d1d9ca2 100644 --- a/src/Forms/ShowEarlierLater.cs +++ b/src/Forms/ShowEarlierLater.cs @@ -1,15 +1,13 @@ using System; -using System.Collections.Generic; +using System.Drawing; using System.Windows.Forms; using Nikse.SubtitleEdit.Logic; -using System.IO; -using System.Drawing; namespace Nikse.SubtitleEdit.Forms { public sealed partial class ShowEarlierLater : Form { - public delegate void AdjustEventHandler(double adjustMilliseconds); + public delegate void AdjustEventHandler(double adjustMilliseconds, bool onlySelected); TimeSpan _totalAdjustment = TimeSpan.FromMilliseconds(0); AdjustEventHandler _adjustCallback; @@ -24,6 +22,8 @@ namespace Nikse.SubtitleEdit.Forms labelHoursMinSecsMilliSecs.Text = Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; buttonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier; buttonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater; + radioButtonAllLines.Text = Configuration.Settings.Language.ShowEarlierLater.AllLines; + radioButtonSelectedLinesOnly.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesonly; FixLargeFonts(); } @@ -54,9 +54,9 @@ namespace Nikse.SubtitleEdit.Forms internal void Initialize(AdjustEventHandler adjustCallback, bool onlySelected) { if (onlySelected) - Text = Configuration.Settings.Language.ShowEarlierLater.Title; + radioButtonSelectedLinesOnly.Checked = true; else - Text = Configuration.Settings.Language.ShowEarlierLater.TitleAll; + radioButtonAllLines.Checked = true; _adjustCallback = adjustCallback; timeUpDownAdjust.TimeCode = new TimeCode(TimeSpan.FromMilliseconds(Configuration.Settings.General.DefaultAdjustMilliseconds)); @@ -67,7 +67,7 @@ namespace Nikse.SubtitleEdit.Forms TimeCode tc = timeUpDownAdjust.TimeCode; if (tc != null && tc.TotalMilliseconds > 0) { - _adjustCallback.Invoke(-tc.TotalMilliseconds); + _adjustCallback.Invoke(-tc.TotalMilliseconds, radioButtonSelectedLinesOnly.Checked); _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds - tc.TotalMilliseconds); ShowTotalAdjustMent(); Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; @@ -85,12 +85,20 @@ namespace Nikse.SubtitleEdit.Forms TimeCode tc = timeUpDownAdjust.TimeCode; if (tc != null && tc.TotalMilliseconds > 0) { - _adjustCallback.Invoke(tc.TotalMilliseconds); + _adjustCallback.Invoke(tc.TotalMilliseconds, radioButtonSelectedLinesOnly.Checked); _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds + tc.TotalMilliseconds); ShowTotalAdjustMent(); Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; } } + private void radioButtonAllLines_CheckedChanged(object sender, EventArgs e) + { + if (radioButtonSelectedLinesOnly.Checked) + Text = Configuration.Settings.Language.ShowEarlierLater.Title; + else + Text = Configuration.Settings.Language.ShowEarlierLater.TitleAll; + } + } }