public bool LoadDirectories(IEnumerable <string> paths)
        {
            IsLoading               = false;
            MainDispatcher          = Dispatcher.CurrentDispatcher;
            cancellationTokenSource = new CancellationTokenSource();
            cancellationToken       = cancellationTokenSource.Token;

            cache        = DefaultFactory.GetDefaultThumbnailCache();
            userSettings = DefaultFactory.GetDefaultUserSettings();
            renderType   = (RenderAspectEnum)userSettings.GetSettingInt(UserSettingEnum.Thumbnails3DAspect);

            logger.Info("Loading paths: Received: [{0}]", string.Join("] [", paths));
            paths = paths.Where(p1 => !paths.Any(p2 => !p1.Equals(p2) && p1.Contains(p2))).ToArray(); // Remove selected subdirectories of other selected paths.
            logger.Info("Loading paths: After removed subdirs: [{0}]", string.Join("] [", paths));

            try
            {
                IEnumerable <string> pathsFound = new List <string>();
                for (int i = 0; i < SupportedExtensionsFilter.Length; i++)
                {
                    foreach (string path in paths)
                    {
                        pathsFound = pathsFound.Concat(UtilMethods.EnumerateFiles(path, SupportedExtensionsFilter[i], SearchOption.AllDirectories, cancellationToken));
                    }
                }
                pathsFound = pathsFound.ToArray();

                if (cancellationToken.IsCancellationRequested)
                {
                    return(false);
                }

                if (pathsFound.Count() > 0)
                {
                    CalculateThumnailSizes(pathsFound.Count());
                    InitializeFoundFilesObjects(pathsFound);
                    return(true);
                }
                else
                {
                    FilesFound = new ModelFileData[0];
                }
            }
            catch (Exception ex)
            {
                logger.Trace(ex, "Unable to load: {ex}", ex.Message);
            }
            return(false);
        }
Esempio n. 2
0
 public ModelCacheInfo()
 {
     cacheObject = DefaultFactory.GetDefaultThumbnailCache();
 }