@@ -40,6 +40,10 @@ public ConsoleEngine(int width, int height, int fontW, int fontH) {
40
40
41
41
Console . Title = "Untitled console application" ;
42
42
Console . CursorVisible = false ;
43
+
44
+ // sätter fönstret och bufferns storlek
45
+ // buffern måste sättas efter fönsret, eftersom den aldrig får vara mindre än skärmen
46
+ Console . SetWindowSize ( width , height ) ;
43
47
Console . SetBufferSize ( width , height ) ;
44
48
45
49
ConsoleBuffer = new ConsoleBuffer ( width , height ) ;
@@ -56,12 +60,9 @@ public ConsoleEngine(int width, int height, int fontW, int fontH) {
56
60
// Stänger av alla standard ConsoleInput metoder (Quick-edit etc)
57
61
NativeMethods . SetConsoleMode ( stdInputHandle , 0x0080 ) ;
58
62
59
- // Sätter fontstorlek och tvingar Raster (Terminal)
63
+ // Sätter fontstorlek och tvingar Raster (Terminal) / Consolas
60
64
// Detta måste göras efter SetBufferSize, annars ger den en IOException
61
65
ConsoleFont . SetFont ( stdOutputHandle , ( short ) fontW , ( short ) fontH ) ;
62
- // sätter storleken på fönstret, måste ske efter SetBufferSize för annars
63
- // blir fönstret 1 px större (?)
64
- Console . SetWindowSize ( width , height ) ;
65
66
}
66
67
67
68
// Rita
@@ -104,13 +105,11 @@ public void DisplayBuffer() {
104
105
ConsoleBuffer . Blit ( ) ;
105
106
}
106
107
107
- /// <summary> Sets wheather the window should be borderless or not. </summary>
108
- /// <param name="b">True if intended to run borderless.</param>
109
- public void Borderless ( bool b ) {
110
- IsBorderless = b ;
108
+ /// <summary> Sets the window to borderless mode. </summary>
109
+ public void Borderless ( ) {
110
+ IsBorderless = true ;
111
111
112
112
int GWL_STYLE = - 16 ; // hex konstant för stil-förändring
113
- int WS_DEFAULT = 0x00C00000 ; // vanlig
114
113
int WS_BORDERLESS = 0x00080000 ; // helt borderless
115
114
116
115
NativeMethods . Rect rect = new NativeMethods . Rect ( ) ;
@@ -125,13 +124,8 @@ public void Borderless(bool b) {
125
124
( desktopRect . Right / 2 ) - ( ( WindowSize . X * FontSize . X ) / 2 ) ,
126
125
( desktopRect . Bottom / 2 ) - ( ( WindowSize . Y * FontSize . Y ) / 2 ) ) ;
127
126
128
- if ( b == true ) {
129
- NativeMethods . SetWindowLong ( consoleHandle , GWL_STYLE , WS_BORDERLESS ) ;
130
- NativeMethods . SetWindowPos ( consoleHandle , - 2 , wPos . X , wPos . Y , rect . Right - 8 , rect . Bottom - 8 , 0x0040 ) ;
131
- } else {
132
- NativeMethods . SetWindowLong ( consoleHandle , GWL_STYLE , WS_DEFAULT ) ;
133
- NativeMethods . SetWindowPos ( consoleHandle , - 2 , wPos . X , wPos . Y , rect . Right , rect . Bottom , 0x0040 ) ;
134
- }
127
+ NativeMethods . SetWindowLong ( consoleHandle , GWL_STYLE , WS_BORDERLESS ) ;
128
+ NativeMethods . SetWindowPos ( consoleHandle , - 2 , wPos . X , wPos . Y , rect . Right - 8 , rect . Bottom - 8 , 0x0040 ) ;
135
129
136
130
NativeMethods . DrawMenuBar ( consoleHandle ) ;
137
131
}
0 commit comments