예제 #1
0
        public static async Task RequestRemoveFolderAsync(FolderViewModel vm)
        {
            var msg = $"Are you sure to remove the following folder from collection:\n{vm.Path}";

            if (await DialogService.RequireConfirmationAsync(msg) == false)
            {
                return;
            }

            var o = new IndexService();
            await o.RequestRemoveFolderAsyncInner(vm);
        }
예제 #2
0
        internal static async Task InitializeAsync()
        {
            _isIndexing.OnNext(false);

            Observable.Using(
                () => Db.Instance,
                db => Observable.Merge(new IObservable <object>[]
            {
                db.Set <Folder>().ToList()
                .ToObservable()
                .ObservableOnThreadPool()
                .Select(x => FolderViewModel.Create(x))
                .Do(_musicFolders.AddOrUpdate),
                db.Set <Artist>().ToList()
                .ToObservable()
                .ObservableOnThreadPool()
                .Select(x => ArtistViewModel.Create(x))
                .Do(_artistSource.AddOrUpdate)
            }).IgnoreElements())
            .Subscribe();

            AlbumSource = ArtistSource.Connect()
                          .ObservableOnThreadPool()
                          .MergeMany(x => x.Albums.Connect())
                          .AsObservableCache();

            TrackSource = AlbumSource.Connect()
                          .ObservableOnThreadPool()
                          .MergeMany(x => x.Tracks.Connect())
                          .AsObservableCache();

            Observable.Merge(new[]
            {
                newMusicFolderObservable.Select(_ => "Added new folder"),
                FolderWatcherManager.ContentChanged.Select(_ => "FolderWatcherManager.ContentChanged"),
                Setting.Collection.AutoRefresh.Where(x => x == true).Select(_ => Unit.Default).Select(_ => "Setting.SettingChanged[Setting.Collection.AutoRefresh]"),
            })
            .ObservableOnThreadPool()
            .Throttle(TimeSpan.FromSeconds(5))
            .SkipUntil(collectionAutoRefresh.Where(x => x == true))
            .TakeUntil(collectionAutoRefresh.Where(x => x == false))
            .Repeat()
            .Subscribe(async _ =>
            {
                var o = new IndexService();
                await o.BeginIndexAsync();
            });

            await FolderWatcherManager.InitializeAsync();
        }
예제 #3
0
        public static async Task RequestAddFolderAsync()
        {
            var folderPicker = new FolderPicker
            {
                SuggestedStartLocation = PickerLocationId.ComputerFolder
            };

            folderPicker.FileTypeFilter.Add("*");

            var folder = await folderPicker.PickSingleFolderAsync();

            if (folder == null)
            {
                return;
            }
            else
            {
                var o = new IndexService();
                await o.RequestAddFolderAsyncInner(folder);

                newMusicFolderObservable.OnNext(Unit.Default);
            }
        }
예제 #4
0
 public static async Task RunAsync()
 {
     var o = new IndexService();
     //await o.RunAsyncInner();
 }