2010-10-12 13:17:56 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Nikse.SubtitleEdit.Logic;
|
2010-12-30 20:20:33 +01:00
|
|
|
|
using System.Drawing;
|
2010-10-12 13:17:56 +02:00
|
|
|
|
|
|
|
|
|
namespace Nikse.SubtitleEdit.Forms
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class ChangeFrameRate : Form
|
|
|
|
|
{
|
|
|
|
|
public ChangeFrameRate()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
comboBoxFrameRateFrom.Items.Add((23.976).ToString());
|
|
|
|
|
comboBoxFrameRateFrom.Items.Add((24.0).ToString());
|
|
|
|
|
comboBoxFrameRateFrom.Items.Add((25.0).ToString());
|
|
|
|
|
comboBoxFrameRateFrom.Items.Add((29.97).ToString());
|
|
|
|
|
|
|
|
|
|
comboBoxFrameRateTo.Items.Add((23.976).ToString());
|
|
|
|
|
comboBoxFrameRateTo.Items.Add((24.0).ToString());
|
|
|
|
|
comboBoxFrameRateTo.Items.Add((25.0).ToString());
|
|
|
|
|
comboBoxFrameRateTo.Items.Add((29.97).ToString());
|
|
|
|
|
|
|
|
|
|
LanguageStructure.ChangeFrameRate language = Configuration.Settings.Language.ChangeFrameRate;
|
|
|
|
|
Text = language.Title;
|
|
|
|
|
labelInfo.Text = language.ConvertFrameRateOfSubtitle;
|
|
|
|
|
labelFromFrameRate.Text = language.FromFrameRate;
|
|
|
|
|
labelToFrameRate.Text = language.ToFrameRate;
|
|
|
|
|
buttonOK.Text = Configuration.Settings.Language.General.OK;
|
|
|
|
|
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
2010-12-30 20:20:33 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
2010-10-12 13:17:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FormChangeFrameRate_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Escape)
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Initialize(string fromFrameRate)
|
|
|
|
|
{
|
|
|
|
|
comboBoxFrameRateFrom.Text = fromFrameRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetFrameRateFromVideoFile(string oldFrameRate)
|
|
|
|
|
{
|
2011-02-12 09:00:12 +01:00
|
|
|
|
openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle;
|
2010-10-12 13:17:56 +02:00
|
|
|
|
openFileDialog1.FileName = string.Empty;
|
|
|
|
|
openFileDialog1.Filter = Utilities.GetVideoFileFilter();
|
|
|
|
|
openFileDialog1.FileName = string.Empty;
|
|
|
|
|
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
VideoInfo info = Utilities.GetVideoInfo(openFileDialog1.FileName, delegate { Application.DoEvents(); });
|
|
|
|
|
if (info != null && info.Success)
|
|
|
|
|
{
|
|
|
|
|
return info.FramesPerSecond.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return oldFrameRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonGetFrameRateFromClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
comboBoxFrameRateFrom.Text = GetFrameRateFromVideoFile(comboBoxFrameRateFrom.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonGetFrameRateToClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
comboBoxFrameRateTo.Text = GetFrameRateFromVideoFile(comboBoxFrameRateTo.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonOkClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
double d;
|
|
|
|
|
if (double.TryParse(comboBoxFrameRateFrom.Text, out d) &&
|
|
|
|
|
double.TryParse(comboBoxFrameRateTo.Text, out d))
|
|
|
|
|
{
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
else if (comboBoxFrameRateFrom.Text.Trim() == comboBoxFrameRateTo.Text.Trim())
|
|
|
|
|
{
|
2011-01-05 08:07:05 +01:00
|
|
|
|
MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotChanged);
|
2010-10-12 13:17:56 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-05 08:07:05 +01:00
|
|
|
|
MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotCorrect);
|
2010-10-12 13:17:56 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double OldFrameRate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return double.Parse(comboBoxFrameRateFrom.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double NewFrameRate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return double.Parse(comboBoxFrameRateTo.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-06 21:22:35 +02:00
|
|
|
|
|
2010-10-12 13:17:56 +02:00
|
|
|
|
}
|
|
|
|
|
}
|