Example #1
0
            private static string GetScaledPath(string path, HashSet <string> assets, ResolutionScale?scaleOverride)
            {
                if (!string.IsNullOrEmpty(path))
                {
                    var directory = Path.GetDirectoryName(path);
                    var filename  = Path.GetFileNameWithoutExtension(path);
                    var extension = Path.GetExtension(path);

                    var resolutionScale = scaleOverride == null ? (int)DisplayInformation.GetForCurrentView().ResolutionScale : (int)scaleOverride;

                    for (var i = KnownScales.Length - 1; i >= 0; i--)
                    {
                        var probeScale = KnownScales[i];

                        if (resolutionScale >= probeScale)
                        {
                            var filePath = Path.Combine(directory, $"{filename}.scale-{probeScale}{extension}");

                            if (assets.Contains(filePath))
                            {
                                return(!string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ?
                                       $"{UNO_BOOTSTRAP_APP_BASE}/{filePath}" :
                                       filePath);
                            }
                        }
                    }

                    return(!string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ? $"{UNO_BOOTSTRAP_APP_BASE}/{path}" : path);
                }

                return(path);
            }
Example #2
0
            private static string GetScaledPath(string path, HashSet <string> assets, ResolutionScale?scaleOverride)
            {
                if (!string.IsNullOrEmpty(path))
                {
                    var directory = Path.GetDirectoryName(path);
                    var filename  = Path.GetFileNameWithoutExtension(path);
                    var extension = Path.GetExtension(path);

                    var resolutionScale = scaleOverride == null ? (int)DisplayInformation.GetForCurrentView().ResolutionScale : (int)scaleOverride;

                    // On Windows, the minimum scale is 100%, however, on Wasm, we can have lower scales.
                    // This condition is to allow Wasm to use the .scale-100 image when the scale is < 100%
                    if (resolutionScale < 100)
                    {
                        resolutionScale = 100;
                    }


                    for (var i = KnownScales.Length - 1; i >= 0; i--)
                    {
                        var probeScale = KnownScales[i];

                        if (resolutionScale >= probeScale)
                        {
                            var filePath = Path.Combine(directory, $"{filename}.scale-{probeScale}{extension}");

                            if (assets.Contains(filePath))
                            {
                                return(AssetsPathBuilder.BuildAssetUri(filePath));
                            }
                        }
                    }

                    return(AssetsPathBuilder.BuildAssetUri(path));
                }

                return(path);
            }