static public void RunScreenSaver(Object previewWndHandle) { ScreenSaver screenSaver = new ScreenSaver(); if (previewWndHandle != null) { screenSaver._previewMode = true; screenSaver._parentHwnd = (IntPtr)previewWndHandle; } screenSaver.Run(); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (ScreenSaver game = new ScreenSaver()) { if (args.Length > 0) { firstArgument = args[0].ToLower().Trim(); secondArgument = null; // Обработка случаев, когда аргумент разделяются ":" // Пример: /c:1234567 or /P:1234567 if (firstArgument.Length > 2) { secondArgument = firstArgument.Substring(3).Trim(); firstArgument = firstArgument.Substring(0, 2); } else if (args.Length > 1) { secondArgument = args[1]; } if (firstArgument == "/c") // Configuration mode { Application.Run(new Двоичные_часы.SettingForm()); /*SettingForm f = new SettingForm(); * f.ShowDialog();*/ } else if (firstArgument == "/p") // Preview mode { if (secondArgument == null) { MessageBox.Show("Sorry, but the expected window handle was not provided.", "ScreenSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } SetupScreenSavers(false, true); //IntPtr previewWndHandle = new IntPtr(long.Parse(secondArgument)); //game.Run(); } else if (firstArgument == "/s") // Full-screen mode { //SetupScreenSavers(true, false); game.Run(); } else // Undefined argument { MessageBox.Show("Sorry, but the command line argument \"" + firstArgument + "\" is not valid.", "ScreenSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else // No arguments - treat like /c { Application.Run(new Двоичные_часы.SettingForm()); /*SettingForm f = new SettingForm(); * f.ShowDialog();*/ } } }