Exemple #1
0
        private void LoadAutoCompleteCore(CancellationToken Token)
        {
            var CancellationTokenSource = this.CancellationTokenSource;

            try
            {
                this.CancellationTokenSource.Token.ThrowIfCancellationRequested();
                foreach (var Item in this.ExistingFileInfo.Directory.EnumerateFiles())
                {
                    this.CancellationTokenSource.Token.ThrowIfCancellationRequested();
                    if (!ImageFileUtils.IsSkippedExtension(Item.Extension))
                    {
                        this._AutoCompleteList.Add(System.IO.Path.GetFileNameWithoutExtension(Item.Name));
                    }
                }
                this.SetNearbyMatch();
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        private void LoadImagesCore(string DirectoryPath, CancellationToken CancellationToken)
        {
            this.IsLoadingFiles = true;
            try
            {
                CancellationToken.ThrowIfCancellationRequested();

                _ActiveFiles.Clear();
                this.ActiveImage = null;

                this.ZoomFit();

                System.IO.DirectoryInfo SelectedDirectory;
                try
                {
                    SelectedDirectory = new System.IO.DirectoryInfo(DirectoryPath);
                }
                catch (System.IO.IOException)
                {
                    //System.Windows.MessageBox.Show("Could not open directory: " + ex.Message);
                    return;
                }

                var NaturalStringComparer = new NaturalStringComparer();
                foreach (var FileInfo in SelectedDirectory.EnumerateFiles().OrderBy((o) => o.Name, NaturalStringComparer))
                {
                    CancellationToken.ThrowIfCancellationRequested();

                    var Decoder = ImageFileUtils.CreateDecoder(FileInfo);
                    if (Decoder == null || Decoder.Frames == null || Decoder.Frames.Count == 0 || Decoder.Frames[0].Width == 0 || Decoder.Frames[0].Height == 0)
                    {
                        continue;
                    }

                    lock (ActiveFilesLock)
                    {
                        _ActiveFiles.Add(FileInfo);
                    }
                    if (_ActiveFiles.Count == 1)
                    {
                        this.MoveToFirst();
                    }
                }
            }
            catch (OperationCanceledException)
            {
                //Ignore task cancel
                throw;
            }
            catch (Exception)
            {
                //TODO: Error handling
            }
            finally
            {
                this.IsLoadingFiles = false;
            }
        }
        private void LoadAutoCompleteCore(CancellationToken Token)
        {
            var CancellationTokenSource = this.CancellationTokenSource;

            try
            {
                this.CancellationTokenSource.Token.ThrowIfCancellationRequested();
                foreach (var Item in this.ActiveFiles)
                {
                    this.CancellationTokenSource.Token.ThrowIfCancellationRequested();
                    if (!ImageFileUtils.IsSkippedExtension(Item.Extension))
                    {
                        this._AutoCompleteList.Add(Item);
                    }
                }
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception)
            {
            }
        }