private void Application_Startup(object sender, StartupEventArgs e) { // mandatory filename arg - grabbed output will write to this file. if (e.Args.Length == 1 && !string.IsNullOrEmpty(e.Args[0])) { string filename = e.Args[0]; var win = new SnippingWindow(filename); win.Show(); } // or Openfin port and app UUID else if (e.Args.Length == 3 && !string.IsNullOrEmpty(e.Args[0]) && !string.IsNullOrEmpty(e.Args[1]) && !string.IsNullOrEmpty(e.Args[2])) { int port; if (!int.TryParse(e.Args[0], out port) || port < 1 || port > 65535) { throw new Exception("Invalid port number."); } var uuid = e.Args[1]; var topic = e.Args[2]; var win = new SnippingWindow(port, uuid, topic); win.Show(); } else { throw new Exception("Invalid command line arguments."); } }
private void Application_Startup(object sender, StartupEventArgs e) { string[] availableLocale = { "en-US", "ja-JP", "fr-FR" }; string filename = (e.Args.Length >= 1 && !string.IsNullOrEmpty(e.Args[0])) ? e.Args[0] : null; string locale = (e.Args.Length == 2 && !string.IsNullOrEmpty(e.Args[1])) ? e.Args[1] : null; if (filename != null) { if (locale != null && availableLocale.Contains(locale)) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(locale); } SnippingWindow win = new SnippingWindow(filename); win.Show(); } else { throw new Exception("Missing filename command line argument."); } }