コード例 #1
0
        private void RegisterViewModels()
        {
            SearchPageViewModel.Register(_searchPage);
            PrivacyModeViewModel.Register(_privacyMode);
            AddWalletPageViewModel.Register(_addWalletPage);
            SettingsPageViewModel.Register(_settingsPage);

            GeneralSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 0;
                return(_settingsPage);
            });

            PrivacySettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 1;
                return(_settingsPage);
            });

            NetworkSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 2;
                return(_settingsPage);
            });

            BitcoinTabSettingsViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 3;
                return(_settingsPage);
            });

            AboutViewModel.RegisterLazy(() => new AboutViewModel());

            BroadcastTransactionViewModel.RegisterAsyncLazy(
                async() =>
            {
                var dialogResult = await DialogScreen.NavigateDialog(new LoadTransactionViewModel(_global.Network));

                if (dialogResult.Result is { })
                {
                    while (_global.TransactionBroadcaster is null)
                    {
                        await Task.Delay(100);
                    }

                    return(new BroadcastTransactionViewModel(
                               _global.BitcoinStore,
                               _global.Network,
                               _global.TransactionBroadcaster,
                               dialogResult.Result));
                }

                return(null);
            });
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: yahiheb/WalletWasabi
        public MainViewModel()
        {
            _windowState  = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState);
            _dialogScreen = new DialogScreenViewModel();

            _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

            _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

            MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

            NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;
            _isFullScreenEnabled   = true;

            _statusBar = new StatusBarViewModel();

            UiServices.Initialize();

            _addWalletPage = new AddWalletPageViewModel();
            _settingsPage  = new SettingsPageViewModel();
            _privacyMode   = new PrivacyModeViewModel();
            _searchPage    = new SearchPageViewModel();
            _navBar        = new NavBarViewModel(MainScreen);

            NavigationManager.RegisterType(_navBar);

            RegisterCategories(_searchPage);
            RegisterViewModels();

            RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

            _searchPage.Initialise();

            this.WhenAnyValue(x => x.WindowState)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(windowState => Services.UiConfig.WindowState = windowState.ToString());

            this.WhenAnyValue(x => x.DialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.FullScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.CompactDialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            if (!Services.WalletManager.HasWallet())
            {
                _dialogScreen.To(_addWalletPage, NavigationMode.Clear);
            }
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: yahiheb/WalletWasabi
        private void RegisterViewModels()
        {
            SearchPageViewModel.Register(_searchPage);
            PrivacyModeViewModel.Register(_privacyMode);
            AddWalletPageViewModel.Register(_addWalletPage);
            SettingsPageViewModel.Register(_settingsPage);

            GeneralSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 0;
                return(_settingsPage);
            });

            PrivacySettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 1;
                return(_settingsPage);
            });

            NetworkSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 2;
                return(_settingsPage);
            });

            BitcoinTabSettingsViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 3;
                return(_settingsPage);
            });

            AboutViewModel.RegisterLazy(() => new AboutViewModel());

            BroadcastTransactionViewModel.RegisterAsyncLazy(
                async() =>
            {
                var dialogResult = await DialogScreen.NavigateDialogAsync(new LoadTransactionViewModel(Services.Config.Network));

                if (dialogResult.Result is { })
                {
                    return(new BroadcastTransactionViewModel(Services.Config.Network,
                                                             dialogResult.Result));
                }

                return(null);
            });
コード例 #4
0
        private void RegisterViewModels()
        {
            HomePageViewModel.Register(_homePage);

            SearchPageViewModel.Register(_searchPage);
            PrivacyModeViewModel.Register(_privacyMode);
            AddWalletPageViewModel.Register(_addWalletPage);
            SettingsPageViewModel.Register(_settingsPage);

            GeneralSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 0;
                return(_settingsPage);
            });

            PrivacySettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 1;
                return(_settingsPage);
            });

            NetworkSettingsTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 2;
                return(_settingsPage);
            });

            BitcoinTabViewModel.RegisterLazy(
                () =>
            {
                _settingsPage.SelectedTab = 3;
                return(_settingsPage);
            });

            AboutViewModel.RegisterLazy(() => new AboutViewModel());

            LegalDocumentsViewModel.RegisterAsyncLazy(
                async() =>
            {
                var content = await File.ReadAllTextAsync(_global.LegalDocuments.FilePath);

                var legalDocs = new LegalDocumentsViewModel(content);

                return(legalDocs);
            });
        }
コード例 #5
0
        public MainViewModel(Global global)
        {
            _global       = global;
            _legalChecker = global.LegalChecker;

            _dialogScreen = new DialogScreenViewModel();

            _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

            _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

            MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

            NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

            Network = global.Network;

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;
            _isFullScreenEnabled   = true;

            _statusBar = new StatusBarViewModel(
                global.DataDir,
                global.Network,
                global.Config,
                global.HostedServices,
                global.BitcoinStore.SmartHeaderChain,
                global.Synchronizer);

            _walletManagerViewModel = new WalletManagerViewModel(global.WalletManager, global.UiConfig, _global.BitcoinStore, _global.LegalChecker, _global.TransactionBroadcaster);

            _addWalletPage = new AddWalletPageViewModel(
                _walletManagerViewModel,
                global.BitcoinStore);

            _settingsPage = new SettingsPageViewModel(global.Config, global.UiConfig);
            _privacyMode  = new PrivacyModeViewModel(global.UiConfig);
            _searchPage   = new SearchPageViewModel();

            _navBar = new NavBarViewModel(MainScreen, _walletManagerViewModel);

            NavigationManager.RegisterType(_navBar);

            RegisterCategories(_searchPage);
            RegisterViewModels();

            RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

            _searchPage.Initialise();

            this.WhenAnyValue(x => x.DialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.FullScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            _walletManagerViewModel.WhenAnyValue(x => x.Items.Count, x => x.Actions.Count)
            .Subscribe(x => _navBar.IsHidden = x.Item1 == 0 && x.Item2 == 0);

            if (!_walletManagerViewModel.WalletManager.AnyWallet(_ => true))
            {
                MainScreen.To(_addWalletPage);
            }
        }
コード例 #6
0
        public MainViewModel()
        {
            _windowState  = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState);
            _dialogScreen = new DialogScreenViewModel();

            _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);

            _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen);

            MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

            NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen);

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;
            _isFullScreenEnabled   = true;

            _statusBar = new StatusBarViewModel();

            UiServices.Initialize();

            _addWalletPage = new AddWalletPageViewModel();
            _settingsPage  = new SettingsPageViewModel();
            _privacyMode   = new PrivacyModeViewModel();
            _searchPage    = new SearchPageViewModel();
            _navBar        = new NavBarViewModel(MainScreen);

            NavigationManager.RegisterType(_navBar);

            RegisterCategories(_searchPage);
            RegisterViewModels();

            RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

            _searchPage.Initialise();

            this.WhenAnyValue(x => x.WindowState)
            .Where(x => x != WindowState.Minimized)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(windowState => Services.UiConfig.WindowState = windowState.ToString());

            this.WhenAnyValue(
                x => x.DialogScreen !.IsDialogOpen,
                x => x.FullScreen !.IsDialogOpen,
                x => x.CompactDialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(tup =>
            {
                var(dialogScreenIsOpen, fullScreenIsOpen, compactDialogScreenIsOpen) = tup;

                IsMainContentEnabled = !(dialogScreenIsOpen || fullScreenIsOpen || compactDialogScreenIsOpen);
            });

            this.WhenAnyValue(
                x => x.DialogScreen.CurrentPage,
                x => x.CompactDialogScreen.CurrentPage,
                x => x.FullScreen.CurrentPage,
                x => x.MainScreen.CurrentPage)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(tup =>
            {
                var(dialog, compactDialog, fullscreenDialog, mainsScreen) = tup;

                /*
                 * Order is important.
                 * Always the topmost content will be the active one.
                 */

                if (compactDialog is { })
                {
                    compactDialog.SetActive();
                    return;
                }

                if (dialog is { })
コード例 #7
0
ファイル: MainViewModel.cs プロジェクト: fbion/WalletWasabi
        public MainViewModel(Global global)
        {
            _global = global;

            _dialogScreen = new DialogScreenViewModel(800, 700);

            _fullScreen = new DialogScreenViewModel(double.PositiveInfinity, double.PositiveInfinity, NavigationTarget.FullScreen);

            MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);

            NavigationState.Register(MainScreen, DialogScreen, FullScreen, () => this);

            Network = global.Network;

            _currentDialog = null;

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;
            _isFullScreenEnabled   = true;

            _statusBar = new StatusBarViewModel(
                global.DataDir,
                global.Network,
                global.Config,
                global.HostedServices,
                global.BitcoinStore.SmartHeaderChain,
                global.Synchronizer,
                global.LegalDocuments);

            _walletManager = new WalletManagerViewModel(global.WalletManager, global.UiConfig);

            _addWalletPage = new AddWalletPageViewModel(
                global.LegalDocuments,
                global.WalletManager,
                global.BitcoinStore,
                global.Network);

            _settingsPage = new SettingsPageViewModel(global.Config, global.UiConfig);
            _privacyMode  = new PrivacyModeViewModel(global.UiConfig);
            _searchPage   = new SearchPageViewModel();

            _navBar = new NavBarViewModel(MainScreen, _walletManager);

            NavigationManager.RegisterType(_navBar);

            RegisterCategories(_searchPage);
            RegisterViewModels();

            RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync());

            _searchPage.Initialise();

            this.WhenAnyValue(x => x.DialogScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.FullScreen !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsMainContentEnabled = !x);

            this.WhenAnyValue(x => x.CurrentDialog !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x =>
            {
                IsFullScreenEnabled   = !x;
                IsDialogScreenEnabled = !x;
            });

            _walletManager.WhenAnyValue(x => x.Items.Count)
            .Subscribe(x => _navBar.IsHidden = x == 0);

            if (!_walletManager.Model.AnyWallet(_ => true))
            {
                MainScreen.To(_addWalletPage);
            }
        }