From d9af3f75d07e762806085856e621e3ce03b265fa Mon Sep 17 00:00:00 2001 From: Ivandro Ismael Date: Sun, 25 Aug 2019 13:18:01 +0100 Subject: [PATCH 1/2] simplify initialization --- src/Forms/ChangeFrameRate.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Forms/ChangeFrameRate.cs b/src/Forms/ChangeFrameRate.cs index ac5727041..e68806d87 100644 --- a/src/Forms/ChangeFrameRate.cs +++ b/src/Forms/ChangeFrameRate.cs @@ -13,15 +13,8 @@ namespace Nikse.SubtitleEdit.Forms InitializeComponent(); UiUtil.FixFonts(this); - comboBoxFrameRateFrom.Items.Add(23.976); - comboBoxFrameRateFrom.Items.Add(24.0); - comboBoxFrameRateFrom.Items.Add(25.0); - comboBoxFrameRateFrom.Items.Add(29.97); - - comboBoxFrameRateTo.Items.Add(23.976); - comboBoxFrameRateTo.Items.Add(24.0); - comboBoxFrameRateTo.Items.Add(25.0); - comboBoxFrameRateTo.Items.Add(29.97); + InitializeCombobox(comboBoxFrameRateFrom); + InitializeCombobox(comboBoxFrameRateTo); LanguageStructure.ChangeFrameRate language = Configuration.Settings.Language.ChangeFrameRate; Text = language.Title; @@ -33,6 +26,17 @@ namespace Nikse.SubtitleEdit.Forms UiUtil.FixLargeFonts(this, buttonOK); } + private void InitializeCombobox(ComboBox comboBox) + { + comboBox.BeginUpdate(); + comboBox.Items.Clear(); + comboBox.Items.Add(23.976); + comboBox.Items.Add(24.0); + comboBox.Items.Add(25.0); + comboBox.Items.Add(29.97); + comboBox.EndUpdate(); + } + private void FormChangeFrameRate_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) @@ -81,8 +85,7 @@ namespace Nikse.SubtitleEdit.Forms return; } - double d; - if (double.TryParse(comboBoxFrameRateFrom.Text, out d) && double.TryParse(comboBoxFrameRateTo.Text, out d)) + if (double.TryParse(comboBoxFrameRateFrom.Text, out _) && double.TryParse(comboBoxFrameRateTo.Text, out _)) { DialogResult = DialogResult.OK; } From 8f745c6e2d9535e2458233d0fb4bff80f26e9011 Mon Sep 17 00:00:00 2001 From: Ivandro Ismael Date: Sun, 25 Aug 2019 13:31:47 +0100 Subject: [PATCH 2/2] take only relevant frame value --- src/Forms/ChangeFrameRate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Forms/ChangeFrameRate.cs b/src/Forms/ChangeFrameRate.cs index e68806d87..f833f6f1b 100644 --- a/src/Forms/ChangeFrameRate.cs +++ b/src/Forms/ChangeFrameRate.cs @@ -59,9 +59,9 @@ namespace Nikse.SubtitleEdit.Forms if (openFileDialog1.ShowDialog() == DialogResult.OK) { var info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info != null && info.Success) + if (info?.Success == true) { - return info.FramesPerSecond.ToString(); + return Math.Round(info.FramesPerSecond, 3).ToString(); } } return oldFrameRate;