private void SetVisibility(PageToShow p) { cErrors.Visibility = p == PageToShow.Errors ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; cResults.Visibility = p == PageToShow.Results ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; cInstructions.Visibility = p == PageToShow.Instructions ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; cWaiting.Visibility = p == PageToShow.Waiting ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; gMain.Height = p == PageToShow.Results ? 680 : 300; }
public void ChangePageUi(PageToShow pageToShow, BChipSmartCard bChipSmartCard) { Visibility noCardVisibility = Visibility.Collapsed; Visibility readyVisibility = Visibility.Collapsed; Visibility confirmFormatVisibility = Visibility.Collapsed; Visibility passphraseDialogVisibility = Visibility.Collapsed; Visibility notInitializedWizardVisibility = Visibility.Collapsed; Visibility crcErrorViewGridVisibility = Visibility.Collapsed; Visibility unsupportedDialogVisibility = Visibility.Collapsed; Visibility provisionNewKeysViewGridVisibility = Visibility.Collapsed; Visibility provisionMnemonicViewGridVisibility = Visibility.Collapsed; Visibility showPrivateKeyViewGridVisibility = Visibility.Collapsed; ClearPasswordBox(PassphraseEntryBox); ClearPasswordBox(passphrase); ClearPasswordBox(passphraseConfirmation); ClearPasswordBox(Mnemonicpassphrase); ClearPasswordBox(MnemonicpassphraseConfirmation); ClearTextBox(MnemonicEntryTextBox); // Clear last error if set UpdateTextLabel(ErrorMessageLabel, ""); switch (pageToShow) { case PageToShow.ProvisionMnemonic: provisionMnemonicViewGridVisibility = Visibility.Visible; break; case PageToShow.ProvisionCard: provisionNewKeysViewGridVisibility = Visibility.Visible; break; case PageToShow.ConfirmFormat: confirmFormatVisibility = Visibility.Visible; break; case PageToShow.Ready: readyVisibility = Visibility.Visible; break; case PageToShow.ShowPassphraseDialog: passphraseDialogVisibility = Visibility.Visible; break; case PageToShow.NoCard: noCardVisibility = Visibility.Visible; break; case PageToShow.Unsupported: case PageToShow.Error: unsupportedDialogVisibility = Visibility.Visible; break; case PageToShow.NotInitialized: notInitializedWizardVisibility = Visibility.Visible; break; case PageToShow.CrcError: crcErrorViewGridVisibility = Visibility.Visible; break; } DispatcherUpdater(ProvisionMnemonicPhraseViewGrid, provisionMnemonicViewGridVisibility); DispatcherUpdater(ShowPrivateKeyViewGrid, showPrivateKeyViewGridVisibility); DispatcherUpdater(ProvisionNewKeysViewGrid, provisionNewKeysViewGridVisibility); DispatcherUpdater(NonInitializedWizardViewGrid, notInitializedWizardVisibility); DispatcherUpdater(CrcErrorViewGrid, crcErrorViewGridVisibility); DispatcherUpdater(InitializedUnknownCardViewGrid, unsupportedDialogVisibility); DispatcherUpdater(ShowPassphraseViewGrid, passphraseDialogVisibility); DispatcherUpdater(InsertCardGrid, noCardVisibility); DispatcherUpdater(ConfirmFormatViewGrid, confirmFormatVisibility); DispatcherUpdater(ReadyCardViewGrid, readyVisibility); if (pageToShow == PageToShow.NoCard) { // Clear any keys left in UI pages UpdateTextLabel(PrivateKeyAddressLabel, ""); PrivateQrCodeImage.Dispatcher.BeginInvoke(new Action(() => { PrivateQrCodeImage.Source = null; })); } // Populate for card UI if (pageToShow == PageToShow.Ready) { QrCodeImage.Dispatcher.BeginInvoke(new Action(() => { QrCodeImage.Visibility = Visibility.Hidden; })); PubKeyCopyIcon.Dispatcher.BeginInvoke(new Action(() => { PubKeyCopyIcon.Visibility = Visibility.Hidden; })); BChipMemoryLayout_BCHIP bchip = (BChipMemoryLayout_BCHIP)bChipSmartCard.SmartCardData; UpdateTextLabel(BChipIdLabel, bchip.IdLabel); switch (bchip.PkType) { case PKType.BTC: UpdateTextLabel(PKTypeLabel, "Bitcoin (BTC)"); break; case PKType.BTC_TestNet: UpdateTextLabel(PKTypeLabel, "Bitcoin (TestNet)"); break; case PKType.CUSTOM: UpdateTextLabel(PKTypeLabel, "Custom"); break; case PKType.UNSET: UpdateTextLabel(PKTypeLabel, "(no key data)"); break; } string publicAddress = bchip.PublicAddress; if (publicAddress == "") { if (bchip.PkType == PKType.UNSET) { UpdateTextLabel(PublicKeyAddressLabel, "Card not setup - remove and re-insert card to reload"); DisplayPrivateKeyButton.Dispatcher.BeginInvoke(new Action(() => { DisplayPrivateKeyButton.IsEnabled = false; })); } else { UpdateTextLabel(PublicKeyAddressLabel, "No public key data on card"); } } else if (publicAddress == null) { UpdateTextLabel(PublicKeyAddressLabel, "Failed to parse public key data"); } else { QrCodeImage.Dispatcher.BeginInvoke(new Action(() => { QrCodeImage.Source = Imaging.CreateBitmapSourceFromHBitmap( new QrHandler(publicAddress, 5).GetQrCode().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); QrCodeImage.Visibility = Visibility.Visible; })); PubKeyCopyIcon.Dispatcher.BeginInvoke(new Action(() => { PubKeyCopyIcon.Visibility = Visibility.Visible; })); UpdateTextLabel(PublicKeyAddressLabel, publicAddress); } if (bchip.PkType != PKType.UNSET) { DisplayPrivateKeyButton.Dispatcher.BeginInvoke(new Action(() => { DisplayPrivateKeyButton.IsEnabled = true; })); } } }