static ShadowWindow()
 {
     ActiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottom.png"));
     ActiveBottomImage.Freeze();
     ActiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomLeft.png"));
     ActiveBottomLeftImage.Freeze();
     ActiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomRight.png"));
     ActiveBottomRightImage.Freeze();
     ActiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveLeft.png"));
     ActiveLeftImage.Freeze();
     ActiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveRight.png"));
     ActiveRightImage.Freeze();
     ActiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTop.png"));
     ActiveTopImage.Freeze();
     ActiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopLeft.png"));
     ActiveTopLeftImage.Freeze();
     ActiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopRight.png"));
     ActiveTopRightImage.Freeze();
     InactiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottom.png"));
     InactiveBottomImage.Freeze();
     InactiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomLeft.png"));
     InactiveBottomLeftImage.Freeze();
     InactiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomRight.png"));
     InactiveBottomRightImage.Freeze();
     InactiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveLeft.png"));
     InactiveLeftImage.Freeze();
     InactiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveRight.png"));
     InactiveRightImage.Freeze();
     InactiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTop.png"));
     InactiveTopImage.Freeze();
     InactiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopLeft.png"));
     InactiveTopLeftImage.Freeze();
     InactiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopRight.png"));
     InactiveTopRightImage.Freeze();
 }
Пример #2
0
        public ProcessInfo(Process rpProcess)
        {
            ID = rpProcess.Id;

            Name = rpProcess.ProcessName;

            var rInfo = rpProcess.MainModule.FileVersionInfo;
            if (rInfo.FileDescription != Name)
            Description = rInfo.FileDescription;

            NativeStructs.SHFILEINFO rFileInfo;
            NativeMethods.Shell32.SHGetFileInfoW(rInfo.FileName, 0, out rFileInfo, Marshal.SizeOf(typeof(NativeStructs.SHFILEINFO)), NativeEnums.SHGFI.SHGFI_ICON);

            Icon = Imaging.CreateBitmapSourceFromHIcon(rFileInfo.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            Icon.Freeze();

            if (rFileInfo.hIcon != IntPtr.Zero)
                NativeMethods.User32.DestroyIcon(rFileInfo.hIcon);
        }
Пример #3
0
        public void Load()
        {
            try
            {
                _asyncSource = new BitmapImage(new Uri(filename));
                _asyncSource.Freeze();

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
                {
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AsyncSource"));

                    if (loaded != null)
                        loaded();
                });
            }
            catch (Exception ex)
            {
                Logger.Error("An error has occured while trying to create an AsyncThumbnailImage. Filename = {0} Exception = {1}", LogSource.BackgroundTask, filename, ex);
            }
        }
        public void Load()
        {
            try
            {
                // If we have a loading function, use that to get the url we want to load
                if (loading != null)
                    this.url = loading();

                // We explicitly use the WebClient here because we need access to the system-wide browser cache and cookies collection
                var client = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable) };

                var stream = new MemoryStream();

                using (var istream = client.OpenRead(url))
                {
                    // Read stream into our own byte buffer on the background thread
                    istream.CopyTo(stream);
                    stream.Seek(0, SeekOrigin.Begin);
                }

                var headers = client.ResponseHeaders;

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
                    {
                        try
                        {
                            // Create imagesource on the foreground thread
                            string extension = Path.GetExtension(url).ToLower();
                            BitmapDecoder decoder = null;

                            if (extension == ".gif")
                                decoder = new GifBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                            else if (extension == ".png")
                                decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                            else if (extension == ".jpg" || extension == ".jpeg")
                                decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                            else if (extension == ".bmp")
                                decoder = new BmpBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                            else
                            {
                                // We are not sure what extension we are looking at, lets see if there is a content-type available
                                if (headers["Content-Type"] != null)
                                {
                                    var type = headers["Content-Type"];

                                    if (type.IndexOf("gif", StringComparison.InvariantCultureIgnoreCase) > -1)
                                        decoder = new GifBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                                    else if (type.IndexOf("png", StringComparison.InvariantCultureIgnoreCase) > -1)
                                        decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                                    else if (type.IndexOf("jpg", StringComparison.InvariantCultureIgnoreCase) > -1 || type.IndexOf("jpeg", StringComparison.InvariantCultureIgnoreCase) > -1)
                                        decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                                    else if (type.IndexOf("bmp", StringComparison.InvariantCultureIgnoreCase) > -1)
                                        decoder = new BmpBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                                }
                            }

                            if (decoder == null)
                            {
                                Logger.Error("Unable to determine type of image to decode. url = {0}", LogSource.BackgroundTask, url);
                                return;
                            }

                            _asyncSource = decoder.Frames[0];
                            _asyncSource.Freeze();

                            if (PropertyChanged != null)
                                PropertyChanged(this, new PropertyChangedEventArgs("AsyncSource"));

                            if (loaded != null)
                                loaded();
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("An error has occured while trying to download an AsyncHttpImage. Url = {0} Exception = {1}", LogSource.BackgroundTask, url, ex);
                        }
                        finally
                        {
                            stream.Dispose();
                        }
                    });

            }
            catch (Exception ex)
            {
                Logger.Error("An error has occured while trying to download an AsyncHttpImage. Url = {0} Exception = {1}", LogSource.BackgroundTask, url, ex);
            }
        }
Пример #5
0
 /// <summary>
 /// Extracts 16*16 icon when ImageContainer is constructed with PowerItem data
 /// </summary>
 public void ExtractSmall()
 {
     if (_smallBitmap != null)
         return;
     var smallIconHandle = GetUnmanagedIcon(API.Shgfi.SMALLICON);
     if (smallIconHandle != IntPtr.Zero)
     {
         SmallBitmap = ExtractInternal(smallIconHandle);
         SmallBitmap.Freeze();
         Util.PostBackgroundIconDestroy(smallIconHandle);
     }
     #if DEBUG
     else
     {
         Log.Raw("FAILED with code " + Marshal.GetLastWin32Error(), _initialObject);
     }
     #endif
     _smallExtracted = true;
 }