예제 #1
0
파일: IconManager.cs 프로젝트: svebal/unp4k
        public static ImageSource GetCachedFolderIcon(String path, IconSize iconSize, FolderType folderType)
        {
            var cache = iconSize == IconSize.Large ? _largeIconCache : _smallIconCache;

            ImageSource icon;

            var cacheKey = $"{path}:{folderType}";

            if (cache.TryGetValue(cacheKey, out icon))
            {
                return(icon);
            }

            icon = IconManager.GetFolderIcon(path, iconSize, folderType).ToImageSource();

            cache.Add(cacheKey, icon);

            return(icon);
        }
예제 #2
0
파일: IconManager.cs 프로젝트: svebal/unp4k
        public static ImageSource GetCachedFileIcon(String path, IconSize iconSize, Boolean linkOverlay = false)
        {
            var cache = iconSize == IconSize.Large ? _largeIconCache : _smallIconCache;

            ImageSource icon;

            var cacheKey = Path.GetExtension(path);

            if (cacheKey == null)
            {
                return(null);
            }

            if (cache.TryGetValue(cacheKey, out icon))
            {
                return(icon);
            }

            icon = IconManager.GetFileIcon(path, iconSize, linkOverlay).ToImageSource();

            cache.Add(cacheKey, icon);

            return(icon);
        }
예제 #3
0
        public ArchiveExplorer()
        {
            ArchiveExplorer._instance = this;

            InitializeComponent();

            this.Icon = IconManager.GetCachedFileIcon("data.zip", IconManager.IconSize.Large);

            trvFileExploder.Focus();

            new Thread(async() =>
            {
                while (true)
                {
                    await Task.Delay(FILTER_PING);

                    while (this._lastFilterText != this._activeFilterText)
                    {
                        var now = this._lastFilterTime ?? DateTime.Now;

                        while ((DateTime.Now - now).TotalMilliseconds < FILTER_DELAY)
                        {
                            await Task.Delay(FILTER_PING);
                            now = this._lastFilterTime ?? DateTime.Now;
                        }

                        if (this._root != null)
                        {
                            var filterText = this._lastFilterText;

                            var sw = new Stopwatch();

                            sw.Start();

                            var allChildren = this._root.AllChildren.ToArray();

                            await this.Dispatcher.Invoke(async() =>
                            {
                                foreach (var child in allChildren)
                                {
                                    child.IsHidden = !this.Filter(child);
                                }
                            });

                            // await this.NotifyNodesAsync(this._root);

                            sw.Stop();

                            await ArchiveExplorer.UpdateStatus($"Filter took {sw.ElapsedMilliseconds:#,##0}ms");

                            this._activeFilterText = filterText;
                        }

                        await Task.Delay(FILTER_PING);
                    }
                }
            }).Start();

            new Thread(async() =>
            {
                while (true)
                {
                    await this.Dispatcher.Invoke(async() =>
                    {
                        await ArchiveExplorer._updateDelegate(this.barProgress);
                    });

                    await Task.Delay(100);
                }
            }).Start();
        }