Ejemplo n.º 1
0
        public override void OnScanFailed([GeneratedEnum] ScanFailure errorCode)
        {
            base.OnScanFailed(errorCode);

            ScanFailed?.Invoke(this, new BLEScanFailureEventArgs(errorCode));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Scans the tree to find all images, and all shortcuts to images.
        /// </summary>
        /// <param name="token"></param>
        public void Populate(CancellationToken token)
        {
            ScanStarted?.Invoke(new DirectoryScanInfo {
                Directory = DirectoryInfo
            });

            if (token.IsCancellationRequested)
            {
                return;
            }

            try
            {
                EnsureShortcutUtility();

                List <ImageItem> children = new List <ImageItem>();
                ImageItem        child;

                foreach (var file in DirectoryInfo.EnumerateFilesByExtensions(Constants.IMAGE_FILE_EXTENSIONS_PLUS_LINK))
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    child = new ImageItem(file, ShortcutUtility);

                    if (child.IsImage)
                    {
                        children.Add(child);
                    }
                }

                if (token.IsCancellationRequested)
                {
                    return;
                }

                AddDescendants(children, 0);

                EnsureBlacklist();

                foreach (var subDir in DirectoryInfo.EnumerateDirectories())
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    if (!BlacklistExcludes(subDir.FullName) && !subDir.Attributes.HasFlag(FileAttributes.System))
                    {
                        var subTreeDir = new ImageTreeDirectory(subDir, this)
                        {
                            Blacklist       = Blacklist,
                            ShortcutUtility = ShortcutUtility
                        };

                        subTreeDir.ScanStarted += ScanStarted;
                        subTreeDir.ScanFailed  += ScanFailed;

                        subTreeDir.Populate(token);

                        if (token.IsCancellationRequested)
                        {
                            return;
                        }

                        ChildDirectories.Add(subTreeDir);
                    }
                }

                IsPopulated = true;
            }
            catch (Exception ex)
            {
                ScanFailed?.Invoke(new DirectoryScanInfo {
                    Directory = DirectoryInfo, Exception = ex
                });
            }
        }
Ejemplo n.º 3
0
 private void RaiseScanFailed(BLEErrorCode code)
 => ScanFailed?.Invoke(this, new BLEErrorEventArgs(code));