@@ -41,6 +41,8 @@ public class InitializationOptions
41
41
public PlatformType PlatformType { get ; set ; }
42
42
public bool UseMessagingCenter { get ; set ; } = true ;
43
43
44
+ public DisplayResolutionUnit DisplayResolutionUnit { get ; set ; }
45
+
44
46
public struct EffectScope
45
47
{
46
48
public string Name ;
@@ -163,9 +165,31 @@ public TizenDeviceInfo()
163
165
TSystemInfo . TryGetValue ( "http://tizen.org/feature/screen.height" , out height ) ;
164
166
165
167
scalingFactor = 1.0 ; // scaling is disabled, we're using pixels as Xamarin's geometry units
166
- if ( s_useDeviceIndependentPixel )
168
+ if ( DisplayResolutionUnit . UseVP && DisplayResolutionUnit . ViewportWidth > 0 )
167
169
{
168
- scalingFactor = s_dpi . Value / 160.0 ;
170
+ scalingFactor = width / DisplayResolutionUnit . ViewportWidth ;
171
+ }
172
+ else
173
+ {
174
+ if ( DisplayResolutionUnit . UseDP )
175
+ {
176
+ scalingFactor = s_dpi . Value / 160.0 ;
177
+ }
178
+
179
+ if ( DisplayResolutionUnit . UseDeviceScale )
180
+ {
181
+ var physicalScale = s_dpi . Value / 160.0 ;
182
+
183
+ var portraitSize = ( Math . Min ( width , height ) ) / physicalScale ;
184
+ if ( portraitSize > 2000 )
185
+ {
186
+ scalingFactor *= 4 ;
187
+ }
188
+ else if ( portraitSize > 1000 )
189
+ {
190
+ scalingFactor *= 2.5 ;
191
+ }
192
+ }
169
193
}
170
194
171
195
pixelScreenSize = new Size ( width , height ) ;
@@ -174,8 +198,6 @@ public TizenDeviceInfo()
174
198
}
175
199
}
176
200
177
- static bool s_useDeviceIndependentPixel = false ;
178
-
179
201
static StaticRegistrarStrategy s_staticRegistrarStrategy = StaticRegistrarStrategy . None ;
180
202
181
203
static PlatformType s_platformType = PlatformType . Defalut ;
@@ -222,6 +244,8 @@ public static bool IsInitialized
222
244
223
245
public static bool UseMessagingCenter => s_useMessagingCenter ;
224
246
247
+ public static DisplayResolutionUnit DisplayResolutionUnit { get ; private set ; }
248
+
225
249
internal static TizenTitleBarVisibility TitleBarVisibility
226
250
{
227
251
get ;
@@ -348,13 +372,24 @@ public static void Init(CoreApplication application)
348
372
349
373
public static void Init ( CoreApplication application , bool useDeviceIndependentPixel )
350
374
{
351
- s_useDeviceIndependentPixel = useDeviceIndependentPixel ;
375
+ DisplayResolutionUnit = DisplayResolutionUnit . FromInit ( useDeviceIndependentPixel ) ;
376
+ SetupInit ( application ) ;
377
+ }
378
+
379
+ public static void Init ( CoreApplication application , DisplayResolutionUnit unit )
380
+ {
381
+ DisplayResolutionUnit = unit ?? DisplayResolutionUnit . Pixel ( ) ;
352
382
SetupInit ( application ) ;
353
383
}
354
384
355
385
public static void Init ( InitializationOptions options )
356
386
{
357
- s_useDeviceIndependentPixel = options ? . UseDeviceIndependentPixel ?? false ;
387
+ if ( options == null )
388
+ {
389
+ throw new ArgumentException ( "Must be set options" , nameof ( options ) ) ;
390
+ }
391
+
392
+ DisplayResolutionUnit = options . DisplayResolutionUnit ?? DisplayResolutionUnit . FromInit ( options . UseDeviceIndependentPixel ) ;
358
393
SetupInit ( options . Context , options ) ;
359
394
}
360
395
0 commit comments