private void MainForm_Load(object sender, EventArgs e)
{
// check for mpv.exe
if (!File.Exists(Path.Combine(Application.StartupPath, "mpv.exe")))
{
MessageBox.Show("mpv.exe was not found!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Application.Exit();
}
this.SuspendLayout(); // -- begin layout changes
RegisterMPlayerEvents();
playlist.Init(this, mp);
trayIcon.ContextMenu = trayContextMenu;
this.MouseWheel += MainForm_MouseWheel;
this.MinimumSize = new Size(this.Width, this.Height - this.ClientSize.Height
+ mainMenuStrip.Height + seekPanel.Height + controlPanel.Height);
folderToolStripMenuItem.Text = "Build " + Program.GetVersion();
SetLCDFont(); // Embbeding Font (LCD.ttf)
ShowConsole = false;
ShowPlaylist = false;
LoadSettings();
this.ResumeLayout(); // -- end layout changes
// check for updates
var dfi = DateTimeFormatInfo.CurrentInfo;
var week = dfi.Calendar.GetWeekOfYear(DateTime.Today, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
var lastCheck = Properties.Settings.Default.LastUpdateCheck;
if (week != lastCheck)
{
var checker = new UpdateEngine();
checker.CheckForUpdates(true);
Properties.Settings.Default.LastUpdateCheck = week;
Properties.Settings.Default.Save();
}
// check for command line args
var arg = Environment.GetCommandLineArgs();
for (int i = 1; i < arg.Length; i++)
{
if (arg[i].Equals("-lastfile", StringComparison.OrdinalIgnoreCase))
{
var lastFile = Properties.Settings.Default.LastFile;
if (File.Exists(lastFile))
{
mp.OpenFile(lastFile);
}
else
{
MessageBox.Show("Either there is no previous file or the previous file does not exist anymore.",
"Cannot Open Last File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
break;
}
if (File.Exists(arg[i]))
{
// Note: opening only one file at a time is supported
mp.OpenFile(arg[i]);
break;
}
}
}