public TransactionViewModel(TransactionDetailsViewModel model, UiConfig uiConfig) { TransactionDetails = model; ClipboardNotificationVisible = false; ClipboardNotificationOpacity = 0; CopyTransactionId = ReactiveCommand.CreateFromTask(TryCopyTxIdToClipboardAsync); OpenTransactionInfo = ReactiveCommand.Create(() => { var shell = IoC.Get <IShell>(); var transactionInfo = shell.Documents?.OfType <TransactionInfoTabViewModel>()?.FirstOrDefault(x => x.Transaction?.TransactionId == TransactionId && x.Transaction?.WalletName == WalletName); if (transactionInfo is null) { transactionInfo = new TransactionInfoTabViewModel(TransactionDetails, uiConfig); shell.AddDocument(transactionInfo); } shell.Select(transactionInfo); }); Observable .Merge(CopyTransactionId.ThrownExceptions) .Merge(OpenTransactionInfo.ThrownExceptions) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(ex => { Logger.LogError(ex); NotificationHelpers.Error(ex.ToUserFriendlyString()); }); }
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); }
public WalletManagerViewModel(IScreen screen, WalletManager walletManager, UiConfig uiConfig) { Model = walletManager; _walletDictionary = new Dictionary <Wallet, WalletViewModelBase>(); _items = new ObservableCollection <WalletViewModelBase>(); _screen = screen; Observable .FromEventPattern <WalletState>(walletManager, nameof(WalletManager.WalletStateChanged)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { var wallet = x.Sender as Wallet; if (wallet is { } && _walletDictionary.ContainsKey(wallet)) { if (wallet.State == WalletState.Stopping) { RemoveWallet(_walletDictionary[wallet]); } else if (_walletDictionary[wallet] is ClosedWalletViewModel cwvm && wallet.State == WalletState.Started) { OpenClosedWallet(walletManager, uiConfig, cwvm); } } AnyWalletStarted = Items.OfType <WalletViewModelBase>().Any(x => x.WalletState == WalletState.Started); });
public JsonFileConfig() { ComConfig = new ComConfig(); AlgorithmPara = new AlgorithmPara(); UiConfig = new UiConfig(); PlotConfig = new PlotConfig(); }
public NewPasswordViewModel(ChaincaseWalletManager walletManager, Config config, UiConfig uiConfig, SensitiveStorage storage) { _walletManager = walletManager; _config = config; _uiConfig = uiConfig; _storage = storage; }
public OverviewViewModel(ChaincaseWalletManager walletManager, Config config, UiConfig uiConfig, BitcoinStore bitcoinStore, IMainThreadInvoker mainThreadInvoker) { _walletManager = walletManager; _config = config; _uiConfig = uiConfig; _bitcoinStore = bitcoinStore; _mainThreadInvoker = mainThreadInvoker; Transactions = new ObservableCollection <TransactionViewModel>(); if (_walletManager.HasDefaultWalletFile() && _walletManager.CurrentWallet == null) { _walletManager.SetDefaultWallet(); Task.Run(async() => await LoadWalletAsync()); TryWriteTableFromCache(); } _hasSeed = this.WhenAnyValue(x => x._uiConfig.HasSeed) .ToProperty(this, nameof(HasSeed)); _isBackedUp = this.WhenAnyValue(x => x._uiConfig.IsBackedUp) .ToProperty(this, nameof(IsBackedUp)); var canBackUp = this.WhenAnyValue(x => x.HasSeed, x => x.IsBackedUp, (hasSeed, isBackedUp) => hasSeed && !isBackedUp); canBackUp.ToProperty(this, x => x.CanBackUp, out _canBackUp); Balance = _uiConfig.Balance; Initializing += OnInit; Initializing(this, EventArgs.Empty); }
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); }
public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig) { Model = walletManager; _walletDictionary = new Dictionary <Wallet, WalletViewModelBase>(); _walletActionsDictionary = new Dictionary <WalletViewModelBase, List <NavBarItemViewModel> >(); _actions = new ObservableCollection <NavBarItemViewModel>(); _wallets = new ObservableCollection <WalletViewModelBase>(); _loggedInAndSelectedAlwaysFirst = true;
public static WalletViewModel Create(UiConfig uiConfig, Wallet wallet) { return(wallet.KeyManager.IsHardwareWallet ? new HardwareWalletViewModel(uiConfig, wallet) : wallet.KeyManager.IsWatchOnly ? new WatchOnlyWalletViewModel(uiConfig, wallet) : new WalletViewModel(uiConfig, wallet)); }
/// <summary> /// Binds JSON data with id only without any ui configuration. /// Default values will be used for ui configuration. /// </summary> public void BindAction(dynamic a, int id) { action = a; uiConfig = new UiConfig(); Id = id; BindActionToUi(); ApplyUi(); }
/// <summary> /// Binds the supplied parameters into action, uiConfig, and Id variables. /// Then it calls underlying methods that make sure the changes are reflected into UI. /// </summary> public void BindRecording(Recording r, int id) { action = r.Action; uiConfig = r.UiConfig; Id = id; BindActionToUi(); ApplyUi(); }
protected SettingsTabViewModelBase(Config config, UiConfig uiConfig) { ConfigOnOpen = new Config(config.FilePath); ConfigOnOpen.LoadFile(); UiConfigOnOpen = new UiConfig(uiConfig.FilePath); UiConfigOnOpen.LoadFile(); }
public WalletInfoViewModel(ChaincaseWalletManager walletManager, Config config, UiConfig uiConfig, IShare share, IDataDirProvider dataDirProvider) { _walletManager = walletManager; _config = config; _uiConfig = uiConfig; _share = share; _dataDirProvider = dataDirProvider; }
public BackUpViewModel(Config config, UiConfig uiConfig, IHsmStorage hsm, SensitiveStorage storage, ChaincaseWalletManager walletManager) { _config = config; _uiConfig = uiConfig; _hsm = hsm; _storage = storage; _walletManager = walletManager; }
public SettingsPageViewModel(Config config, UiConfig uiConfig) { _selectedTab = 0; GeneralSettingsTab = new GeneralSettingsTabViewModel(config, uiConfig); PrivacySettingsTab = new PrivacySettingsTabViewModel(config); NetworkSettingsTab = new NetworkSettingsTabViewModel(config); BitcoinTabSettings = new BitcoinTabSettingsViewModel(config); }
public PinLockScreenViewModel(UiConfig uiConfig) : base() { KeyPadCommand = ReactiveCommand.Create <string>((arg) => { if (arg == "BACK") { if (PinInput.Length > 0) { PinInput = PinInput[0..^ 1]; }
//获取UI的路径 public string GetPathByName(string windowName) { UiConfig uiCfg = GetUiConfigByName(windowName); if (uiCfg != null) { return(uiCfg.m_WindowPath); } return(null); }
public void SetPanelVisibility(UiConfig config) { _layoutRight.Visible = config.ShowRightPanel; _panelFilters.Visible = config.ShowTopPanel; _panelMenu.Visible = _buttonShowScrollCards.Visible = _labelStatusScrollCards.Visible = config.ShowSearchBar; }
public PrivacySettingsTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig) { _minimalPrivacyLevel = config.PrivacyLevelSome; _mediumPrivacyLevel = config.PrivacyLevelFine; _strongPrivacyLevel = config.PrivacyLevelStrong; this.WhenAnyValue( x => x.MinimalPrivacyLevel, x => x.MediumPrivacyLevel, x => x.StrongPrivacyLevel) .ObserveOn(RxApp.TaskpoolScheduler) .Throttle(TimeSpan.FromMilliseconds(ThrottleTime)) .Skip(1) .Subscribe(_ => Save()); this.WhenAnyValue(x => x.MinimalPrivacyLevel) .Subscribe( x => { if (x >= MediumPrivacyLevel) { MediumPrivacyLevel = x + 1; } }); this.WhenAnyValue(x => x.MediumPrivacyLevel) .Subscribe( x => { if (x >= StrongPrivacyLevel) { StrongPrivacyLevel = x + 1; } if (x <= MinimalPrivacyLevel) { MinimalPrivacyLevel = x - 1; } }); this.WhenAnyValue(x => x.StrongPrivacyLevel) .Subscribe( x => { if (x <= MinimalPrivacyLevel) { MinimalPrivacyLevel = x - 1; } if (x <= MediumPrivacyLevel) { MediumPrivacyLevel = x - 1; } }); }
public async Task Unsupported_DotNet_Framework_Should_Return_404_NotFound() { // Arrange var config = new UiConfig { Name = new UiConfig.Text { Default = "my project name" }, Description = new UiConfig.Text { Default = "my description" }, Namespace = new UiConfig.Text { Default = "my namespace" }, SteeltoeVersion = new UiConfig.SingleSelectList { Default = "0.0" }, DotNetFramework = new UiConfig.SingleSelectList { Default = "0.0" }, Dependencies = new UiConfig.GroupList { Values = new[] { new UiConfig.Group { Values = new[] { new UiConfig.GroupItem { Id = "MyDep", DotNetFrameworkRange = "1.0" }, }, }, }, }, }; var controller = new ProjectControllerBuilder() .WithInitializrConfiguration(config) .Build(); var spec = new ProjectSpec { Dependencies = "mydep", }; // Act var unknown = await controller.GetProjectArchive(spec); var result = Assert.IsType <NotFoundObjectResult>(unknown); // Assert result.Value.ToString().Should().Be("No dependency 'mydep' found for .NET framework 0.0."); }
private static void InitializeSteeltoeVersions(UiConfig config) { var versions = new List <string>(); foreach (var version in config.SteeltoeVersion.Values) { versions.Add(version.Id); } SteeltoeVersions = versions.ToArray(); }
private static void InitializeDotNetFrameworks(UiConfig config) { var frameworks = new List <string>(); foreach (var framework in config.DotNetFramework.Values) { frameworks.Add(framework.Id); } DotNetFrameworks = frameworks.ToArray(); }
public WalletManagerViewModel(WalletManager walletManager, UiConfig uiConfig, BitcoinStore bitcoinStore, LegalChecker legalChecker, TransactionBroadcaster broadcaster) { WalletManager = walletManager; BitcoinStore = bitcoinStore; LegalChecker = legalChecker; _walletDictionary = new Dictionary <Wallet, WalletViewModelBase>(); _walletActionsDictionary = new Dictionary <WalletViewModelBase, List <NavBarItemViewModel> >(); _actions = new ObservableCollection <NavBarItemViewModel>(); _wallets = new ObservableCollection <WalletViewModelBase>(); _loggedInAndSelectedAlwaysFirst = true; _transactionBroadcaster = broadcaster;
/*判断是否有全屏UI显示*/ public bool IsAnyExclusionWindowVisble() { foreach (string name in m_VisibleWindow.Keys) { UiConfig uiCfg = GetUiConfigByName(name); if (uiCfg != null && uiCfg.m_IsExclusion) { return(true); } } return(false); }
private static void InitializeDependencies(UiConfig config) { var deps = new List <string>(); foreach (var group in config.Dependencies.Values) { foreach (var item in group.Values) { deps.Add(item.Id); } } Dependencies = deps.ToArray(); }
public void CanStoreSeedWords() { var testDir = EnvironmentHelpers.GetDataDir(Path.Combine("Chaincase", "Tests", "StorageTests")); var config = new Config(Path.Combine(testDir, "Config.json")); var uiConfig = new UiConfig(Path.Combine(testDir, "UiConfig.json")); SensitiveStorage storage = new(new MockHsmStorage(), config, uiConfig); string password = "******"; Mnemonic mnemonic = new(Wordlist.English); storage.SetSeedWords(password, mnemonic.ToString()); var gotSeedWords = storage.GetSeedWords(password).Result; Assert.True(gotSeedWords == mnemonic.ToString()); }
public GeneralSettingsTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig) { this.ValidateProperty(x => x.DustThreshold, ValidateDustThreshold); _darkModeEnabled = uiConfig.DarkModeEnabled; _autoCopy = uiConfig.Autocopy; _customFee = uiConfig.IsCustomFee; _customChangeAddress = uiConfig.IsCustomChangeAddress; _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), uiConfig.FeeDisplayFormat) ? (FeeDisplayFormat)uiConfig.FeeDisplayFormat : FeeDisplayFormat.SatoshiPerByte; _dustThreshold = config.DustThreshold.ToString(); this.WhenAnyValue(x => x.DustThreshold) .ObserveOn(RxApp.TaskpoolScheduler) .Throttle(TimeSpan.FromMilliseconds(ThrottleTime)) .Skip(1) .Subscribe(_ => Save()); this.WhenAnyValue(x => x.DarkModeEnabled) .Skip(1) .Subscribe( x => { uiConfig.DarkModeEnabled = x; IsRestartNeeded(x); }); this.WhenAnyValue(x => x.AutoCopy) .ObserveOn(RxApp.TaskpoolScheduler) .Skip(1) .Subscribe(x => uiConfig.Autocopy = x); this.WhenAnyValue(x => x.CustomFee) .ObserveOn(RxApp.TaskpoolScheduler) .Skip(1) .Subscribe(x => uiConfig.IsCustomFee = x); this.WhenAnyValue(x => x.CustomChangeAddress) .ObserveOn(RxApp.TaskpoolScheduler) .Skip(1) .Subscribe(x => uiConfig.IsCustomChangeAddress = x); this.WhenAnyValue(x => x.SelectedFeeDisplayFormat) .ObserveOn(RxApp.MainThreadScheduler) .Skip(1) .Subscribe(x => uiConfig.FeeDisplayFormat = (int)x); }
public async Task Configuration_Should_Specify_Defaults() { // Arrange var config = new UiConfig { Name = new UiConfig.Text { Default = "my project name" }, Description = new UiConfig.Text { Default = "my description" }, Namespace = new UiConfig.Text { Default = "my namespace" }, SteeltoeVersion = new UiConfig.SingleSelectList { Default = "3.0.0" }, DotNetFramework = new UiConfig.SingleSelectList { Default = "netcoreapp3.1" }, Language = new UiConfig.SingleSelectList { Default = "my language" }, Packaging = new UiConfig.SingleSelectList { Default = "myarchive" }, }; var controller = new ProjectControllerBuilder() .WithInitializrConfiguration(config) .Build(); // Act var unknown = await controller.GetProjectArchive(new ProjectSpec()); var result = Assert.IsType <FileContentResult>(unknown); var projectPackage = Encoding.ASCII.GetString(result.FileContents); // Assert projectPackage.Should().Contain("project name=my project name"); projectPackage.Should().Contain("namespace=my namespace"); projectPackage.Should().Contain("description=my description"); projectPackage.Should().Contain("steeltoe version=3.0.0"); projectPackage.Should().Contain("dotnet framework=netcoreapp3.1"); projectPackage.Should().Contain("language=my language"); projectPackage.Should().Contain("packaging=myarchive"); projectPackage.Should().Contain("dependencies=<na>"); }
public void Properties_Should_Be_Defined() { // Arrange var uiConfig = new UiConfig(); // Act // Assert uiConfig.Name.Should().BeNull(); uiConfig.Namespace.Should().BeNull(); uiConfig.Description.Should().BeNull(); uiConfig.SteeltoeVersion.Should().BeNull(); uiConfig.DotNetFramework.Should().BeNull(); uiConfig.Language.Should().BeNull(); uiConfig.Packaging.Should().BeNull(); uiConfig.Dependencies.Should().NotBeNull(); }
public NetworkSettingsTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig) { this.ValidateProperty(x => x.TorSocks5EndPoint, ValidateTorSocks5EndPoint); _useTor = config.UseTor; _terminateTorOnExit = config.TerminateTorOnExit; _torSocks5EndPoint = config.TorSocks5EndPoint.ToString(-1); this.WhenAnyValue( x => x.UseTor, x => x.TerminateTorOnExit, x => x.TorSocks5EndPoint) .ObserveOn(RxApp.TaskpoolScheduler) .Throttle(TimeSpan.FromMilliseconds(ThrottleTime)) .Skip(1) .Subscribe(_ => Save()); }
public QueryPublisher(UiConfig _config) { config = _config; InitializeComponent(); try { selectedReports.Clear(); selectedArgs.Clear(); GetUsers(); //SetOutputExtension(); } catch (Exception ex) { log.Error(ex); } }