-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
94 lines (86 loc) · 3.18 KB
/
Copy pathProgram.cs
File metadata and controls
94 lines (86 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ChaosScreen
{
static class Program
{
[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();
static void ShowScreenSaver()
{
var allScreens = Screen.AllScreens;
ScreenSaverForm screensaver = null;
for (int i = 0; i < allScreens.Length; i++)
{
if (i == 0)
{
screensaver = new ScreenSaverForm(allScreens[i].Bounds);
}
else
{
var black = new Blank(allScreens[i].Bounds);
black.Show();
}
}
screensaver.Initialize();
screensaver.Render();
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(String[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
{
string firstArgument = args[0].ToLower().Trim();
string secondArgument = null;
// Handle cases where arguments are separated by colon.
// Examples: /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 About());
}
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;
}
IntPtr previewWndHandle = new IntPtr(long.Parse(secondArgument));
var form = new ScreenSaverForm(previewWndHandle);
}
else if (firstArgument == "/s") // Full-screen mode
{
ShowScreenSaver();
}
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
{
//var screen = new ScreenSaverForm(GetDesktopWindow());
//screen.Initialize();
//screen.Render();
//Application.Run(new About());
ShowScreenSaver();
}
}
}
}