Bunch of screensavers in Windows
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.7 KiB

  1. using System;
  2. using System.Windows.Forms;
  3. namespace GameOfLife
  4. {
  5. static class Program
  6. {
  7. /// <summary>
  8. /// The main entry point for the application.
  9. /// </summary>
  10. [STAThread]
  11. static void Main(string[] args)
  12. {
  13. Application.SetHighDpiMode(HighDpiMode.SystemAware);
  14. Application.EnableVisualStyles();
  15. Application.SetCompatibleTextRenderingDefault(false);
  16. if (args.Length > 0)
  17. {
  18. string firstArgument = args[0].ToLower().Trim();
  19. string secondArgument = null;
  20. // Handle cases where arguments are separated by colon.
  21. // Examples: /c:1234567 or /P:1234567
  22. if (firstArgument.Length > 2)
  23. {
  24. secondArgument = firstArgument.Substring(3).Trim();
  25. firstArgument = firstArgument.Substring(0, 2);
  26. }
  27. else if (args.Length > 1)
  28. secondArgument = args[1];
  29. if (firstArgument == "/c") // Configuration mode
  30. {
  31. Application.Run(new SettingsForm());
  32. }
  33. else if (firstArgument == "/p") // Preview mode
  34. {
  35. if (secondArgument == null)
  36. {
  37. MessageBox.Show("Sorry, but the expected window handle was not provided.",
  38. "ScreenSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  39. return;
  40. }
  41. IntPtr previewWndHandle = new IntPtr(long.Parse(secondArgument));
  42. Application.Run(new MainForm(previewWndHandle));
  43. }
  44. else if (firstArgument == "/s") // Full-screen mode
  45. {
  46. ShowScreenSaver();
  47. Application.Run();
  48. }
  49. else // Undefined argument
  50. {
  51. MessageBox.Show("Sorry, but the command line argument \"" + firstArgument +
  52. "\" is not valid.", "ScreenSaver",
  53. MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  54. }
  55. }
  56. else // No arguments - treat like /c
  57. {
  58. Application.Run(new SettingsForm());
  59. }
  60. }
  61. static void ShowScreenSaver()
  62. {
  63. foreach (Screen screen in Screen.AllScreens) {
  64. MainForm form = new MainForm(screen.Bounds);
  65. form.Show();
  66. }
  67. }
  68. }
  69. }