/// <summary>
        /// Display file system objects in the path as thumbnails, or open viewer depending on the file type and parameters.
        /// Main open logic is set here.
        /// Support cancellation. Used in Task.
        /// </summary>
        internal void LoadPath(ObjectInfo objInfo, ViewWindow viewWin = null)
        {
            // action based on flags
            if (objInfo.Flags.HasFlag(FileFlags.Directory))
            {
                //directory -> load thumbs
                try {
                    tknSrc_LoadThumb?.Cancel();
                    Monitor.Enter(lock_LoadThumb);
                    tknSrc_LoadThumb = new CancellationTokenSource();
                    preRefreshActions();
                    CurrentPath = objInfo.FileSystemPath;
                    foreach (var childInfo in new DirectoryInfo(objInfo.FileSystemPath).EnumerateFileSystemInfos())
                    {
                        if (tknSrc_LoadThumb?.IsCancellationRequested == true)
                        {
                            return;
                        }

                        var flag = GetPathType(childInfo);
                        callback_AddToImageList(new ObjectInfo(childInfo.FullName, flag, childInfo.Name));
                    }
                    Dispatcher.Invoke(() => scrollPosition());
                }
                finally {
                    tknSrc_LoadThumb.Dispose();
                    tknSrc_LoadThumb = null;
                    Monitor.Exit(lock_LoadThumb);
                }
            }
            else if (objInfo.Flags.HasFlag(FileFlags.Image))
            {
                //plain image file or image inside archive -> open viewer
                //using a new ObjectInfo to avoid confusion and reduce chance of holding ImageSource
                Dispatcher.Invoke(() => {
                    if (viewWin == null)
                    {
                        new ViewWindow(objInfo.ContainerPath, objInfo.FileName).Show();
                    }
                    else
                    {
                        viewWin.ViewPath = (objInfo.ContainerPath, objInfo.FileName);
                    }
                });
            }
            else if (objInfo.Flags.HasFlag(FileFlags.Archive))
            {
                //archive itself -> extract and load thumbs
                try {
                    tknSrc_LoadThumb?.Cancel();
                    Monitor.Enter(lock_LoadThumb);
                    tknSrc_LoadThumb = new CancellationTokenSource();
                    preRefreshActions();
                    CurrentPath = objInfo.FileSystemPath;
                    ExtractZip(new LoadOptions(objInfo.FileSystemPath)
                    {
                        Flags           = objInfo.Flags,
                        LoadImage       = true,
                        DecodeSize      = (SizeInt)Setting.ThumbnailSize,
                        CldInfoCallback = callback_AddToImageList,
                    }, tknSrc_LoadThumb);
                    Dispatcher.Invoke(() => scrollPosition());
                }
                finally {
                    tknSrc_LoadThumb.Dispose();
                    tknSrc_LoadThumb = null;
                    Monitor.Exit(lock_LoadThumb);
                }
            }
        }
 /// <summary>
 /// Display file system objects in the path as thumbnails, or open viewer depending on the file type and parameters.
 /// Main open logic is set here.
 /// Support cancellation. Used in Task.
 /// Flags are inferred from path. Not for opening image in an archive.
 /// </summary>
 internal void LoadPath(string path, ViewWindow viewWin = null)
 {
     LoadPath(new ObjectInfo(path, GetPathType(path)), viewWin);
 }