@@ -75,15 +75,75 @@ public BlazorDesktopWindow(IServiceProvider services, IConfiguration config, IWe
7575
7676 private void InitializeWindow ( )
7777 {
78+ var height = _config . GetValue < int ? > ( WindowDefaults . Height ) ?? 768 ;
79+ var width = _config . GetValue < int ? > ( WindowDefaults . Width ) ?? 1366 ;
80+ var minHeight = _config . GetValue < int ? > ( WindowDefaults . MinHeight ) ?? 0 ;
81+ var minWidth = _config . GetValue < int ? > ( WindowDefaults . MinWidth ) ?? 0 ;
82+ var maxHeight = _config . GetValue < int ? > ( WindowDefaults . MaxHeight ) ?? double . PositiveInfinity ;
83+ var maxWidth = _config . GetValue < int ? > ( WindowDefaults . MaxWidth ) ?? double . PositiveInfinity ;
84+
85+ var useFrame = _config . GetValue < bool ? > ( WindowDefaults . Frame ) ?? true ;
86+
87+ if ( useFrame )
88+ {
89+ height += 7 ;
90+ width += 14 ;
91+
92+ if ( minHeight != 0 )
93+ {
94+ minHeight += 7 ;
95+ }
96+
97+ if ( minWidth != 0 )
98+ {
99+ minWidth += 14 ;
100+ }
101+
102+ if ( maxHeight != double . PositiveInfinity )
103+ {
104+ maxHeight += 7 ;
105+ }
106+
107+ if ( maxWidth != double . PositiveInfinity )
108+ {
109+ maxWidth += 14 ;
110+ }
111+ }
112+ else
113+ {
114+ height += 3 ;
115+ width += 6 ;
116+
117+ if ( minHeight != 0 )
118+ {
119+ minHeight += 3 ;
120+ }
121+
122+ if ( minWidth != 0 )
123+ {
124+ minWidth += 6 ;
125+ }
126+
127+ if ( maxHeight != double . PositiveInfinity )
128+ {
129+ maxHeight += 3 ;
130+ }
131+
132+ if ( maxWidth != double . PositiveInfinity )
133+ {
134+ maxWidth += 6 ;
135+ }
136+ }
137+
78138 Name = "BlazorDesktopWindow" ;
79139 Title = _config . GetValue < string ? > ( WindowDefaults . Title ) ?? _environment . ApplicationName ;
80- Height = _config . GetValue < int ? > ( WindowDefaults . Height ) ?? 768 ;
81- Width = _config . GetValue < int ? > ( WindowDefaults . Width ) ?? 1366 ;
82- MinHeight = _config . GetValue < int ? > ( WindowDefaults . MinHeight ) ?? 0 ;
83- MinWidth = _config . GetValue < int ? > ( WindowDefaults . MinWidth ) ?? 0 ;
84- MaxHeight = _config . GetValue < int ? > ( WindowDefaults . MaxHeight ) ?? double . PositiveInfinity ;
85- MaxWidth = _config . GetValue < int ? > ( WindowDefaults . MaxWidth ) ?? double . PositiveInfinity ;
86- UseFrame ( _config . GetValue < bool ? > ( WindowDefaults . Frame ) ?? true ) ;
140+ Height = height ;
141+ Width = width ;
142+ MinHeight = minHeight ;
143+ MinWidth = minWidth ;
144+ MaxHeight = maxHeight ;
145+ MaxWidth = maxWidth ;
146+ UseFrame ( useFrame ) ;
87147 ResizeMode = ( _config . GetValue < bool ? > ( WindowDefaults . Resizable ) ?? true ) ? ResizeMode . CanResize : ResizeMode . NoResize ;
88148 UseIcon ( _config . GetValue < string ? > ( WindowDefaults . Icon ) ?? string . Empty ) ;
89149 Content = WebViewBorder ;
@@ -93,8 +153,9 @@ private void InitializeWindow()
93153 private void InitializeWebViewBorder ( )
94154 {
95155 WebViewBorder . Name = "BlazorDesktopWebViewBorder" ;
96- WebViewBorder . BorderThickness = new Thickness ( 0 , 0 , 0 , 0 ) ;
97156 WebViewBorder . Child = WebView ;
157+
158+ UpdateWebViewBorderThickness ( ) ;
98159 }
99160
100161 private void InitializeWebView ( )
@@ -124,16 +185,7 @@ private void InitializeTheming()
124185
125186 private void WindowStateChanged ( object ? sender , EventArgs e )
126187 {
127- var useFrame = _config . GetValue < bool ? > ( WindowDefaults . Frame ) ?? true ;
128-
129- if ( WindowState == WindowState . Maximized && ! useFrame )
130- {
131- WebViewBorder . BorderThickness = new Thickness ( 8 , 8 , 8 , 0 ) ;
132- }
133- else
134- {
135- WebViewBorder . BorderThickness = new Thickness ( 0 , 0 , 0 , 0 ) ;
136- }
188+ UpdateWebViewBorderThickness ( ) ;
137189 }
138190
139191 private void WindowSourceInitialized ( object ? sender , EventArgs e )
@@ -146,6 +198,26 @@ private void ThemeChanged(UISettings sender, object args)
146198 Dispatcher . Invoke ( new ( UpdateTheme ) ) ;
147199 }
148200
201+ private void UpdateWebViewBorderThickness ( )
202+ {
203+ var useFrame = _config . GetValue < bool ? > ( WindowDefaults . Frame ) ?? true ;
204+
205+ WebViewBorder . BorderThickness = new Thickness ( 20 , 20 , 20 , 20 ) ;
206+
207+ if ( WindowState == WindowState . Maximized && ! useFrame )
208+ {
209+ WebViewBorder . BorderThickness = new Thickness ( 8 , 8 , 8 , 8 ) ;
210+ }
211+ else if ( WindowState != WindowState . Maximized && ! useFrame )
212+ {
213+ WebViewBorder . BorderThickness = new Thickness ( 3 , 0 , 3 , 3 ) ;
214+ }
215+ else
216+ {
217+ WebViewBorder . BorderThickness = new Thickness ( 0 , 0 , 0 , 0 ) ;
218+ }
219+ }
220+
149221 private void UpdateTheme ( )
150222 {
151223 if ( ShouldSystemUseDarkMode ( ) )
0 commit comments