protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
        {
            Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");

            uiConfig = Locator.Current.GetService <Global>().UiConfig;

            Observable.Merge(
                Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
            .Throttle(TimeSpan.FromSeconds(0.1))
            .Merge(uiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
            .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(
                _ =>
            {
                try
                {
                    var balance = Wallet.Coins.TotalAmount();
                    Title       = $"{WalletName} ({(uiConfig.PrivacyMode ? "#########" : balance.ToString(false))} BTC)";

                    TitleTip = balance.ToUsdString(Wallet.Synchronizer.UsdExchangeRate, uiConfig.PrivacyMode);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
            })
            .DisposeWith(Disposables);
        }
Beispiel #2
0
        protected WalletViewModel(Wallet wallet) : base(wallet)
        {
            Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");

            Actions = new ObservableCollection <ViewModelBase>();

            UiConfig = Locator.Current.GetService <Global>().UiConfig;

            WalletManager = Locator.Current.GetService <Global>().WalletManager;

            Observable.Merge(
                Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
            .Throttle(TimeSpan.FromSeconds(0.1))
            .Merge(UiConfig.WhenAnyValue(x => x.LurkingWifeMode).Select(_ => Unit.Default))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ =>
            {
                try
                {
                    Money balance = Wallet.Coins.TotalAmount();
                    Title         = $"{WalletName} ({(UiConfig.LurkingWifeMode ? "#########" : balance.ToString(false, true))} BTC)";
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
            })
            .DisposeWith(Disposables);

            // If hardware wallet or not watch only wallet then we need the Send tab.
            if (Wallet.KeyManager.IsHardwareWallet || !Wallet.KeyManager.IsWatchOnly)
            {
                SendTab = new SendTabViewModel(Wallet);
                Actions.Add(SendTab);
            }

            ReceiveTab = new ReceiveTabViewModel(Wallet);
            HistoryTab = new HistoryTabViewModel(Wallet);

            var advancedAction = new WalletAdvancedViewModel();

            InfoTab  = new WalletInfoViewModel(Wallet);
            BuildTab = new BuildTabViewModel(Wallet);

            Actions.Add(ReceiveTab);

            // If not watch only wallet (not hww) then we need the CoinJoin tab.
            if (!Wallet.KeyManager.IsWatchOnly)
            {
                CoinjoinTab = new CoinJoinTabViewModel(Wallet);
                Actions.Add(CoinjoinTab);
            }

            Actions.Add(HistoryTab);

            Actions.Add(advancedAction);
            advancedAction.Items.Add(InfoTab);
            advancedAction.Items.Add(BuildTab);
        }
Beispiel #3
0
        protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
        {
            Disposables = Disposables is null
                                ? new CompositeDisposable()
                                : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");

            var balanceChanged =
                Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default)
                .Throttle(TimeSpan.FromSeconds(0.1))
                .Merge(Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed)).Select(_ => Unit.Default))
                .Merge(uiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
                .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
                .ObserveOn(RxApp.MainThreadScheduler);

            History          = new HistoryViewModel(wallet, uiConfig, balanceChanged);
            BalanceTile      = new WalletBalanceTileViewModel(wallet, balanceChanged);
            BalanceChartTile = new WalletBalanceChartTileViewModel(History.Transactions);
            WalletPieChart   = new WalletPieChartTileViewModel(wallet, balanceChanged);
        }