private async void UpdatePreviewImage(bool reset = false) { var color = (this.Color.IsKnown) ? this.Color : Pallete.Black; var iconUrl = this.GenerateUrl(this.Icon.Group.Id, this.Icon.Id, this.XHdpi.Item.Folder, color.Name, this.Size.Value); if (this.Color.IsKnown) { this.PreviewImage = new BitmapImage(new System.Uri(iconUrl), new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable)); } else { // if icon data is is null, then cache if (this._previewImageDataInBlack == null || reset) { using (var client = new HttpClient()) this._previewImageDataInBlack = await client.GetByteArrayAsync(iconUrl); } var iconData = (byte[])this._previewImageDataInBlack.Clone(); iconData = ColorUtils.ReplaceColor(iconData, this.Color.Color); this.PreviewImage = ImageUtils.BitmapFromByteArray(iconData); } }
private async void UpdatePreviewImage() { if (IsInDesignModeStatic) { return; } var data = await this.ProjectIcon.Get(); if (data == null) { this.PreviewImage = ImageUtils.EmptyBitmap; this.Error = "Icon or size does not exists in Google's github repo"; } else { this.PreviewImage = ImageUtils.BitmapFromByteArray(data); this.Error = string.Empty; } }
private async void UpdatePreviewImage() { if (IsInDesignModeStatic) { return; } var data = await this.ProjectIcon.Get(); // TEMP solution to https://github.com/interisti/vs-material-icons-generator/issues/17 if (data == null) { this.PreviewImage = ImageUtils.EmptyBitmap; this.Error = "Icon does not exists, try another size"; } else { this.PreviewImage = ImageUtils.BitmapFromByteArray(data); this.Error = string.Empty; } }