//! \brief get image accoriding to current state public System.Windows.Controls.Image GetImage() { try { this.Validate(); switch (state_) { case State.busy: case State.failed: string imgName = ExtensionContext.ConstExtensionImgResName; imgName += state_ == State.failed ? "error.png" : "refresh.png"; System.Reflection.Assembly thisAss = System.Reflection.Assembly.GetExecutingAssembly(); //var resNames = thisAss.GetManifestResourceNames(); System.IO.Stream fileStream = thisAss.GetManifestResourceStream(imgName); var img = new System.Windows.Controls.Image(); System.Windows.Media.Imaging.PngBitmapDecoder decoder = new System.Windows.Media.Imaging.PngBitmapDecoder(fileStream, System.Windows.Media.Imaging.BitmapCreateOptions.PreservePixelFormat, System.Windows.Media.Imaging.BitmapCacheOption.Default); img.Source = decoder.Frames[0]; return(img); case State.valid: return(this.GetValidImage()); } } catch { } return(null); }
LoadPNGImageFromResource(string imageResourceName) { System.Reflection.Assembly dotNetAssembly = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream iconStream = dotNetAssembly.GetManifestResourceStream(imageResourceName); System.Windows.Media.Imaging.PngBitmapDecoder bitmapDecoder = new System.Windows.Media.Imaging.PngBitmapDecoder(iconStream, System.Windows.Media.Imaging.BitmapCreateOptions. PreservePixelFormat, System.Windows.Media.Imaging. BitmapCacheOption.Default); System.Windows.Media.ImageSource imageSource = bitmapDecoder.Frames[0]; return(imageSource); }
LoadPNGImageFromResource(string imageResourceName) { System.Reflection.Assembly dotNetAssembly = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream iconStream = dotNetAssembly.GetManifestResourceStream(imageResourceName); System.Windows.Media.Imaging.PngBitmapDecoder bitmapDecoder = new System.Windows.Media.Imaging.PngBitmapDecoder(iconStream, System.Windows.Media.Imaging.BitmapCreateOptions. PreservePixelFormat, System.Windows.Media.Imaging. BitmapCacheOption.Default); System.Windows.Media.ImageSource imageSource = bitmapDecoder.Frames[0]; return imageSource; }