diff --git a/src/Controls/SubtitleListView.cs b/src/Controls/SubtitleListView.cs index 617813830..f8b46242b 100644 --- a/src/Controls/SubtitleListView.cs +++ b/src/Controls/SubtitleListView.cs @@ -556,6 +556,8 @@ namespace Nikse.SubtitleEdit.Controls { if (index < 0 || index >= Items.Count || Items.Count == 0) return; + if (TopItem == null) + return; int bottomIndex = TopItem.Index + ((Height - 25) / 16); int itemsBeforeAfterCount = ((bottomIndex - TopItem.Index) / 2) - 1; diff --git a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs b/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs index 488d47ffd..b597df638 100644 --- a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs +++ b/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs @@ -35,8 +35,12 @@ this.buttonOK = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.checkBoxShowOnlyChangedLines = new System.Windows.Forms.CheckBox(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.labelOneFrameIsXMS = new System.Windows.Forms.Label(); + this.groupBoxFrameInfo = new System.Windows.Forms.GroupBox(); this.groupBoxLinesFound.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).BeginInit(); + this.groupBoxFrameInfo.SuspendLayout(); this.SuspendLayout(); // // groupBoxLinesFound @@ -45,9 +49,9 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxLinesFound.Controls.Add(this.SubtitleListview1); - this.groupBoxLinesFound.Location = new System.Drawing.Point(18, 75); + this.groupBoxLinesFound.Location = new System.Drawing.Point(18, 94); this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(726, 366); + this.groupBoxLinesFound.Size = new System.Drawing.Size(726, 347); this.groupBoxLinesFound.TabIndex = 14; this.groupBoxLinesFound.TabStop = false; this.groupBoxLinesFound.Text = "Preview"; @@ -67,9 +71,10 @@ this.SubtitleListview1.Location = new System.Drawing.Point(6, 19); this.SubtitleListview1.Name = "SubtitleListview1"; this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(714, 341); + this.SubtitleListview1.Size = new System.Drawing.Size(714, 322); this.SubtitleListview1.TabIndex = 5; this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; this.SubtitleListview1.View = System.Windows.Forms.View.Details; // // numericUpDownMinMillisecondsBetweenLines @@ -86,7 +91,7 @@ 0, 0}); this.numericUpDownMinMillisecondsBetweenLines.Name = "numericUpDownMinMillisecondsBetweenLines"; - this.numericUpDownMinMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21); + this.numericUpDownMinMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 24); this.numericUpDownMinMillisecondsBetweenLines.TabIndex = 34; this.numericUpDownMinMillisecondsBetweenLines.Value = new decimal(new int[] { 50, @@ -101,7 +106,7 @@ this.labelMaxMillisecondsBetweenLines.AutoSize = true; this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(15, 18); this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; - this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(172, 13); + this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(217, 17); this.labelMaxMillisecondsBetweenLines.TabIndex = 35; this.labelMaxMillisecondsBetweenLines.Text = "Mininum milliseconds between lines"; // @@ -132,19 +137,52 @@ // this.checkBoxShowOnlyChangedLines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.checkBoxShowOnlyChangedLines.AutoSize = true; - this.checkBoxShowOnlyChangedLines.Location = new System.Drawing.Point(18, 448); + this.checkBoxShowOnlyChangedLines.Location = new System.Drawing.Point(18, 444); this.checkBoxShowOnlyChangedLines.Name = "checkBoxShowOnlyChangedLines"; - this.checkBoxShowOnlyChangedLines.Size = new System.Drawing.Size(142, 17); + this.checkBoxShowOnlyChangedLines.Size = new System.Drawing.Size(178, 21); this.checkBoxShowOnlyChangedLines.TabIndex = 38; this.checkBoxShowOnlyChangedLines.Text = "Show only modified lines"; this.checkBoxShowOnlyChangedLines.UseVisualStyleBackColor = true; this.checkBoxShowOnlyChangedLines.CheckedChanged += new System.EventHandler(this.checkBoxShowOnlyChangedLines_CheckedChanged); // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(7, 25); + this.comboBoxFrameRate.Margin = new System.Windows.Forms.Padding(4); + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(160, 25); + this.comboBoxFrameRate.TabIndex = 39; + this.comboBoxFrameRate.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrameRate_SelectedIndexChanged); + // + // labelOneFrameIsXMS + // + this.labelOneFrameIsXMS.AutoSize = true; + this.labelOneFrameIsXMS.Location = new System.Drawing.Point(6, 57); + this.labelOneFrameIsXMS.Name = "labelOneFrameIsXMS"; + this.labelOneFrameIsXMS.Size = new System.Drawing.Size(170, 17); + this.labelOneFrameIsXMS.TabIndex = 40; + this.labelOneFrameIsXMS.Text = "One frame is x milliseconds"; + // + // groupBoxFrameInfo + // + this.groupBoxFrameInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFrameInfo.Controls.Add(this.comboBoxFrameRate); + this.groupBoxFrameInfo.Controls.Add(this.labelOneFrameIsXMS); + this.groupBoxFrameInfo.Location = new System.Drawing.Point(355, 12); + this.groupBoxFrameInfo.Name = "groupBoxFrameInfo"; + this.groupBoxFrameInfo.Size = new System.Drawing.Size(383, 76); + this.groupBoxFrameInfo.TabIndex = 41; + this.groupBoxFrameInfo.TabStop = false; + this.groupBoxFrameInfo.Text = "Frame rate info"; + // // SetMinimumDisplayTimeBetweenParagraphs // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(754, 480); + this.Controls.Add(this.groupBoxFrameInfo); this.Controls.Add(this.checkBoxShowOnlyChangedLines); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); @@ -152,6 +190,7 @@ this.Controls.Add(this.labelMaxMillisecondsBetweenLines); this.Controls.Add(this.groupBoxLinesFound); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MinimumSize = new System.Drawing.Size(750, 500); this.Name = "SetMinimumDisplayTimeBetweenParagraphs"; this.ShowIcon = false; this.ShowInTaskbar = false; @@ -160,6 +199,8 @@ this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SetMinimalDisplayTimeDifference_KeyDown); this.groupBoxLinesFound.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).EndInit(); + this.groupBoxFrameInfo.ResumeLayout(false); + this.groupBoxFrameInfo.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -174,5 +215,8 @@ private System.Windows.Forms.Button buttonCancel; private Controls.SubtitleListView SubtitleListview1; private System.Windows.Forms.CheckBox checkBoxShowOnlyChangedLines; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.Label labelOneFrameIsXMS; + private System.Windows.Forms.GroupBox groupBoxFrameInfo; } } \ No newline at end of file diff --git a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs b/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs index 490a4cc26..cd45d4637 100644 --- a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs +++ b/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using Nikse.SubtitleEdit.Logic; +using System.Globalization; namespace Nikse.SubtitleEdit.Forms { @@ -25,6 +26,30 @@ namespace Nikse.SubtitleEdit.Forms SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); SubtitleListview1.InitializeTimeStampColumWidths(this); FixLargeFonts(); + + groupBoxFrameInfo.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.FrameInfo; + comboBoxFrameRate.Items.Add((23.976).ToString()); + comboBoxFrameRate.Items.Add((24.0).ToString()); + comboBoxFrameRate.Items.Add((25.0).ToString()); + comboBoxFrameRate.Items.Add((29.97).ToString()); + comboBoxFrameRate.Items.Add((30.0).ToString()); + comboBoxFrameRate.Items.Add((59.94).ToString()); + if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 23.976) < 0.1) + comboBoxFrameRate.SelectedIndex = 0; + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.1) + comboBoxFrameRate.SelectedIndex = 1; + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 25) < 0.1) + comboBoxFrameRate.SelectedIndex = 2; + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 29.97) < 0.01) + comboBoxFrameRate.SelectedIndex = 3; + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 30) < 0.1) + comboBoxFrameRate.SelectedIndex = 4; + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 59.94) < 0.1) + comboBoxFrameRate.SelectedIndex = 5; + else + comboBoxFrameRate.SelectedIndex = 3; + if (string.IsNullOrEmpty(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.OneFrameXisYMilliseconds)) + groupBoxFrameInfo.Visible = false; } private void FixLargeFonts() @@ -129,6 +154,22 @@ namespace Nikse.SubtitleEdit.Forms Configuration.Settings.General.MininumMillisecondsBetweenLines = (int)numericUpDownMinMillisecondsBetweenLines.Value; } + private void comboBoxFrameRate_SelectedIndexChanged(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.OneFrameXisYMilliseconds)) + return; + + double frameRate = 25.0; + string s = comboBoxFrameRate.SelectedItem.ToString(); + s = s.Replace(",", ".").Trim(); + double d; + if (double.TryParse(s, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) + frameRate = d; + + long ms = (long)Math.Round(1000 / frameRate); + labelOneFrameIsXMS.Text = string.Format(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.OneFrameXisYMilliseconds, frameRate, ms); + } + } } diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index b6df583ff..6a1dc431e 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -1520,6 +1520,8 @@ can edit in same subtitle file (collaboration)", PreviewLinesModifiedX = "Preview - paragraphs modified: {0}", MinimumMillisecondsBetweenParagraphs = "Minimum milliseconds between lines", ShowOnlyModifiedLines = "Show only modified lines", + FrameInfo = "", + OneFrameXisYMilliseconds = "One frame at {0:0.00} fps is {1} milliseconds", }; SetSyncPoint = new LanguageStructure.SetSyncPoint diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index bd2b188a9..3554ec90c 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -1421,6 +1421,8 @@ public string PreviewLinesModifiedX { get; set; } public string ShowOnlyModifiedLines { get; set; } public string MinimumMillisecondsBetweenParagraphs { get; set; } + public string FrameInfo { get; set; } + public string OneFrameXisYMilliseconds { get; set; } } public class SetSyncPoint