コード例 #1
0
        public SettingsViewModel(FileOpenCommands commands, IDialogService dialogService, IVirtualDashboardsRepository virtualDashboardsRepository)
        {
            this.virtualDashboardsRepository = virtualDashboardsRepository;
            settings            = new SettingsSaver(this, ApplicationData.Current.RoamingSettings);
            BrowseFolderCommand = commands.BrowseFolderCommand;
            BrowseFolderCommand.Subscribe(x =>
            {
                if (VideoFolderToken != null)
                {
                    StorageApplicationPermissions.FutureAccessList.Clear();
                }

                var token        = StorageApplicationPermissions.FutureAccessList.Add(x);
                VideoFolder      = x.Path;
                VideoFolderToken = token;
            });

            videoFolder         = BrowseFolderCommand.ToProperty(this, x => x.Folder);
            IsAccountConfigured = this.WhenAnyValue(x => x.Username, x => x.Password,
                                                    (u, p) => new[] { u, p }.All(s => !string.IsNullOrEmpty(s)));

            IsVideoFolderFolderConfigured = this.WhenAnyValue(x => x.VideoFolder, x => !string.IsNullOrEmpty(x));

            UnitPack = UnitPacks.FirstOrDefault(pack => pack.Id == StringUnitPack) ?? UnitPacks.First();
            this.WhenAnyValue(x => x.UnitPack).Subscribe(x => StringUnitPack = UnitPack.Id);

            RemoveFolderCommand = ReactiveCommand.Create(() =>
            {
                StorageApplicationPermissions.FutureAccessList.Clear();

                VideoFolder      = null;
                VideoFolderToken = null;
            }, this.WhenAnyValue(x => x.VideoFolderToken, selector: s => s != null));

            UserBasedLogin  = new UserBasedLogin();
            EmailBasedLogin = new EmailBasedLogin(dialogService);

            var usernamesSequence = GetUsernamesSequence();
            var passwordSequence  = GetPasswordsSequence();


            username = usernamesSequence.ToProperty(this, x => x.Username);
            password = passwordSequence.ToProperty(this, x => x.Password);

            dashboardPreview =
                this.WhenAnyValue(x => x.VirtualDashboard, x => x.UnitPack,
                                  (vd, up) => CreatePreviewViewModel(up, vd)).ToProperty(this, x => x.DashboardPreview);
        }
コード例 #2
0
        public SettingsViewModel(IAccesibleFolders accesibleFolders, ISettingsStore settingsStore,
                                 IVirtualDashboardRepository virtualDashboardRepository)
        {
            this.settingsStore = settingsStore;
            this.virtualDashboardRepository = virtualDashboardRepository;
            AddFolder = ReactiveCommand.CreateFromTask(accesibleFolders.Add);

            disposable = accesibleFolders.Folders
                         .Connect()
                         .Transform(x => new FolderViewModel(x, accesibleFolders))
                         .Bind(out folders)
                         .Subscribe();

            UnitPack = UnitPacks.FirstOrDefault(pack => pack.Id == StringUnitPack) ?? UnitPacks.First();
            this.WhenAnyValue(x => x.UnitPack).Subscribe(x => StringUnitPack = UnitPack.Id);

            dashboardPreview =
                this.WhenAnyValue(x => x.VirtualDashboard, x => x.UnitPack,
                                  (vd, up) => SettingsSampleData.CreatePreviewViewModel(up, vd)).ToProperty(this, x => x.DashboardPreview);
        }