public static void TriggerDate() { Random Chance = new Random(); DateTime BirthDate = DateTime.Now; int currentyear = Convert.ToInt32(BirthDate.ToString("yyyy")); if (BirthDate.ToString("dd") == "01") { double days = (DateTime.Now.Date - Properties.Settings.Default.DonationShownWhen).TotalDays; if (days > 30 && Properties.Settings.Default.NoMoreDonation == false) { Form frm = new DonateMonthlyDialog { StartPosition = FormStartPosition.CenterScreen }; frm.ShowDialog(); } } if (BirthDate.ToString("dd/MM") == "17/09") { MessageBox.Show("Today, KMC turned " + (currentyear - 2015).ToString() + " year(s) old!\n\nHappy birthday, awesome converter!", "Happy birthday to me, Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "05/12") { MessageBox.Show("Today is Keppy's birthday! He turned " + (currentyear - 1999).ToString() + " years old!\n\nHappy birthday, you potato!", "Happy birthday to Kepperino", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void TriggerDate() { DateTime BirthDate = DateTime.Now; int currentyear = Convert.ToInt32(BirthDate.ToString("yyyy")); if (BirthDate.ToString("dd") == "01") { double days = (DateTime.Now.Date - Properties.Settings.Default.DonationShownWhen).TotalDays; if (days > 30 && Properties.Settings.Default.NoMoreDonation == false) { Form frm = new DonateMonthlyDialog(); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); } } if (BirthDate.ToString("dd/MM") == "23/04") { MessageBox.Show("Today is Frozen's birthday! He turned " + (currentyear - 1996).ToString() + " years old!\n\nHappy birthday, you potato!", "Happy birthday to Frozen Snow", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "17/09") { MessageBox.Show("Today, KMC turned " + (currentyear - 2015).ToString() + " year(s) old!\n\nHappy birthday, awesome converter!", "Happy birthday to me, Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "31/10") { MessageBox.Show("Spooky conversions today, huh?", "Happy Halloween!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "05/12") { MessageBox.Show("Today is Keppy's birthday! He turned " + (currentyear - 1999).ToString() + " years old!\n\nHappy birthday, you potato!", "Happy birthday to Kepperino", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "25/12") { MessageBox.Show("Oh oh oh, Merry Christmas!", "Happy holidays, and Merry Christmas!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (BirthDate.ToString("dd/MM") == "01/01") { MessageBox.Show("HAPPY NEW YEAR!", "Finally, " + BirthDate.ToString("yyyy") + " has begun!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//Take in arguments static void Main(String[] args) { if (Properties.Settings.Default.MigrateSettings) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.MigrateSettings = false; Properties.Settings.Default.Save(); } bool deletencoder = false; string oggencoder = "kmcogg.exe"; string mp3encoder = "kmcmp3.exe"; bool ok; DeleteOldLanguages(); Mutex m = new Mutex(true, "KepMIDIConv", out ok); if (!ok) { var bytes = new byte[16]; var rnd = new Random(); rnd.NextBytes(bytes); string originalkmcpath = String.Format("{0}\\{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "kmcogg.exe"); string newkmcoggpath = String.Format("{0}kmcogg{1}.exe", Path.GetTempPath(), Convert.ToBase64String(bytes).Replace("=", "").Replace("+", "").Replace("/", "").ToString()); File.Copy(originalkmcpath, newkmcoggpath); rnd.NextBytes(bytes); originalkmcpath = String.Format("{0}\\{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "kmcmp3.exe"); string newkmcmp3path = String.Format("{0}kmcmp3{1}.exe", Path.GetTempPath(), Convert.ToBase64String(bytes).Replace("=", "").Replace("+", "").Replace("/", "").ToString()); File.Copy(originalkmcpath, newkmcmp3path); deletencoder = true; oggencoder = newkmcoggpath; mp3encoder = newkmcmp3path; } try { int shouldupdate = 1; int skiptrigger = 1; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); for (int i = 0; i < args.Length; i++) { if (args[i].ToLowerInvariant() == "/skipupdate") { shouldupdate = 0; break; } else if (args[i].ToLowerInvariant() == "/avoidtrigger") { skiptrigger = 0; break; } else if (args[i].ToLowerInvariant() == "/resetsettings") { Properties.Settings.Default.Reset(); Properties.Settings.Default.Save(); MessageBox.Show("Settings have been reset to their default values.", "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } else if (args[i].ToLowerInvariant() == "/debug") // DO NOT USE IF NOT NEEDED <.< { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; AllocConsole(); Console.Title = "Keppy's MIDI Converter Debug Window"; Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Keppy's MIDI Converter Debug Window - Version " + version); Console.WriteLine("Copyright KaleidonKep99 2013 - " + DateTime.Now.Year.ToString()); Console.ResetColor(); Console.WriteLine(); Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("This should only be used when Kep himself asks you to do so. It's not really that useful, if not for debug."); Console.WriteLine(); Console.ResetColor(); Console.BackgroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine("Debug started, waiting for errors..."); Console.ResetColor(); break; } else if (args[i].ToLowerInvariant() == "/nothemespartial") { Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NonClientAreaEnabled; break; } else if (args[i].ToLowerInvariant() == "/nothemesfull") { Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled; break; } else if (args[i].ToLowerInvariant() == "/alternativetextrendering") { Application.SetCompatibleTextRenderingDefault(true); break; } else if (args[i].ToLowerInvariant() == "/restorelanguage") { Properties.Settings.Default.LangOverride = false; Properties.Settings.Default.SelectedLang = "en-US"; Properties.Settings.Default.Save(); MessageBox.Show("Language succesfully restored.", "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (args[i].ToLowerInvariant() == "/rickroll") { Process.Start("https://www.youtube.com/watch?v=dQw4w9WgXcQ"); return; } else if (args[i].ToLowerInvariant() == "/triggerdonation") { Properties.Settings.Default.NoMoreDonation = false; Properties.Settings.Default.Save(); Form frm = new DonateMonthlyDialog(); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); } else if (args[i].ToLowerInvariant() == "/ksp" | args[i].ToLowerInvariant() == "/keppysteinwaypiano") { Process.Start("https://github.com/KaleidonKep99/Keppy-Steinway-Piano"); return; } else if (args[i].ToLowerInvariant() == "/kep" | args[i].ToLowerInvariant() == "/keppy" | args[i].ToLowerInvariant() == "/kaleidonkep99") { Process.Start("https://plus.google.com/u/0/+RiccardoLoi"); return; } else if (args[i].ToLowerInvariant() == "/blackmidi" | args[i].ToLowerInvariant() == "/blackmiditeam" | args[i].ToLowerInvariant() == "/blackmidicommunity") { Process.Start("https://plus.google.com/communities/105907289212970966669"); return; } else if (args[i].ToLowerInvariant() == "/blackmididiscord" | args[i].ToLowerInvariant() == "/bmcdiscord" | args[i].ToLowerInvariant() == "/bmtdiscord") { Process.Start("https://discord.gg/9afWatV"); return; } else if (args[i].ToLowerInvariant().Contains("/")) { MessageBox.Show(String.Format("\"{0}\" is not a valid command line argument!\n\nPress OK to continue.", args[i]), "Keppy's MIDI Converter - Argument error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } else { break; } } if (shouldupdate == 1) { PerformUpdate(); } if (skiptrigger == 1) { TriggerDate(); } var encoders = new List <string>(); encoders.Add(oggencoder); encoders.Add(mp3encoder); String[] array = encoders.ToArray(); Application.Run(new MainWindow(args, array, deletencoder)); GC.KeepAlive(m); } catch (Exception ex) { MessageBox.Show("There was an error while trying to load the languages!\n\nError:" + ex.ToString(), "Keppy's MIDI Converter - Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public static void CheckStartUpArguments(String[] args) { for (int i = 0; i < args.Length; i++) { if (args[i].ToLowerInvariant() == "/skipupdate") { SkipUpdate = true; } else if (args[i].ToLowerInvariant() == "/avoidtrigger") { SkipTrigger = true; } else if (args[i].ToLowerInvariant() == "/resetsettings") { Properties.Settings.Default.Reset(); Properties.Settings.Default.Save(); MessageBox.Show(Languages.Parse("SettingsReset"), "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (args[i].ToLowerInvariant() == "/debug") // DO NOT USE IF NOT NEEDED <.< { Program.DebugMode = true; FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); string version = fvi.FileVersion; AllocConsole(); Console.Title = "Keppy's MIDI Converter Debug Window"; Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.Write(Properties.Resources.KMCTitle); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Keppy's MIDI Converter Debug Window - Version " + version); Console.WriteLine("Copyright(C) KaleidonKep99 2013 - " + DateTime.Now.Year.ToString()); Console.ResetColor(); Console.WriteLine(); Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("This should only be used when Kep himself asks you to do so. It's not really that useful, if not for debug."); Console.WriteLine(); Console.ResetColor(); Console.BackgroundColor = ConsoleColor.Green; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine("Debug started, waiting for errors..."); Console.ResetColor(); } else if (args[i].ToLowerInvariant() == "/restorelanguage") { Properties.Settings.Default.LangOverride = false; Properties.Settings.Default.SelectedLang = "en-US"; Properties.Settings.Default.Save(); MessageBox.Show("Language succesfully restored.", "Keppy's MIDI Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (args[i].ToLowerInvariant() == "/triggerdonation") { Properties.Settings.Default.NoMoreDonation = false; Properties.Settings.Default.Save(); Form frm = new DonateMonthlyDialog { StartPosition = FormStartPosition.CenterScreen }; frm.ShowDialog(); } else if (args[i].ToLowerInvariant().Contains("/")) { MessageBox.Show(String.Format(Languages.Parse("InvalidArg"), args[i]), Languages.Parse("ArgumentError"), MessageBoxButtons.OK, MessageBoxIcon.Error); CloseApp = true; } else { break; } } }