public MainWindowViewModel(Window desktopMainWindow)
        {
            _desktopMainWindow = desktopMainWindow;

            BlockChainCache            = new BlockChainCache();
            BlockChainCache.StakePools = new ObservableCollection <StakePool>();
            var stakePoolDbFileInfo = new FileInfo(StakePoolListDatabase);

            if (stakePoolDbFileInfo.Exists)
            {
                var jsonCacheStakePools = File.ReadAllBytes(StakePoolListDatabase);
                var readOnlySpan        = new ReadOnlySpan <byte>(jsonCacheStakePools);
                BlockChainCache = JsonSerializer.Deserialize <BlockChainCache>(readOnlySpan);

                _allStakePools = BlockChainCache.StakePools;
                OnPropertyChanged("BlockChainCache");
            }
            else
            {
                _allStakePools = new ObservableCollection <StakePool>();
            }
            _allWallets = new ObservableCollection <Wallet>();

            _cardanoServer             = new CardanoServer();
            _walletClient              = new WalletClient(_nodePort);
            desktopMainWindow.Opened  += StartCardanoServer;
            desktopMainWindow.Closing += WindowClosing;
        }
예제 #2
0
        public MainWindowViewModel(Window desktopMainWindow, SprdSettings sprdSettings)
        {
            _desktopMainWindow = desktopMainWindow;
            _sprdSettings      = sprdSettings;
            _sprdSelection     = new SprdSelection
            {
                Pool = new StakePool {
                    Name = "<Select Pool>"
                },
                Wallet = new Wallet {
                    Name = "<Select Wallet>"
                },
            };

            SpreadAdaCommand = ReactiveCommand.Create(SpreadAda);//, this.WhenAnyValue(x => x.CanExecuteSprd));

            BlockChainCache = new BlockChainCache
            {
                StakePools = new ObservableCollection <StakePool>()
            };
            var stakePoolDbFileInfo = new FileInfo(_stakePoolListDatabase);

            if (stakePoolDbFileInfo.Exists)
            {
                var jsonCacheStakePools = File.ReadAllBytes(_stakePoolListDatabase);
                var readOnlySpan        = new ReadOnlySpan <byte>(jsonCacheStakePools);
                BlockChainCache = JsonSerializer.Deserialize <BlockChainCache>(readOnlySpan);

                _allStakePools = BlockChainCache.StakePools;
                OnPropertyChanged("BlockChainCache");
            }
            else
            {
                _allStakePools = new ObservableCollection <StakePool>();
            }
            _allWallets          = new ObservableCollection <Wallet>();
            LastComittedAdaPools = new ObservableCollection <SprdPoolInfo>();

            _cardanoServer             = new CardanoServer();
            _sprdServer                = new SprdServer();
            _walletClient              = new WalletClient(_sprdSettings.WalletSettings.Port, _sprdServer);
            desktopMainWindow.Opened  += StartCardanoServer;
            desktopMainWindow.Closing += WindowClosing;
        }