public static string GetUrlWithSize(this ImageArchive imageArchive, WallpaperSize size) { if (imageArchive == null) { return(null); } return(string.Format("http://www.bing.com{0}_{1}.jpg", imageArchive.UrlBase, size.GetName())); }
public string GetCacheUrl(WallpaperSize size) { if(WallpaperSize.SupportWallpaperSizes.Contains(size)== false) { throw new ArgumentException("7niu cache not support.",nameof(size)); } return "http://7u2lw5.com5.z0.glb.clouddn.com" + Image.UrlBase + "_" + size.ToString() + ".jpg"; }
public string GetUrl(IImage image, WallpaperSize size) { if (image == null) { throw new ArgumentNullException(nameof(image)); } if (!GetSupportedWallpaperSizes().Contains(size)) { throw new NotSupportedException(); } return($"{Constants.ImageUrlBase}{image.UrlBase}_{size.Width}x{size.Height}.jpg"); }
public object Convert(object value, Type targetType, object parameter, string language) { if (value == null) { return(null); } WallpaperSize wallpaperSize = (WallpaperSize)value; string name = wallpaperSize.GetName(); if (wallpaperSize == WallpaperSizeHelper.GetDefaultSize()) { name = name + ResourcesHelper.Default; } return(name); }
/// <summary> /// 初始化最适合壁纸大小。 /// </summary> /// <returns></returns> private async Task InitSuitableWallpaperSize() { await SuitableWallpaperSize.InitAsync(); WallpaperSize wallpaperSize = AppSetting.WallpaperSize; if (wallpaperSize == null) { wallpaperSize = new WallpaperSize(SuitableWallpaperSize.Width, SuitableWallpaperSize.Height); if (WallpaperSize.SupportWallpaperSizes.Contains(wallpaperSize)) { AppSetting.WallpaperSize = wallpaperSize; } else { AppSetting.WallpaperSize = new WallpaperSize(480, 800); } } }
public string GetOriginalUrl(WallpaperSize size) { return "http://www.bing.com" + Image.UrlBase + "_" + size.ToString() + ".jpg"; }
public static string GetName(this WallpaperSize size) { return(size.ToString().TrimStart('_')); }
public static double GetHeight(this WallpaperSize size) { return(int.Parse(size.GetName().Split('x')[1])); }
public static int GetWidth(this WallpaperSize size) { return(int.Parse(size.GetName().Split('x')[0])); }