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); }
public Local(string?name, string path) : base(path) { if (string.IsNullOrEmpty(name)) { if (!path.EndsWith("/")) { // Intentionally use GetFileName here, as the directory name // may be a "file-like name" e.g. myfolder.txt, in which case // GetDirectoryName would actually return the parent. name = IOPath.GetFileName(path); } else { name = IOPath.GetDirectoryName(path); } } _name = name ?? string.Empty; }
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); }