/// <summary>Constructs the <see cref="ImagesServiceBase"/>.</summary> public ImagesServiceBase(BitmapFactory bitmapFactory, UIService ui) { BitmapFactory = bitmapFactory; UI = ui; UI.Invoke(() => { // Load file type icons with a different method FileCollection = LoadFileIcon(nameof(FileCollection)); FreeSpace = LoadFileIcon(nameof(FreeSpace)); UnknownSpace = LoadFileIcon(nameof(UnknownSpace)); Missing = LoadFileIcon(nameof(Missing)); // Load all unassigned icons with reflection foreach (PropertyInfo propInfo in typeof(ImagesServiceBase).GetProperties()) { if (propInfo.PropertyType == typeof(ImageSource) && propInfo.CanWrite) { ImageSource value = (ImageSource)propInfo.GetValue(this); if (value != null) { continue; } value = LoadIcon(propInfo.Name); propInfo.SetValue(this, value); } } }); }
/// <summary>Creates a new writeable bitmap.</summary> /// /// <param name="size">The size of the bitmap.</param> /// <returns>The new writeable bitmap.</returns> public WriteableBitmap CreateBitmap(Point2I size) { return(ui.Invoke(() => new WriteableBitmap(size.X, size.Y, 96, 96, PixelFormats.Bgra32, null))); }