Exemple #1
0
        public MainViewModel(Global global)
        {
            _global = global;

            _dialogScreen = new DialogScreenViewModel();

            var navigationState = new NavigationStateViewModel(() => this, () => _dialogScreen, () => this);

            Network = global.Network;

            _currentDialog = null;

            _isMainContentEnabled  = true;
            _isDialogScreenEnabled = true;

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

            var walletManager = new WalletManagerViewModel(navigationState, global.WalletManager, global.UiConfig);

            var addWalletPage = new AddWalletPageViewModel(navigationState, global.LegalDocuments, global.WalletManager, global.BitcoinStore, global.Network);

            _navBar = new NavBarViewModel(navigationState, Router, walletManager, addWalletPage);

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

            this.WhenAnyValue(x => x.CurrentDialog !.IsDialogOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => IsDialogScreenEnabled = !x);
        }
 public HomeViewModel(NavigationStateViewModel navigationState, WalletManagerViewModel walletManager) : base(navigationState, "Home", "Home")
 {
     _items = new ObservableCollection <RoutableViewModel>
     {
         new WalletExplorerViewModel(navigationState, walletManager),
         walletManager,
         new TransactionBroadcasterViewModel(navigationState),
         new SettingsViewModel(navigationState),
         new HelpViewModel(navigationState)
     };
 }
        public MainViewModel(Global global)
        {
            _global = global;
            Network = global.Network;

            _currentDialog = null;

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

            var walletManager = new WalletManagerViewModel(this, global.WalletManager, global.UiConfig);

            _navBar = new NavBarViewModel(this, Router, walletManager);
        }
Exemple #4
0
        public NavBarViewModel(IScreen screen, RoutingState router, WalletManagerViewModel walletManager)
        {
            Router         = router;
            _walletManager = walletManager;
            _topItems      = new ObservableCollection <NavBarItemViewModel>();
            _bottomItems   = new ObservableCollection <NavBarItemViewModel>();

            var addWalletPage = new AddWalletPageViewModel(screen);

            SelectedItem = new HomePageViewModel(screen, walletManager, addWalletPage);
            _topItems.Add(_selectedItem);
            _bottomItems.Add(addWalletPage);
            _bottomItems.Add(new SettingsPageViewModel(screen));

            Router.CurrentViewModel
            .OfType <NavBarItemViewModel>()
            .Subscribe(x =>
            {
                if (walletManager.Items.Contains(x) || _topItems.Contains(x) || _bottomItems.Contains(x))
                {
                    if (!_isNavigating)
                    {
                        _isNavigating = true;
                        SelectedItem  = x;
                        _isNavigating = false;
                    }
                }
            });

            this.WhenAnyValue(x => x.SelectedItem)
            .OfType <IRoutableViewModel>()
            .Subscribe(x =>
            {
                if (!_isNavigating)
                {
                    _isNavigating = true;
                    Router.NavigateAndReset.Execute(x);
                    CollapseOnClickAction?.Invoke();

                    _isNavigating = false;
                }
            });

            Observable.FromEventPattern(Router.NavigationStack, nameof(Router.NavigationStack.CollectionChanged))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => IsBackButtonVisible = Router.NavigationStack.Count > 1);

            this.WhenAnyValue(x => x.IsOpen)
            .Subscribe(x => SelectedItem.IsExpanded = x);
        }
        public HomePageViewModel(IScreen screen, WalletManagerViewModel walletManager, AddWalletPageViewModel addWalletPage) : base(screen)
        {
            Title = "Home";

            var list = new SourceList <NavBarItemViewModel>();

            list.Add(addWalletPage);

            walletManager.Items.ToObservableChangeSet()
            .Cast(x => x as NavBarItemViewModel)
            .Sort(SortExpressionComparer <NavBarItemViewModel> .Ascending(i => i.Title))
            .Merge(list.Connect())
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _items)
            .AsObservableList();

            OpenWalletsFolderCommand = ReactiveCommand.Create(() => IoHelpers.OpenFolderInFileExplorer(walletManager.Model.WalletDirectories.WalletsDir));
        }
        public MainViewModel()
        {
            var navigationState = new NavigationStateViewModel();

            _dialog        = new DialogViewModel();
            _walletManager = new WalletManagerViewModel(navigationState, "Add Wallet");

            var helpViewModel           = new HelpViewModel(navigationState);
            var walletExplorerViewModel = new WalletExplorerViewModel(navigationState, _walletManager);
            var settingsViewModel       = new SettingsViewModel(navigationState);

            HomeCommand = ReactiveCommand.Create(() => navigationState.Screen().Router.NavigateAndReset.Execute(walletExplorerViewModel));

#if !USE_DIALOG
            HelpCommand = ReactiveCommand.Create(() => navigationState.Screen().Router.Navigate.Execute(helpViewModel));
#else
            HelpCommand = ReactiveCommand.Create(() => navigationState.Dialog().Router.Navigate.Execute(helpViewModel));
#endif

#if !USE_DIALOG
            AddWalletCommand = ReactiveCommand.Create(() => navigationState.Screen().Router.Navigate.Execute(walletManager));
#else
            AddWalletCommand = ReactiveCommand.Create(() => navigationState.Dialog().Router.Navigate.Execute(_walletManager));
#endif

#if !USE_DIALOG
            SettingsCommand = ReactiveCommand.Create(() => navigationState.Screen().Router.Navigate.Execute(settingsViewModel));
#else
            SettingsCommand = ReactiveCommand.Create(() => navigationState.Dialog().Router.Navigate.Execute(settingsViewModel));
#endif
            _walletManager.Home = walletExplorerViewModel;

            navigationState.Screen     = () => this;
            navigationState.Dialog     = () => _dialog;
            navigationState.NextView   = () => walletExplorerViewModel;
            navigationState.CancelView = () => walletExplorerViewModel;

            Router.NavigateAndReset.Execute(walletExplorerViewModel);

            // Router.NavigateAndReset.Execute(new HomeViewModel(this));
        }
Exemple #7
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);
            }
        }
 public static void Initialize()
 {
     WalletManager = new WalletManagerViewModel();
 }
Exemple #9
0
        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);
            }
        }