Beispiel #1
0
        public GeneralSettingsTabViewModel()
        {
            _darkModeEnabled          = Services.UiConfig.DarkModeEnabled;
            _autoCopy                 = Services.UiConfig.Autocopy;
            _customFee                = Services.UiConfig.IsCustomFee;
            _customChangeAddress      = Services.UiConfig.IsCustomChangeAddress;
            _runOnSystemStartup       = Services.UiConfig.RunOnSystemStartup;
            _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), Services.UiConfig.FeeDisplayFormat)
                                ? (FeeDisplayFormat)Services.UiConfig.FeeDisplayFormat
                                : FeeDisplayFormat.SatoshiPerByte;

            this.WhenAnyValue(x => x.DarkModeEnabled)
            .Skip(1)
            .Subscribe(
                x =>
            {
                Services.UiConfig.DarkModeEnabled = x;
                Navigate(NavigationTarget.CompactDialogScreen).To(new ThemeChangeViewModel(x ? Theme.Dark : Theme.Light));
            });

            this.WhenAnyValue(x => x.AutoCopy)
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Skip(1)
            .Subscribe(x => Services.UiConfig.Autocopy = x);

            this.WhenAnyValue(x => x.RunOnSystemStartup)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Skip(1)
            .Subscribe(async runOnStartup =>
            {
                try
                {
                    await StartupHelper.ModifyStartupSettingAsync(runOnStartup);
                    Services.UiConfig.RunOnSystemStartup = runOnStartup;
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                    await ShowErrorAsync(Title, "Couldn't save your change, please see the logs for further information.", "Error occured.");
                }
            });

            this.WhenAnyValue(x => x.CustomFee)
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Skip(1)
            .Subscribe(x => Services.UiConfig.IsCustomFee = x);

            this.WhenAnyValue(x => x.CustomChangeAddress)
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Skip(1)
            .Subscribe(x => Services.UiConfig.IsCustomChangeAddress = x);

            this.WhenAnyValue(x => x.SelectedFeeDisplayFormat)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Skip(1)
            .Subscribe(x => Services.UiConfig.FeeDisplayFormat = (int)x);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public GeneralSettingsTabViewModel(Config config, UiConfig uiConfig) : base(config, uiConfig)
        {
            _darkModeEnabled          = uiConfig.DarkModeEnabled;
            _autoCopy                 = uiConfig.Autocopy;
            _customFee                = uiConfig.IsCustomFee;
            _customChangeAddress      = uiConfig.IsCustomChangeAddress;
            _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), uiConfig.FeeDisplayFormat)
                                ? (FeeDisplayFormat)uiConfig.FeeDisplayFormat
                                : FeeDisplayFormat.SatoshiPerByte;

            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);
        }
Beispiel #4
0
        public GeneralSettingsTabViewModel(Config config, UiConfig uiConfig) : base(config)
        {
            _darkModeEnabled          = uiConfig.DarkModeEnabled;
            _autoCopy                 = uiConfig.Autocopy;
            _customFee                = uiConfig.IsCustomFee;
            _customChangeAddress      = uiConfig.IsCustomChangeAddress;
            _selectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), uiConfig.FeeDisplayFormat)
                                ? (FeeDisplayFormat)uiConfig.FeeDisplayFormat
                                : FeeDisplayFormat.SatoshiPerByte;

            this.WhenAnyValue(x => x.DarkModeEnabled)
            .Skip(1)
            .Subscribe(
                x =>
            {
                uiConfig.DarkModeEnabled = x;
                Navigate(NavigationTarget.CompactDialogScreen).To(new ThemeChangeViewModel(x ? Theme.Dark : Theme.Light));
            });

            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);
        }
Beispiel #5
0
 public static MoneyUnit ToMoneyUnit(this FeeDisplayFormat feeDisplayFormat) =>
 feeDisplayFormat switch
 {