Program.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Windows.Forms;
  3. namespace MBox
  4. {
  5. internal static class Program
  6. {
  7. /// <summary>
  8. /// The main entry point for the application.
  9. /// </summary>
  10. [STAThread]
  11. private static int Main(string[] args)
  12. {
  13. Application.EnableVisualStyles();
  14. Application.SetCompatibleTextRenderingDefault(false);
  15. var title = args.Length > 0 ? args[0] : "";
  16. var text = args.Length > 1 ? args[1] : "";
  17. var buttons = args.Length > 2 ? (MessageBoxButtons)Enum.Parse(typeof(MessageBoxButtons), args[2]) : 0;
  18. var icon = args.Length > 3 ? (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), args[3]) : 0;
  19. var def = args.Length > 4 ? (MessageBoxDefaultButton)Enum.Parse(typeof(MessageBoxDefaultButton), args[4]) : 0;
  20. var opt = args.Length > 5 ? (MessageBoxOptions)Enum.Parse(typeof(MessageBoxOptions), args[5]) : 0;
  21. var dr = MessageBox.Show(text, title, buttons, icon, def, opt);
  22. Environment.ExitCode = (int)dr;
  23. Environment.Exit((int)dr);
  24. return (int)dr;
  25. }
  26. }
  27. }