private void OnSyncedWallet() { var accountBalances = Wallet.CalculateBalances(1); // TODO: configurable confirmations var accountViewModels = Wallet.EnumerateAccounts() .Zip(accountBalances, (a, bals) => new AccountViewModel(a.Item1, a.Item2, bals)) .ToList(); var txSet = Wallet.RecentTransactions; var recentTx = txSet.UnminedTransactions .Select(x => new TransactionViewModel(Wallet, x.Value, BlockIdentity.Unmined)) .Concat(txSet.MinedTransactions.ReverseList().SelectMany(b => b.Transactions.Select(tx => new TransactionViewModel(Wallet, tx, b.Identity)))) .Take(10); var overviewViewModel = (OverviewViewModel)SingletonViewModelLocator.Resolve("Overview"); App.Current.Dispatcher.Invoke(() => { foreach (var vm in accountViewModels) { Accounts.Add(vm); } foreach (var tx in recentTx) { overviewViewModel.RecentTransactions.Add(tx); } }); SyncedBlockHeight = Wallet.ChainTip.Height; SelectedAccount = accountViewModels[0]; RaisePropertyChanged(nameof(TotalBalance)); RaisePropertyChanged(nameof(AccountNames)); overviewViewModel.AccountsCount = accountViewModels.Count(); var shell = (ShellViewModel)ViewModelLocator.ShellViewModel; shell.StartupWizardVisible = false; }
public App() { if (Current != null) { throw new ApplicationException("Application instance already exists"); } InitializeComponent(); SingletonViewModelLocator.RegisterFactory <ShellView, ShellViewModel>(); SingletonViewModelLocator.RegisterFactory <Overview, OverviewViewModel>(); SingletonViewModelLocator.RegisterFactory <Request, RequestViewModel>(); Application.Current.Dispatcher.UnhandledException += (sender, args) => { var ex = args.Exception; var ae = ex as AggregateException; Exception inner; if (ae != null && ae.TryUnwrap(out inner)) { ex = inner; } MessageBox.Show(ex.Message, "Error"); UncleanShutdown(); Application.Current.Shutdown(1); }; Application.Current.Startup += Application_Startup; Current = this; }
private void OnSyncedWallet() { var txSet = _wallet.RecentTransactions; var recentTx = txSet.UnminedTransactions .Select(x => new TransactionViewModel(_wallet, x.Value, BlockIdentity.Unmined)) .Concat(txSet.MinedTransactions.ReverseList().SelectMany(b => b.Transactions.Select(tx => new TransactionViewModel(_wallet, tx, b.Identity)))) .Take(10); var overviewViewModel = (OverviewViewModel)SingletonViewModelLocator.Resolve("Overview"); overviewViewModel.AccountsCount = _wallet.EnumerateAccounts().Count(); Application.Current.Dispatcher.Invoke(() => { foreach (var tx in recentTx) { overviewViewModel.RecentTransactions.Add(tx); } }); SyncedBlockHeight = _wallet.ChainTip.Height; NotifyRecalculatedBalances(); StartupWizardVisible = false; }
public App() { if (Current != null) { throw new ApplicationException("Application instance already exists"); } SingletonViewModelLocator.RegisterFactory <LauncherProgressView, LauncherProgressViewModel>(); Application.Current.Dispatcher.UnhandledException += (sender, args) => { var ex = args.Exception; MessageBox.Show(ex.Message, "Error"); UncleanShutdown(); Shutdown(1); }; Application.Current.Startup += Application_Startup; Current = this; }
private void Application_Startup(object sender, StartupEventArgs e) { // WPF defaults to using the en-US culture for all formatted bindings. // Override this with the system's current culture. FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); var args = ProcessArguments.ParseArguments(e.Args); var activeNetwork = args.IntendedNetwork; WalletClient.Initialize(); Directory.CreateDirectory(AppDataDir); // try to obtain some default rpc settings to autofill the startup dialogs with. // try paymetheus defaults first, and if that fails, look for a dcrd config. try { var iniParser = new FileIniDataParser(); IniData config = null; string defaultsFile = Path.Combine(AppDataDir, "defaults.ini"); if (File.Exists(defaultsFile)) { config = iniParser.ReadFile(defaultsFile); } else { var consensusRpcAppData = Portability.LocalAppData(Environment.OSVersion.Platform, "", ConsensusServerRpcOptions.ApplicationName); var consensusRpcConfig = ConsensusServerRpcOptions.ApplicationName + ".conf"; var consensusConfigFilePath = Path.Combine(consensusRpcAppData, consensusRpcConfig); if (File.Exists(consensusConfigFilePath)) { config = iniParser.ReadFile(consensusConfigFilePath); } } if (config != null) { // Settings can be found in either the Application Options or global sections. var section = config["Application Options"]; if (section == null) { section = config.Global; } var rpcUser = section["rpcuser"] ?? ""; var rpcPass = section["rpcpass"] ?? ""; var rpcListen = section["rpclisten"] ?? ""; var rpcCert = section["rpccert"] ?? ""; // rpclisten and rpccert can be filled with sensible defaults when empty. user and password can not. if (rpcListen == "") { rpcListen = "127.0.0.1"; } if (rpcCert == "") { var localCertPath = ConsensusServerRpcOptions.LocalCertificateFilePath(); if (File.Exists(localCertPath)) { rpcCert = localCertPath; } } DefaultCSRPO = new ConsensusServerRpcOptions(rpcListen, rpcUser, rpcPass, rpcCert); } } catch { } // Ignore any errors, this will just result in leaving defaults empty. var syncTask = Task.Run(async() => { return(await SynchronizerViewModel.Startup(activeNetwork, AppDataDir, args.SearchPathForWalletProcess, args.ExtraWalletArgs)); }); var synchronizer = syncTask.Result; SingletonViewModelLocator.RegisterInstance("Synchronizer", synchronizer); ActiveNetwork = activeNetwork; Synchronizer = synchronizer; Current.Exit += Application_Exit; }