public ManualCoinJoinProfileDialogViewModel(CoinJoinProfileViewModelBase current)
    {
        _autoCoinjoin       = true;
        _minAnonScoreTarget = current.MinAnonScoreTarget.ToString();
        _maxAnonScoreTarget = current.MaxAnonScoreTarget.ToString();
        _timeFrames         = new[]
        {
            new TimeFrameItem("Hours", TimeSpan.Zero),
            new TimeFrameItem("Days", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[0])),
            new TimeFrameItem("Weeks", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[1])),
            new TimeFrameItem("Months", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[2]))
        };

        _selectedTimeFrame = _timeFrames.FirstOrDefault(tf => tf.TimeFrame == TimeSpan.FromHours(current.FeeRateMedianTimeFrameHours)) ?? _timeFrames.First();

        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);
        EnableBack = false;

        NextCommand = ReactiveCommand.Create(() =>
        {
            var auto  = AutoCoinjoin;
            var min   = int.Parse(MinAnonScoreTarget);
            var max   = int.Parse(MaxAnonScoreTarget);
            var hours = (int)Math.Floor(SelectedTimeFrame.TimeFrame.TotalHours);

            Close(DialogResultKind.Normal, new ManualCoinJoinProfile(auto, min, max, hours));
        });

        this.ValidateProperty(x => x.MinAnonScoreTarget, errors => ValidateInteger(MinAnonScoreTarget, nameof(MinAnonScoreTarget), errors));
        this.ValidateProperty(x => x.MaxAnonScoreTarget, errors => ValidateInteger(MaxAnonScoreTarget, nameof(MaxAnonScoreTarget), errors));
    }
Пример #2
0
    public ManualCoinJoinProfileDialogViewModel(CoinJoinProfileViewModelBase current, bool autoCoinJoin)
    {
        _autoCoinjoin = autoCoinJoin;

        _anonScoreTarget = current.AnonScoreTarget;

        _timeFrames = new[]
        {
            new TimeFrameItem("Hours", TimeSpan.Zero),
            new TimeFrameItem("Days", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[0])),
            new TimeFrameItem("Weeks", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[1])),
            new TimeFrameItem("Months", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[2]))
        };

        _selectedTimeFrame = _timeFrames.FirstOrDefault(tf => tf.TimeFrame == TimeSpan.FromHours(current.FeeRateMedianTimeFrameHours)) ?? _timeFrames.First();

        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

        EnableBack = false;

        NextCommand = ReactiveCommand.Create(() =>
        {
            var auto   = AutoCoinjoin;
            var target = AnonScoreTarget;
            var hours  = (int)Math.Floor(SelectedTimeFrame.TimeFrame.TotalHours);

            Close(DialogResultKind.Normal, new ManualCoinJoinProfileDialogViewModelResult(AutoCoinjoin, new ManualCoinJoinProfileViewModel(target, hours)));
        });
    }
    public ManualCoinJoinProfileDialogViewModel(CoinJoinProfileViewModelBase current)
    {
        _autoCoinjoin = true;

        _minAnonScoreTarget = current.MinAnonScoreTarget;
        _maxAnonScoreTarget = current.MaxAnonScoreTarget;

        _timeFrames = new[]
        {
            new TimeFrameItem("Hours", TimeSpan.Zero),
            new TimeFrameItem("Days", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[0])),
            new TimeFrameItem("Weeks", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[1])),
            new TimeFrameItem("Months", TimeSpan.FromHours(Constants.CoinJoinFeeRateMedianTimeFrames[2]))
        };

        _selectedTimeFrame = _timeFrames.FirstOrDefault(tf => tf.TimeFrame == TimeSpan.FromHours(current.FeeRateMedianTimeFrameHours)) ?? _timeFrames.First();

        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

        EnableBack = false;

        this.WhenAnyValue(x => x.MinAnonScoreTarget)
        .Subscribe(
            x =>
        {
            if (x >= MaxAnonScoreTarget)
            {
                MaxAnonScoreTarget = x + 1;
            }
        });

        this.WhenAnyValue(x => x.MaxAnonScoreTarget)
        .Subscribe(
            x =>
        {
            if (x <= MinAnonScoreTarget)
            {
                MinAnonScoreTarget = x - 1;
            }
        });


        NextCommand = ReactiveCommand.Create(() =>
        {
            var auto  = AutoCoinjoin;
            var min   = MinAnonScoreTarget;
            var max   = MaxAnonScoreTarget;
            var hours = (int)Math.Floor(SelectedTimeFrame.TimeFrame.TotalHours);

            Close(DialogResultKind.Normal, new ManualCoinJoinProfileViewModel(auto, min, max, hours));
        });
    }