Example #1
0
        private async Task Loged(AccountConfiguration account)
        {
            Header.TabItems.Clear();

            foreach (var wallet in account.Wallets)
            {
                if (wallet.IsActive)
                {
                    var tabItem = new Models.TabItem()
                    {
                        Name       = wallet.Name,
                        IsSelected = false,
                    };
                    var walletProvider = new Iota.IotaWalletManager(wallet, tabItem);
                    tabItem.Selected = (t) => View = walletProvider.Wallet;
                    Header.TabItems.Add(tabItem);
                }
            }
            var tab = Header.TabItems.FirstOrDefault();

            if (tab != null)
            {
                tab.IsSelected = true;
            }
            else
            {
                View = null;
            }
        }
Example #2
0
        private async Task CreateWalletAsync(IUserNameCredentials credentials)
        {
            var oldView = this.View;

            var createWalletModel = new CreateWalletModel();

            this.View = createWalletModel;

            try
            {
                var wallet = await createWalletModel.CreateWallet();

                var syncContent = await syncModel.EnterSync();

                try
                {
                    syncContent.SetTextView("Your wallet is almost ready. We are creating the first address for you.");

                    var tabItem = new Models.TabItem()
                    {
                        Name       = wallet.Name,
                        IsSelected = false,
                    };
                    var walletProvider = new Iota.IotaWalletManager(wallet, tabItem);

                    await walletProvider.EnsureFirstAddressAsync();

                    if (wallet.IsImported)
                    {
                        walletProvider.InitializeAsync(true);
                    }

                    var passwordHash = credentials.GetPasswordHash();
                    storageManager.SaveWallet(credentials.UserName, passwordHash, wallet);

                    tabItem.Selected = (t) => View = walletProvider.Wallet;
                    Header.TabItems.Add(tabItem);
                    foreach (var tab in Header.TabItems) // don't know why but need
                    {
                        tab.IsSelected = false;
                    }
                    tabItem.IsSelected = true;
                    return;
                }
                catch (OperationCanceledException)
                {
                    // do nothing
                }
                catch (Exception e)
                {
                    await syncContent.SetCancelView(e.Message).WaitAsync();
                }
                finally
                {
                    syncContent.Dispose();
                }
            }
            catch (OperationCanceledException)
            {
                // do nothing
            }
            this.View = oldView;
        }