public OpenFolderItemCommand(
     INavigationService navigationService,
     FolderContainerTypeManager folderContainerTypeManager,
     SourceChoiceCommand sourceChoiceCommand
     )
 {
     _navigationService          = navigationService;
     _folderContainerTypeManager = folderContainerTypeManager;
     _sourceChoiceCommand        = sourceChoiceCommand;
 }
        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. 3
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);
        }