@@ -295,33 +295,42 @@ public override void InitSettingSubscribe()
295295
296296 protected override ActiveUserRecordDTO GetActiveUserRecord ( )
297297 {
298- #if ! __MOBILE__ && ! MAUI
299- var app = UI . App . Instance ;
300- var window = app . GetFirstOrDefaultWindow ( ) ;
301- var screens = window ? . Screens ;
302- #else
303- var mainDisplayInfo = DeviceDisplay . MainDisplayInfo ;
304- var mainDisplayInfoH = mainDisplayInfo . Height . ToInt32 ( NumberToInt32Format . Ceiling ) ;
305- var mainDisplayInfoW = mainDisplayInfo . Width . ToInt32 ( NumberToInt32Format . Ceiling ) ;
306- #endif
307298 var result = new ActiveUserRecordDTO
308299 {
309- #if __MOBILE__ || MAUI
310- ScreenCount = 1 ,
311- PrimaryScreenPixelDensity = mainDisplayInfo . Density ,
312- PrimaryScreenWidth = mainDisplayInfoW ,
313- PrimaryScreenHeight = mainDisplayInfoH ,
314- SumScreenWidth = mainDisplayInfoW ,
315- SumScreenHeight = mainDisplayInfoH ,
300+ } ;
301+ SetScreen ( result ) ;
302+ static void SetScreen ( ActiveUserRecordDTO m )
303+ {
304+ try
305+ {
306+ #if ! __MOBILE__ && ! MAUI
307+ var app = UI . App . Instance ;
308+ var window = app . GetFirstOrDefaultWindow ( ) ;
309+ var screens = window ? . Screens ;
310+
311+ m . ScreenCount = screens ? . ScreenCount ?? default ;
312+ m . PrimaryScreenPixelDensity = screens ? . Primary ? . Scaling ?? default ;
313+ m . PrimaryScreenWidth = screens ? . Primary ? . Bounds . Width ?? default ;
314+ m . PrimaryScreenHeight = screens ? . Primary ? . Bounds . Height ?? default ;
315+ m . SumScreenWidth = screens ? . All ? . Sum ( x => x . Bounds . Width ) ?? default ;
316+ m . SumScreenHeight = screens ? . All ? . Sum ( x => x . Bounds . Height ) ?? default ;
316317#else
317- ScreenCount = screens ? . ScreenCount ?? default ,
318- PrimaryScreenPixelDensity = screens ? . Primary ? . Scaling ?? default ,
319- PrimaryScreenWidth = screens ? . Primary ? . Bounds . Width ?? default ,
320- PrimaryScreenHeight = screens ? . Primary ? . Bounds . Height ?? default ,
321- SumScreenWidth = screens ? . All . Sum ( x => x . Bounds . Width ) ?? default ,
322- SumScreenHeight = screens ? . All . Sum ( x => x . Bounds . Height ) ?? default ,
318+ var mainDisplayInfo = DeviceDisplay . MainDisplayInfo ;
319+ var mainDisplayInfoH = mainDisplayInfo . Height . ToInt32 ( NumberToInt32Format . Ceiling ) ;
320+ var mainDisplayInfoW = mainDisplayInfo . Width . ToInt32 ( NumberToInt32Format . Ceiling ) ;
321+
322+ m . ScreenCount = 1 ;
323+ m . PrimaryScreenPixelDensity = mainDisplayInfo . Density ;
324+ m . PrimaryScreenWidth = mainDisplayInfoW ;
325+ m . PrimaryScreenHeight = mainDisplayInfoH ;
326+ m . SumScreenWidth = mainDisplayInfoW ;
327+ m . SumScreenHeight = mainDisplayInfoH ;
323328#endif
324- } ;
329+ }
330+ catch
331+ {
332+ }
333+ }
325334 return result ;
326335 }
327336}
0 commit comments