@@ -12,7 +12,7 @@ static void Main(string[] args) {
12
12
Application . EnableVisualStyles ( ) ;
13
13
Application . SetCompatibleTextRenderingDefault ( false ) ;
14
14
15
- char cmd = getParam ( args , 0 , 's' ) ;
15
+ char cmd = getCommand ( args , 0 , 's' ) ;
16
16
if ( cmd == 'c' ) {
17
17
Configure ( ) ;
18
18
}
@@ -26,6 +26,14 @@ static void Main(string[] args) {
26
26
Show ( ) ;
27
27
#endif
28
28
}
29
+ else if ( cmd == 'w' ) {
30
+ Settings . I . Windowed = true ;
31
+ Settings . I . Maximized = false ;
32
+ Settings . I . Fullscreen = false ;
33
+ int w = ( int . TryParse ( getParam ( args , 1 , "" ) , out w ) ? w : int . MaxValue ) ;
34
+ int h = ( int . TryParse ( getParam ( args , 2 , "" ) , out h ) ? h : int . MaxValue ) ;
35
+ Show ( w , h ) ;
36
+ }
29
37
else {
30
38
Configure ( ) ;
31
39
}
@@ -41,27 +49,33 @@ private static void Preview(string[] args) {
41
49
Application . Run ( new PreviewForm ( Ptr ) ) ;
42
50
}
43
51
44
- public static void Show ( ) {
52
+ public static void Show ( int width = int . MaxValue , int height = int . MaxValue ) {
45
53
// get resolution
46
- int left = int . MaxValue ;
47
- int right = int . MinValue ;
48
- int top = int . MaxValue ;
54
+ int left = int . MaxValue ;
55
+ int right = int . MinValue ;
56
+ int top = int . MaxValue ;
49
57
int bottom = int . MinValue ;
50
58
foreach ( Screen s in Screen . AllScreens ) {
51
- left = Math . Min ( s . Bounds . Left , left ) ;
52
- right = Math . Max ( s . Bounds . Right , right ) ;
53
- top = Math . Min ( s . Bounds . Top , top ) ;
59
+ left = Math . Min ( s . Bounds . Left , left ) ;
60
+ right = Math . Max ( s . Bounds . Right , right ) ;
61
+ top = Math . Min ( s . Bounds . Top , top ) ;
54
62
bottom = Math . Max ( s . Bounds . Bottom , bottom ) ;
55
63
}
56
- Rectangle r = new Rectangle ( left , top , right - left , bottom - top ) ;
64
+ width = Math . Min ( width , right - left ) ;
65
+ height = Math . Min ( height , bottom - top ) ;
66
+ Rectangle r = new Rectangle ( left , top , width , height ) ;
57
67
using ( ScreensaverWindow scr = new ScreensaverWindow ( r ) ) {
58
68
scr . Run ( ) ;
59
69
}
60
70
}
61
71
62
- private static char getParam ( string [ ] args , int index , char _default ) {
72
+ private static string getParam ( string [ ] args , int index , string _default ) {
63
73
if ( args . Length <= index || index < 0 ) { return _default ; }
64
- return args [ index ] . Trim ( ) . Substring ( 1 , 1 ) . ToLower ( ) [ 0 ] ;
74
+ return args [ index ] . Trim ( ) ;
75
+ }
76
+
77
+ private static char getCommand ( string [ ] args , int index , char _default ) {
78
+ return getParam ( args , index , "/" + _default ) . Substring ( 1 , 1 ) . ToLower ( ) [ 0 ] ;
65
79
}
66
80
}
67
81
}
0 commit comments