public ImageSource GetIconImage(string fastKey, string key, IconSize size, bool delayLoading)
        {
            string extKey = KeyToExtKey(key, size);
            if (!iconDic.ContainsKey(extKey))
                if (delayLoading)
                {
                    WriteableBitmap bitmap = new WriteableBitmap(loadBitmap(KeyToBitmap(fastKey, size)));
                    thumbnailInfo info = new thumbnailInfo(bitmap, key, size, currentRoll);
                    if (size == IconSize.thumbnail)
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PollThumbnailCallback), info);
                    else ThreadPool.QueueUserWorkItem(new WaitCallback(PollIconCallback), info);

                    iconDic.Add(extKey, bitmap);
                }
                else
                    iconDic.Add(extKey, loadBitmap(KeyToBitmap(key, size)));
            return iconDic[extKey];
        }
        public ImageSource GetIconImage(string fastKey, string key, IconSize size, bool delayLoading)
        {
            string extKey = KeyToExtKey(key, size);
            string ext = Path.GetExtension(key);
            string fastExtKey = KeyToExtKey(fastKey, size);

            bool isImage = !String.IsNullOrEmpty(ext) &&
                imageFilter.IndexOf(ext, StringComparison.InvariantCultureIgnoreCase) != -1;
            delayLoading = delayLoading && ((isImage && (int)size >= (int)IconSize.extraLarge) || !isImage);

            //!!! +AK Поставлено принудительно, т.к. иначе при первом запуске возвращает одинаковую иконку(папку) для всех файлов
            //Видимо, значение в iconDic не успевает подмениться
            delayLoading = false;//
            //0.4
            //Fixed Small Image Icon not shared by all instance
            if (isImage && size == IconSize.small)
                extKey = ext.ToLower();

            if (!iconDic.ContainsKey(extKey))
            {
                if (delayLoading)
                {
                    WriteableBitmap bitmap = new WriteableBitmap(
                        iconDic.ContainsKey(fastExtKey) ? iconDic[fastExtKey] : loadBitmap(KeyToBitmap(fastKey, size)));
                    thumbnailInfo info = new thumbnailInfo(bitmap, key, size, new System.Drawing.Size(bitmap.PixelWidth, bitmap.PixelHeight), currentRoll);

                    if (isImage)
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PollThumbnailCallback), info);
                    else
                    ////Не работает PollIconCallback(info);
                    {
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PollIconCallback), info);
                        _ev.WaitOne();
                    }
                    iconDic.Add(extKey, bitmap);
                }
                else
                    iconDic.Add(extKey, loadBitmap(KeyToBitmap(isImage ? fastKey : key, size)));
            }

            return iconDic[extKey];
        }
Exemplo n.º 3
0
        public ImageSource GetIconImage(string fastKey, string key, IconSize size, bool delayLoading)
        {
            string extKey = KeyToExtKey(key, size);
            string ext = Path.GetExtension(key);
            string fastExtKey = KeyToExtKey(fastKey, size);

            bool isImage = !String.IsNullOrEmpty(ext) &&
                imageFilter.IndexOf(ext, StringComparison.InvariantCultureIgnoreCase) != -1;
            delayLoading = delayLoading && ((isImage && (int)size >= (int)IconSize.extraLarge) || !isImage);

            //0.4
            //Fixed Small Image Icon not shared by all instance
            if (isImage && size == IconSize.small)
                extKey = ext.ToLower();

            if (!iconDic.ContainsKey(extKey))
            {
                if (delayLoading)
                {
                    WriteableBitmap bitmap = new WriteableBitmap(
                        iconDic.ContainsKey(fastExtKey) ? iconDic[fastExtKey] : loadBitmap(KeyToBitmap(fastKey, size)));
                    thumbnailInfo info = new thumbnailInfo(bitmap, key, size, new System.Drawing.Size(bitmap.PixelWidth, bitmap.PixelHeight), currentRoll);

                    if (isImage)
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PollThumbnailCallback), info);
                    else
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PollIconCallback), info);

                    iconDic.Add(extKey, bitmap);
                }
                else
                    iconDic.Add(extKey, loadBitmap(KeyToBitmap(isImage ? fastKey : key, size)));
            }

            return iconDic[extKey];
        }