public static ParseSizeString ( string size ) : Size? | ||
size | string | |
return | Size? |
List <SharedImageInfo> ParseImageTaskItems(ITaskItem[] images) { var r = new List <SharedImageInfo>(); if (images == null) { return(r); } foreach (var image in images) { var info = new SharedImageInfo(); var fileInfo = new FileInfo(image.GetMetadata("FullPath")); info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); info.BaseSize = Utils.ParseSizeString(image.GetMetadata("BaseSize")); if (bool.TryParse(image.GetMetadata("Resize"), out var rz)) { info.Resize = rz; } info.TintColor = Utils.ParseColorString(image.GetMetadata("TintColor")); if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai)) { info.IsAppIcon = iai; } if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc)) { info.ForegroundScale = fsc; } var fgFile = image.GetMetadata("ForegroundFile"); if (!string.IsNullOrEmpty(fgFile)) { var bgFileInfo = new FileInfo(info.Filename); if (!Path.IsPathRooted(fgFile)) { fgFile = Path.Combine(bgFileInfo.Directory.FullName, fgFile); } else { fgFile = Path.GetFullPath(fgFile); } Logger.Log($"AppIcon Foreground: " + fgFile); if (File.Exists(fgFile)) { info.ForegroundFilename = fgFile; } } // TODO: // - Parse out custom DPI's r.Add(info); } return(r); }
public static List <ResizeImageInfo> Parse(IEnumerable <ITaskItem> images) { var r = new List <ResizeImageInfo>(); if (images == null) { return(r); } foreach (var image in images) { var info = new ResizeImageInfo(); var fileInfo = new FileInfo(image.GetMetadata("FullPath")); if (!fileInfo.Exists) { throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName); } info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); info.BaseSize = Utils.ParseSizeString(image.GetMetadata("BaseSize")); if (bool.TryParse(image.GetMetadata("Resize"), out var rz)) { info.Resize = rz; } else if (info.BaseSize == null && !info.IsVector) { // By default do not resize non-vector images info.Resize = false; } var tintColor = image.GetMetadata("TintColor"); info.TintColor = Utils.ParseColorString(tintColor); if (info.TintColor is null && !string.IsNullOrEmpty(tintColor)) { throw new InvalidDataException($"Unable to parse color value '{tintColor}' for '{info.Filename}'."); } var color = image.GetMetadata("Color"); info.Color = Utils.ParseColorString(color); if (info.Color is null && !string.IsNullOrEmpty(color)) { throw new InvalidDataException($"Unable to parse color value '{color}' for '{info.Filename}'."); } if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai)) { info.IsAppIcon = iai; } if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc)) { info.ForegroundScale = fsc; } var fgFile = image.GetMetadata("ForegroundFile"); if (!string.IsNullOrEmpty(fgFile)) { var fgFileInfo = new FileInfo(fgFile); if (!fgFileInfo.Exists) { throw new FileNotFoundException("Unable to find foreground file: " + fgFileInfo.FullName, fgFileInfo.FullName); } info.ForegroundFilename = fgFileInfo.FullName; } // make sure the image is a foreground if this is an icon if (info.IsAppIcon && string.IsNullOrEmpty(info.ForegroundFilename)) { info.ForegroundFilename = info.Filename; info.Filename = null; } // TODO: // - Parse out custom DPI's r.Add(info); } return(r); }
List <SharedImageInfo> ParseImageTaskItems(ITaskItem[] images) { var r = new List <SharedImageInfo>(); if (images == null) { return(r); } foreach (var image in images) { var info = new SharedImageInfo(); var fileInfo = new FileInfo(image.GetMetadata("FullPath")); if (!fileInfo.Exists) { throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName); } info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); info.BaseSize = Utils.ParseSizeString(image.GetMetadata("BaseSize")); if (bool.TryParse(image.GetMetadata("Resize"), out var rz)) { info.Resize = rz; } info.TintColor = Utils.ParseColorString(image.GetMetadata("TintColor")); if (bool.TryParse(image.GetMetadata("IsAppIcon"), out var iai)) { info.IsAppIcon = iai; } if (float.TryParse(image.GetMetadata("ForegroundScale"), out var fsc)) { info.ForegroundScale = fsc; } var fgFile = image.GetMetadata("ForegroundFile"); if (!string.IsNullOrEmpty(fgFile)) { var fgFileInfo = new FileInfo(fgFile); if (!fgFileInfo.Exists) { throw new FileNotFoundException("Unable to find foreground file: " + fgFileInfo.FullName, fgFileInfo.FullName); } info.ForegroundFilename = fgFileInfo.FullName; } // TODO: // - Parse out custom DPI's r.Add(info); } return(r); }