public FolderListupPageViewModel(
            BookmarkManager bookmarkManager,
            ImageCollectionManager imageCollectionManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            SecondaryTileManager secondaryTileManager,
            FolderLastIntractItemManager folderLastIntractItemManager,
            FolderListingSettings folderListingSettings,
            OpenPageCommand openPageCommand,
            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            _bookmarkManager              = bookmarkManager;
            _imageCollectionManager       = imageCollectionManager;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
            SecondaryTileManager          = secondaryTileManager;
            _folderLastIntractItemManager = folderLastIntractItemManager;
            _folderListingSettings        = folderListingSettings;
            OpenPageCommand            = openPageCommand;
            OpenFolderItemCommand      = openFolderItemCommand;
            OpenImageViewerCommand     = openImageViewerCommand;
            OpenFolderListupCommand    = openFolderListupCommand;
            OpenWithExplorerCommand    = openWithExplorerCommand;
            SecondaryTileAddCommand    = secondaryTileAddCommand;
            SecondaryTileRemoveCommand = secondaryTileRemoveCommand;
            FolderItems      = new ObservableCollection <StorageItemViewModel>();
            ArchiveFileItems = new ObservableCollection <StorageItemViewModel>();
            EBookFileItems   = new ObservableCollection <StorageItemViewModel>();
            ImageFileItems   = new ObservableCollection <StorageItemViewModel>();

            FileItemsView        = new AdvancedCollectionView(ImageFileItems);
            SelectedFileSortType = new ReactivePropertySlim <FileSortType>(FileSortType.TitleAscending);



            FileDisplayMode       = _folderListingSettings.ToReactivePropertyAsSynchronized(x => x.FileDisplayMode);
            FolderLastIntractItem = new ReactivePropertySlim <StorageItemViewModel>();
            ImageLastIntractItem  = new ReactivePropertySlim <int>();

            /*
             * _currentQueryOptions = Observable.CombineLatest(
             *  SelectedFolderViewFirstSort,
             *  (queryType, sort) => (queryType, sort)
             *  )
             *  .Select(_ =>
             *  {
             *      var options = new QueryOptions();
             *      options.FolderDepth = FolderDepth.Shallow;
             *      options.SetPropertyPrefetch(Windows.Storage.FileProperties.PropertyPrefetchOptions.ImageProperties, Enumerable.Empty<string>());
             *      return options;
             *  })
             *  .ToReadOnlyReactivePropertySlim();
             */
        }
        public PathReferenceCountUpdateWhenSourceManagementChanged(
            IEventAggregator eventAggregator,
            SearchIndexUpdateProcessSettings settings,
            StorageItemSearchManager storageItemSearchManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager
            )
        {
            _eventAggregator              = eventAggregator;
            _settings                     = settings;
            _storageItemSearchManager     = storageItemSearchManager;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
            _ProgressEvent                = _eventAggregator.GetEvent <SearchIndexUpdateProgressEvent>();

            _eventAggregator.GetEvent <SourceStorageItemsRepository.AddedEvent>()
            .Subscribe(async args =>
            {
                if (args.StorageItem is StorageFolder)
                {
                    RegistrationUpdateIndex(args.Token);
                }
                else
                {
                    using (await _lock.LockAsync(default))
        public SearchResultPageViewModel(
            StorageItemSearchManager storageItemSearchManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            FolderListingSettings folderListingSettings,
            BookmarkManager bookmarkManager,
            ThumbnailManager thumbnailManager,
            SecondaryTileManager secondaryTileManager,

            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            _storageItemSearchManager     = storageItemSearchManager;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
            _folderListingSettings        = folderListingSettings;
            _bookmarkManager           = bookmarkManager;
            _thumbnailManager          = thumbnailManager;
            SecondaryTileManager       = secondaryTileManager;
            OpenFolderItemCommand      = openFolderItemCommand;
            OpenImageViewerCommand     = openImageViewerCommand;
            OpenFolderListupCommand    = openFolderListupCommand;
            OpenWithExplorerCommand    = openWithExplorerCommand;
            SecondaryTileAddCommand    = secondaryTileAddCommand;
            SecondaryTileRemoveCommand = secondaryTileRemoveCommand;
        }
        public StorageItemSearchManager(
            StorageItemSearchRepository storageItemSearchRepository,
            IEventAggregator eventAggregator,

            SourceFolders.SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager
            )
        {
            _storageItemSearchRepository  = storageItemSearchRepository;
            _eventAggregator              = eventAggregator;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _PathReferenceCountManager    = PathReferenceCountManager;
        }
        public PrimaryWindowCoreLayoutViewModel(
            [Dependency("PrimaryWindowNavigationService")] Lazy <INavigationService> navigationServiceLazy,
            IEventAggregator eventAggregator,
            IScheduler scheduler,
            ApplicationSettings applicationSettings,
            RestoreNavigationManager restoreNavigationManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            FolderContainerTypeManager folderContainerTypeManager,
            StorageItemSearchManager storageItemSearchManager,
            SourceChoiceCommand sourceChoiceCommand,
            RefreshNavigationCommand refreshNavigationCommand,
            OpenPageCommand openPageCommand
            )
        {
            MenuItems = new List <object>
            {
                new MenuItemViewModel()
                {
                    PageType = nameof(Views.SourceStorageItemsPage)
                },
                //new MenuItemViewModel() { PageType = nameof(Views.CollectionPage) },
            };
            _navigationServiceLazy              = navigationServiceLazy;
            EventAggregator                     = eventAggregator;
            _scheduler                          = scheduler;
            ApplicationSettings                 = applicationSettings;
            RestoreNavigationManager            = restoreNavigationManager;
            SourceStorageItemsRepository        = sourceStorageItemsRepository;
            _PathReferenceCountManager          = PathReferenceCountManager;
            _folderContainerTypeManager         = folderContainerTypeManager;
            _storageItemSearchManager           = storageItemSearchManager;
            SourceChoiceCommand                 = sourceChoiceCommand;
            SourceChoiceCommand.OpenAfterChoice = true;
            RefreshNavigationCommand            = refreshNavigationCommand;
            OpenPageCommand                     = openPageCommand;


            UpdateAutoSuggestCommand = new ReactiveCommand <string>();

            UpdateAutoSuggestCommand
            .Throttle(TimeSpan.FromSeconds(0.250), _scheduler)
            .Subscribe(ExecuteUpdateAutoSuggestCommand)
            .AddTo(_disposables);

            EventAggregator.GetEvent <PathReferenceCountUpdateWhenSourceManagementChanged.SearchIndexUpdateProgressEvent>()
            .Subscribe(args =>
            {
                _autoSuggestBoxSearchIndexGroup.SearchIndexUpdateProgressCount = args.ProcessedCount;
                _autoSuggestBoxSearchIndexGroup.SearchIndexUpdateTotalCount    = args.TotalCount;

                Debug.WriteLine($"[SearchIndexUpdate] progress: {args.ProcessedCount}/{args.TotalCount} ");
            }
                       , ThreadOption.UIThread
                       , keepSubscriberReferenceAlive: true
                       )
            .AddTo(_disposables);

            AutoSuggestBoxItems = new[]
            {
                _AutoSuggestItemsGroup,
                _autoSuggestBoxSearchIndexGroup
            };
        }
Esempio n. 6
0
        public SourceStorageItemsPageViewModel(
            IEventAggregator eventAggregator,
            FolderListingSettings folderListingSettings,
            BookmarkManager bookmarkManager,
            ThumbnailManager thumbnailManager,
            PathReferenceCountManager PathReferenceCountManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            RecentlyAccessManager recentlyAccessManager,
            SecondaryTileManager secondaryTileManager,
            SourceChoiceCommand sourceChoiceCommand,
            OpenFolderItemCommand openFolderItemCommand,
            OpenImageViewerCommand openImageViewerCommand,
            OpenFolderListupCommand openFolderListupCommand,
            OpenWithExplorerCommand openWithExplorerCommand,
            SecondaryTileAddCommand secondaryTileAddCommand,
            SecondaryTileRemoveCommand secondaryTileRemoveCommand
            )
        {
            Folders                       = new ObservableCollection <StorageItemViewModel>();
            RecentlyItems                 = new ObservableCollection <StorageItemViewModel>();
            OpenFolderItemCommand         = openFolderItemCommand;
            SourceChoiceCommand           = sourceChoiceCommand;
            _sourceStorageItemsRepository = sourceStorageItemsRepository;
            _recentlyAccessManager        = recentlyAccessManager;
            SecondaryTileManager          = secondaryTileManager;
            _eventAggregator              = eventAggregator;
            OpenImageViewerCommand        = openImageViewerCommand;
            OpenFolderListupCommand       = openFolderListupCommand;
            OpenWithExplorerCommand       = openWithExplorerCommand;
            SecondaryTileAddCommand       = secondaryTileAddCommand;
            SecondaryTileRemoveCommand    = secondaryTileRemoveCommand;
            _bookmarkManager              = bookmarkManager;
            _thumbnailManager             = thumbnailManager;
            _PathReferenceCountManager    = PathReferenceCountManager;
            _folderListingSettings        = folderListingSettings;

            Groups = new[]
            {
                new SourceItemsGroup
                {
                    GroupId = "Folders",
                    Items   = Folders,
                },
                new SourceItemsGroup
                {
                    GroupId = "RecentlyUsedFiles",
                    Items   = RecentlyItems,
                },
            };

            _eventAggregator.GetEvent <SourceStorageItemsRepository.AddedEvent>()
            .Subscribe(args =>
            {
                var existInFolders = Folders.FirstOrDefault(x => x.Token == args.Token);
                if (existInFolders != null)
                {
                    Folders.Remove(existInFolders);
                }

                var existInFiles = RecentlyItems.FirstOrDefault(x => x.Token == args.Token);
                if (existInFiles != null)
                {
                    RecentlyItems.Remove(existInFiles);
                }

                var storageItemImageSource = new StorageItemImageSource(args.StorageItem, _thumbnailManager);
                if (storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Folder)
                {
                    // 追加用ボタンの次に配置するための 1
                    Folders.Insert(1, new StorageItemViewModel(storageItemImageSource, args.Token, _sourceStorageItemsRepository, _folderListingSettings, _bookmarkManager));
                }
                else if (storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Image ||
                         storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.Archive ||
                         storageItemImageSource.ItemTypes == Models.Domain.StorageItemTypes.EBook
                         )
                {
                    RecentlyItems.Insert(0, new StorageItemViewModel(storageItemImageSource, args.Token, _sourceStorageItemsRepository, _folderListingSettings, _bookmarkManager));
                }
            })
            .AddTo(_disposables);

            _eventAggregator.GetEvent <SourceStorageItemsRepository.RemovedEvent>()
            .Subscribe(args =>
            {
                var existInFolders = Folders.FirstOrDefault(x => x.Token == args.Token);
                if (existInFolders != null)
                {
                    Folders.Remove(existInFolders);
                }

                var existInFiles = RecentlyItems.Where(x => x.Token == args.Token).ToList();
                foreach (var item in existInFiles)
                {
                    RecentlyItems.Remove(item);
                }
            })
            .AddTo(_disposables);
        }