public void UpdateTransaction(BuildTransactionResult transactionResult, TransactionInfo info)
    {
        _transaction = transactionResult;

        ConfirmationTimeText = $"Approximately {TextHelpers.TimeSpanToFriendlyString(info.ConfirmationTimeSpan)} ";

        var destinationAmount = _transaction.CalculateDestinationAmount();
        var btcAmountText     = $"{destinationAmount.ToFormattedString()} BTC";
        var fiatAmountText    = destinationAmount.ToDecimal(MoneyUnit.BTC).GenerateFiatText(_wallet.Synchronizer.UsdExchangeRate, "USD");

        AmountText = $"{btcAmountText} {fiatAmountText}";

        var fee         = _transaction.Fee;
        var feeText     = fee.ToFeeDisplayUnitString();
        var fiatFeeText = fee.ToDecimal(MoneyUnit.BTC).GenerateFiatText(_wallet.Synchronizer.UsdExchangeRate, "USD");

        FeeText = $"{feeText} {fiatFeeText}";

        TransactionHasChange =
            _transaction.InnerWalletOutputs.Any(x => x.ScriptPubKey != _address.ScriptPubKey);

        TransactionHasPockets = !info.IsPrivate;

        Labels = SmartLabel.Merge(transactionResult.SpentCoins.Select(x => x.GetLabels(info.PrivateCoinThreshold)));
        var exactPocketUsed = Labels.Count() == info.UserLabels.Count() && Labels.All(label => info.UserLabels.Contains(label, StringComparer.OrdinalIgnoreCase));

        TransactionHasPockets = Labels.Any() && !exactPocketUsed;

        IsCustomFeeUsed = info.IsCustomFeeUsed;
        IsOtherPocketSelectionPossible = info.IsOtherPocketSelectionPossible;
    }
Exemple #2
0
        public IssueUpdate ToUpdate()
        {
            var milestoneId = Milestone == null
                ? new int?()
                : Milestone.Number;

            var assignee = Assignee == null
                ? null
                : Assignee.Name;

            var issueUpdate = new IssueUpdate
            {
                Assignee  = assignee,
                Body      = Body,
                Milestone = milestoneId,
                State     = State,
                Title     = Title
            };

            if (Labels.Any())
            {
                issueUpdate.Labels = new List <string>(Labels.Select(l => l.Name));
            }

            return(issueUpdate);
        }
Exemple #3
0
        /// <summary>
        /// Fires the action that prints the labels to networked printers
        /// </summary>
        public void PrintNetworkLabels()
        {
            var printQueue = new Dictionary <string, StringBuilder>();

            // Print server labels
            if (Labels.Any(l => l.PrintFrom == Rock.Model.PrintFrom.Server))
            {
                string delayCut     = @"^XB";
                string endingTag    = @"^XZ";
                var    printerIp    = string.Empty;
                var    labelContent = new StringBuilder();

                // make sure labels have a valid ip
                var lastLabel = Labels.Last();
                foreach (var label in Labels.Where(l => l.PrintFrom == PrintFrom.Server && !string.IsNullOrEmpty(l.PrinterAddress)))
                {
                    var labelCache = KioskLabel.Get(label.FileGuid);
                    if (labelCache != null)
                    {
                        if (printerIp != label.PrinterAddress)
                        {
                            printQueue.AddOrReplace(label.PrinterAddress, labelContent);
                            printerIp    = label.PrinterAddress;
                            labelContent = new StringBuilder();
                        }

                        var printContent = labelCache.FileContent;
                        foreach (var mergeField in label.MergeFields)
                        {
                            if (!string.IsNullOrWhiteSpace(mergeField.Value))
                            {
                                printContent = Regex.Replace(printContent, string.Format(@"(?<=\^FD){0}(?=\^FS)", mergeField.Key), ZebraFormatString(mergeField.Value));
                            }
                            else
                            {
                                printContent = Regex.Replace(printContent, string.Format(@"\^FO.*\^FS\s*(?=\^FT.*\^FD{0}\^FS)", mergeField.Key), string.Empty);
                                printContent = Regex.Replace(printContent, string.Format(@"\^FD{0}\^FS", mergeField.Key), "^FD^FS");
                            }
                        }

                        // send a Delay Cut command at the end to prevent cutting intermediary labels
                        if (label != lastLabel)
                        {
                            printContent = Regex.Replace(printContent.Trim(), @"\" + endingTag + @"$", delayCut + endingTag);
                        }

                        labelContent.Append(printContent);
                    }
                }

                printQueue.AddOrReplace(printerIp, labelContent);
            }

            if (printQueue.Any())
            {
                SendNetworkPrintData(printQueue);
                printQueue.Clear();
            }
        }
Exemple #4
0
        public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster) : base(NavigationMode.Normal)
        {
            _to                    = "";
            _owner                 = walletVm;
            _transactionInfo       = new TransactionInfo();
            _labels                = new ObservableCollection <string>();
            _lastXAxisCurrentValue = _xAxisCurrentValue;

            ExchangeRate = walletVm.Wallet.Synchronizer.UsdExchangeRate;
            PriorLabels  = new();

            this.ValidateProperty(x => x.To, ValidateToField);
            this.ValidateProperty(x => x.AmountBtc, ValidateAmount);

            this.WhenAnyValue(x => x.To)
            .Subscribe(ParseToField);

            this.WhenAnyValue(x => x.AmountBtc)
            .Subscribe(x => _transactionInfo.Amount = new Money(x, MoneyUnit.BTC));

            this.WhenAnyValue(x => x.XAxisCurrentValue)
            .Subscribe(x =>
            {
                if (x > 0)
                {
                    _transactionInfo.FeeRate = new FeeRate(GetYAxisValueFromXAxisCurrentValue(x));
                    SetXAxisCurrentValueIndex(x);
                }
            });

            this.WhenAnyValue(x => x.XAxisCurrentValueIndex)
            .Subscribe(SetXAxisCurrentValue);

            Labels.ToObservableChangeSet().Subscribe(x => _transactionInfo.Labels = new SmartLabel(_labels.ToArray()));

            EnableCancel = true;

            EnableBack = true;

            PasteCommand = ReactiveCommand.CreateFromTask(async() => await OnPaste());

            var nextCommandCanExecute =
                this.WhenAnyValue(x => x.Labels, x => x.AmountBtc, x => x.To, x => x.XAxisCurrentValue).Select(_ => Unit.Default)
                .Merge(Observable.FromEventPattern(Labels, nameof(Labels.CollectionChanged)).Select(_ => Unit.Default))
                .Select(_ =>
            {
                var allFilled = !string.IsNullOrEmpty(To) && AmountBtc > 0 && Labels.Any();
                var hasError  = Validations.Any;

                return(allFilled && !hasError);
            });

            NextCommand = ReactiveCommand.CreateFromTask(async() => await OnNext(broadcaster), nextCommandCanExecute);

            EnableAutoBusyOn(NextCommand);
        }
Exemple #5
0
 /// <summary>
 /// Returns javascript to print labels over usb
 /// </summary>
 /// <returns></returns>
 public string GetClientScript()
 {
     // Print client labels
     if (Labels.Any(l => l.PrintFrom == Rock.Model.PrintFrom.Client))
     {
         var clientLabels = Labels.Where(l => l.PrintFrom == PrintFrom.Client).ToList();
         var urlRoot      = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
         clientLabels.ForEach(l => l.LabelFile = urlRoot + l.LabelFile);
         return(AddLabelScript(clientLabels.ToJson()));
     }
     return("");
 }
Exemple #6
0
        /// <summary>
        /// Add only knowned attributes
        /// avoid duplicated label
        /// avoid null key
        /// </summary>
        public void AddNewLabel(Label label)
        {
            if (string.IsNullOrEmpty(label.Key))
            {
                throw new KeyLabelMediaException(this);
            }

            if (Labels.Any(l => l.Equals(label)))
            {
                throw new DuplicatedMediaLabelException(label, this);
            }

            Labels.Add(label);
        }
Exemple #7
0
        public SmartLabel(IEnumerable <string> labels)
        {
            labels ??= Enumerable.Empty <string>();
            Labels = labels
                     .SelectMany(x => x?.Split(Separators, StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty <string>())
                     .Select(x => x.Trim())
                     .Where(x => x.Length != 0)
                     .Distinct(StringComparer.OrdinalIgnoreCase)
                     .OrderBy(x => x)
                     .ToArray();

            IsEmpty = !Labels.Any();

            LabelString = string.Join(", ", Labels);
        }
Exemple #8
0
        private void UpdateLabels(CocApi cocApi, ClanApiModel downloadedClan)
        {
            if (Labels == null && downloadedClan.Labels == null)
            {
                return;
            }

            if (Labels != null && Labels.Count() > 0 && (downloadedClan.Labels == null || downloadedClan.Labels.Count() == 0))
            {
                cocApi.ClanLabelsRemovedEvent(downloadedClan, Labels);

                //Labels = downloadedClan.Labels;
            }
            else if ((Labels == null || Labels.Count() == 0) && downloadedClan.Labels != null && downloadedClan.Labels.Count() > 0)
            {
                cocApi.ClanLabelsAddedEvent(downloadedClan, downloadedClan.Labels);

                //Labels = downloadedClan.Labels;
            }
            else
            {
                List <ClanLabelApiModel> added = new List <ClanLabelApiModel>();

                List <ClanLabelApiModel> removed = new List <ClanLabelApiModel>();

                foreach (ClanLabelApiModel labelApiModel in Labels.EmptyIfNull())
                {
                    if (!downloadedClan.Labels.Any(l => l.Id == labelApiModel.Id))
                    {
                        removed.Add(labelApiModel);
                    }
                }

                foreach (ClanLabelApiModel labelApiModel in downloadedClan.Labels.EmptyIfNull())
                {
                    if (!Labels.Any(l => l.Id == labelApiModel.Id))
                    {
                        added.Add(labelApiModel);
                    }
                }

                cocApi.ClanLabelsRemovedEvent(downloadedClan, removed);

                cocApi.ClanLabelsAddedEvent(downloadedClan, added);

                //Labels = downloadedClan.Labels;
            }
        }
Exemple #9
0
        public SmartLabel(IEnumerable <string> labels)
        {
            labels ??= Enumerable.Empty <string>();
            Labels = labels
                     .SelectMany(x => x?.Split(Separators, StringSplitOptions.RemoveEmptyEntries) ?? new string[0])
                     .Select(x => x.Trim())
                     .Where(x => x != "")
                     .Distinct(StringComparer.OrdinalIgnoreCase)
                     .OrderBy(x => x)
                     .ToArray();

            HashCode = ((IStructuralEquatable)Labels).GetHashCode(EqualityComparer <string> .Default);
            IsEmpty  = !Labels.Any();

            LabelString = string.Join(", ", Labels);
        }
Exemple #10
0
        public void AddToQueryString(QueryStringBuilder qsb)
        {
            if (State.HasValue)
            {
                qsb.SetValue("state", State.Value == IssueState.Opened ? "opened" : "closed");
            }

            if (Labels != null && Labels.Any())
            {
                qsb.SetValue("labels", Labels.Aggregate((acc, x) => acc + "," + x));
            }

            if (!string.IsNullOrEmpty(Milestone))
            {
                qsb.SetValue("milestone", Milestone);
            }
        }
        public void ExecuteNext(CancellationToken ct)
        {
            if (ProgramIterator >= _programCode.Length - 1 || ct.IsCancellationRequested)
            {
                EndOfExecutionEvent?.Invoke(this, EventArgs.Empty);
                return;
            }

            switch (_programCode[ProgramIterator])
            {
            case var word when new Regex(@"Put this ([^ ]*?) pancake on top!").IsMatch(word):
            {
                var match = Regex.Match(word, @"Put this ([^ ]*?) pancake on top!");
                PancakeStack.Push(match.Groups[1].Value.Length);
                break;
            }

            case "Eat the pancake on top!":
                if (CheckPancakeStackCount(1))
                {
                    PancakeStack.Pop();
                }
                break;

            case "Put the top pancakes together!":
            {
                if (CheckPancakeStackCount(2))
                {
                    var firstTopItem  = PancakeStack.Pop();
                    var secondTopItem = PancakeStack.Pop();
                    PancakeStack.Push(firstTopItem + secondTopItem);
                }
                break;
            }

            case "Give me a pancake!":
                Input = "";

                while (string.IsNullOrEmpty(Input))
                {
                    if (ct.IsCancellationRequested)
                    {
                        break;
                    }

                    WaitingForInputEvent?.Invoke(this, new WaitingForInputEventArgs()
                    {
                        Type = InputType.Numeric
                    });
                    WaitHandle.WaitOne();
                }

                if (!ct.IsCancellationRequested)
                {
                    if (CheckIfValueIsInt32(Input))
                    {
                        PancakeStack.Push(Convert.ToInt32(Input));
                        Input = "";
                    }
                }
                break;

            case "How about a hotcake?":
                while (string.IsNullOrEmpty(Input))
                {
                    if (ct.IsCancellationRequested)
                    {
                        break;
                    }

                    WaitingForInputEvent?.Invoke(this, new WaitingForInputEventArgs()
                    {
                        Type = InputType.Alphanumeric
                    });
                    WaitHandle.WaitOne();
                }

                if (!ct.IsCancellationRequested)
                {
                    PancakeStack.Push(Input[0]);
                    Input = Input.Remove(0, 1);     // imitate console buffer
                }
                break;

            case "Show me a pancake!":
                if (CheckPancakeStackCount(1))
                {
                    NewOutputEvent?.Invoke(this, new OutputEventArgs()
                    {
                        Type = OutputType.Character, CharacterOutput = (char)PancakeStack.Peek()
                    });
                }
                break;

            case "Take from the top pancakes!":
            {
                if (CheckPancakeStackCount(2))
                {
                    var firstTopItem  = PancakeStack.Pop();
                    var secondTopItem = PancakeStack.Pop();
                    PancakeStack.Push(firstTopItem - secondTopItem);
                }
                break;
            }

            case "Flip the pancakes on top!":
            {
                if (CheckPancakeStackCount(2))
                {
                    var firstTopItem  = PancakeStack.Pop();
                    var secondTopItem = PancakeStack.Pop();
                    PancakeStack.Push(firstTopItem);
                    PancakeStack.Push(secondTopItem);
                }
                break;
            }

            case "Put another pancake on top!":
            {
                if (CheckPancakeStackCount(1))
                {
                    var topItem = PancakeStack.Pop();
                    PancakeStack.Push(topItem);
                    PancakeStack.Push(topItem);
                }
                break;
            }

            case var label when new Regex(@"\[(.*)\]").IsMatch(label):
            {
                if (CheckPancakeStackCount(1))
                {
                    var match = Regex.Match(label, @"\[(.*)\]");
                    if (Labels.Any(item => item.Key == match.Groups[1].Value))
                    {
                        break;
                    }

                    Labels[match.Groups[1].Value] = PancakeStack.Peek() - 2;         //Pancake stack language start counting lines from 1
                    LabelDictionaryChangedEvent?.Invoke(this, Labels);
                }
                break;
            }

            case var label when new Regex(@"If the pancake isn't tasty, go over to ""(.*)"".").IsMatch(label):
            {
                var match = Regex.Match(label, @"If the pancake isn't tasty, go over to ""(.*)"".");

                if (CheckPancakeStackCount(1) && CheckIfLabelExist(match.Groups[1].Value))
                {
                    if (PancakeStack.Peek() == 0)
                    {
                        ProgramIterator = Labels[match.Groups[1].Value];
                    }
                }
                break;
            }

            case var label when new Regex(@"If the pancake is tasty, go over to ""(.*)"".").IsMatch(label):
            {
                var match = Regex.Match(label, @"If the pancake is tasty, go over to ""(.*)"".");

                if (CheckPancakeStackCount(1) && CheckIfLabelExist(match.Groups[1].Value))
                {
                    if (PancakeStack.Peek() != 0)
                    {
                        ProgramIterator = Labels[match.Groups[1].Value];
                    }
                }
                break;
            }

            case "Put syrup on the pancakes!":
                PancakeStack = new Stack <int>(PancakeStack.Select(item => item + 1).Reverse());
                break;

            case "Put butter on the pancakes!":
            {
                if (CheckPancakeStackCount(1))
                {
                    var topItem = PancakeStack.Pop();
                    PancakeStack.Push(topItem + 1);
                }
                break;
            }

            case "Take off the syrup!":
                PancakeStack = new Stack <int>(PancakeStack.Select(item => item - 1).Reverse());
                break;

            case "Take off the butter!":
            {
                if (CheckPancakeStackCount(1))
                {
                    var topItem = PancakeStack.Pop();
                    PancakeStack.Push(topItem - 1);
                }
                break;
            }

            case "Show me a numeric pancake!":
                if (CheckPancakeStackCount(1))
                {
                    NewOutputEvent?.Invoke(this, new OutputEventArgs()
                    {
                        Type = OutputType.Line, LineOutput = PancakeStack.Peek().ToString()
                    });
                }
                break;

            case "Eat all of the pancakes!":
                ProgramIterator = _programCode.Length;
                return;
            }

            PancakeStackChangedEvent?.Invoke(this, PancakeStack);
            ProgramIterator++;
        }
 public bool IsBugFix()
 {
     return(Labels.Any(x => x.ToLower() == "category: bug"));
 }
Exemple #13
0
 public override string ToString()
 {
     return(Labels.Any()
         ? $"[{string.Join("][", Labels)}] {Name}"
         : Name.ToString());
 }
Exemple #14
0
 /// <summary>
 ///     Returns true if the path has the specified label, else return false.
 /// </summary>
 /// <param name="key">The label to search for.</param>
 /// <returns>True if the label exists in the path.</returns>
 public bool ContainsKey(string key)
 {
     return(Labels.Any(objLabels => objLabels.Contains(key)));
 }
Exemple #15
0
 public override string ToString()
 {
     return(String.Format("[{0}] {1} = {2}\t{3}", Timestamp, ColumnName, Labels.Any() ? String.Concat("[", String.Join(", ", Labels), "]") : String.Empty));
 }
Exemple #16
0
 private void AddContainerLabels(IList <string> arguments)
 {
     arguments.AddConditionally(
         Labels.Any(),
         $"{string.Join(" ", Labels.Select(pair => $"--label {pair.Key}=\"{pair.Value}\""))}");
 }
        public override string ToString()
        {
            var labels = Labels.Any() ? $"-{string.Join(".", Labels)}" : string.Empty;

            return($"{Major}.{Minor}.{Patch}{labels}");
        }
 public bool IsHousekeeping()
 {
     return(Labels.Any(x => x.ToLower() == "category: housekeeping"));
 }
 public bool IsFeature()
 {
     return(Labels.Any(x => x.ToLower() == "category: feature"));
 }
Exemple #20
0
        public void LogParameters(ILogger logger)
        {
            using var contentsScope = logger.BeginScope("Using create container parameters");

            logger.LogInformation($"Container name '{ContainerName}'");
            logger.LogInformation($"Container image: '{ImageId.FullName}");
            logger.LogInformation($"Network name: {ImageId.FullName}");

            using (logger.BeginScope("Labels"))
            {
                if (!Labels.Any())
                {
                    logger.LogError("No labels are configured for this container!");
                }

                foreach (var(name, value) in Labels)
                {
                    logger.LogInformation($"{name}: {value}");
                }
            }

            using (logger.BeginScope("Environment variables"))
            {
                if (!EnvironmentVariables.Any())
                {
                    logger.LogInformation("No environment variables are set");
                }

                foreach (var variable in EnvironmentVariables)
                {
                    logger.LogInformation(variable);
                }
            }

            using (logger.BeginScope("Volume mounts"))
            {
                if (!Mounts.Any())
                {
                    logger.LogWarning("There are no volume mounts specified for this container");
                }

                foreach (var mount in Mounts)
                {
                    logger.LogInformation($"Volume '{mount.Source}' mounted to '{mount.Target}'");
                }
            }

            using (logger.BeginScope("Port bindings"))
            {
                if (!PortBindings.Any())
                {
                    logger.LogWarning("There are no port bindings specified for this container");
                }

                foreach (var(containerPort, hostBindings) in PortBindings)
                {
                    foreach (var binding in hostBindings)
                    {
                        logger.LogInformation(
                            $"Container port {containerPort} is bound to {binding.HostIP}:{binding.HostPort}"
                            );
                    }
                }
            }
        }
 public bool IsDoc()
 {
     return(Labels.Any(x => x.ToLower() == "category: docs-and-samples"));
 }
Exemple #22
0
        public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster)
        {
            _to                    = "";
            _owner                 = walletVm;
            _transactionInfo       = new TransactionInfo();
            _labels                = new ObservableCollection <string>();
            _lastXAxisCurrentValue = _xAxisCurrentValue;

            ExchangeRate = walletVm.Wallet.Synchronizer.UsdExchangeRate;
            PriorLabels  = new();

            this.ValidateProperty(x => x.To, ValidateToField);
            this.ValidateProperty(x => x.AmountBtc, ValidateAmount);

            this.WhenAnyValue(x => x.To)
            .Subscribe(ParseToField);

            this.WhenAnyValue(x => x.AmountBtc)
            .Subscribe(x => _transactionInfo.Amount = new Money(x, MoneyUnit.BTC));

            this.WhenAnyValue(x => x.XAxisCurrentValue)
            .Subscribe(x =>
            {
                if (x > 0)
                {
                    _transactionInfo.FeeRate = new FeeRate(GetYAxisValueFromXAxisCurrentValue(x));
                    SetXAxisCurrentValueIndex(x);
                }
            });

            this.WhenAnyValue(x => x.XAxisCurrentValueIndex)
            .Subscribe(SetXAxisCurrentValue);

            Labels.ToObservableChangeSet().Subscribe(x =>
            {
                _transactionInfo.Labels = new SmartLabel(_labels.ToArray());
            });

            PasteCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var text = await Application.Current.Clipboard.GetTextAsync();

                _parsingUrl = true;

                if (!TryParseUrl(text))
                {
                    To = text;
                    // todo validation errors.
                }

                _parsingUrl = false;
            });

            var nextCommandCanExecute =
                this.WhenAnyValue(x => x.Labels, x => x.AmountBtc, x => x.To, x => x.XAxisCurrentValue).Select(_ => Unit.Default)
                .Merge(Observable.FromEventPattern(Labels, nameof(Labels.CollectionChanged)).Select(_ => Unit.Default))
                .Select(_ =>
            {
                var allFilled = !string.IsNullOrEmpty(To) && AmountBtc > 0 && Labels.Any();
                var hasError  = Validations.Any;

                return(allFilled && !hasError);
            });

            NextCommand = ReactiveCommand.Create(() =>
            {
                var transactionInfo    = _transactionInfo;
                var wallet             = _owner.Wallet;
                var targetAnonymitySet = wallet.ServiceConfiguration.GetMixUntilAnonymitySetValue();
                var mixedCoins         = wallet.Coins.Where(x => x.HdPubKey.AnonymitySet >= targetAnonymitySet).ToList();

                if (mixedCoins.Any())
                {
                    var intent = new PaymentIntent(
                        destination: transactionInfo.Address,
                        amount: transactionInfo.Amount,
                        subtractFee: false,
                        label: transactionInfo.Labels);

                    try
                    {
                        var txRes = wallet.BuildTransaction(
                            wallet.Kitchen.SaltSoup(),
                            intent,
                            FeeStrategy.CreateFromFeeRate(transactionInfo.FeeRate),
                            allowUnconfirmed: true,
                            mixedCoins.Select(x => x.OutPoint));

                        // Private coins are enough.
                        Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, broadcaster, txRes));
                        return;
                    }
                    catch (InsufficientBalanceException)
                    {
                        // Do Nothing
                    }
                }

                Navigate().To(new PrivacyControlViewModel(wallet, transactionInfo, broadcaster));
            }, nextCommandCanExecute);
        }
Exemple #23
0
 private bool NotHaveInvalidLabel() => Labels.Any(label => InvalidLabels.Any(validLabel => validLabel.Equals(label.Name))) == false;
Exemple #24
0
        public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster) : base(NavigationMode.Normal)
        {
            _to                    = "";
            _owner                 = walletVm;
            _transactionInfo       = new TransactionInfo();
            _labels                = new ObservableCollection <string>();
            _lastXAxisCurrentValue = _xAxisCurrentValue;

            ExchangeRate = walletVm.Wallet.Synchronizer.UsdExchangeRate;
            PriorLabels  = new();

            this.ValidateProperty(x => x.To, ValidateToField);
            this.ValidateProperty(x => x.AmountBtc, ValidateAmount);

            this.WhenAnyValue(x => x.To)
            .Subscribe(ParseToField);

            this.WhenAnyValue(x => x.AmountBtc)
            .Subscribe(x => _transactionInfo.Amount = new Money(x, MoneyUnit.BTC));

            this.WhenAnyValue(x => x.XAxisCurrentValue)
            .Subscribe(x =>
            {
                if (x > 0)
                {
                    _transactionInfo.FeeRate = new FeeRate(GetYAxisValueFromXAxisCurrentValue(x));
                    SetXAxisCurrentValueIndex(x);
                }
            });

            this.WhenAnyValue(x => x.XAxisCurrentValueIndex)
            .Subscribe(SetXAxisCurrentValue);

            Labels.ToObservableChangeSet().Subscribe(x =>
            {
                _transactionInfo.Labels = new SmartLabel(_labels.ToArray());
            });

            PasteCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var text = await Application.Current.Clipboard.GetTextAsync();

                _parsingUrl = true;

                if (!TryParseUrl(text))
                {
                    To = text;
                    // todo validation errors.
                }

                _parsingUrl = false;
            });

            var nextCommandCanExecute =
                this.WhenAnyValue(x => x.Labels, x => x.AmountBtc, x => x.To, x => x.XAxisCurrentValue).Select(_ => Unit.Default)
                .Merge(Observable.FromEventPattern(Labels, nameof(Labels.CollectionChanged)).Select(_ => Unit.Default))
                .Select(_ =>
            {
                var allFilled = !string.IsNullOrEmpty(To) && AmountBtc > 0 && Labels.Any();
                var hasError  = Validations.Any;

                return(allFilled && !hasError);
            });

            NextCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var transactionInfo       = _transactionInfo;
                var wallet                = _owner.Wallet;
                var targetAnonymitySet    = wallet.ServiceConfiguration.GetMixUntilAnonymitySetValue();
                var mixedCoins            = wallet.Coins.Where(x => x.HdPubKey.AnonymitySet >= targetAnonymitySet).ToList();
                var totalMixedCoinsAmount = Money.FromUnit(mixedCoins.Sum(coin => coin.Amount), MoneyUnit.Satoshi);


                if (transactionInfo.Amount <= totalMixedCoinsAmount)
                {
                    try
                    {
                        try
                        {
                            var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, transactionInfo.Amount, transactionInfo.Labels, transactionInfo.FeeRate, mixedCoins, subtractFee: false));
                            Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, broadcaster, txRes));
                            return;
                        }
                        catch (InsufficientBalanceException)
                        {
                            var dialog = new InsufficientBalanceDialogViewModel(BalanceType.Private);
                            var result = await NavigateDialog(dialog, NavigationTarget.DialogScreen);

                            if (result.Result)
                            {
                                var txRes = await Task.Run(() => TransactionHelpers.BuildTransaction(wallet, transactionInfo.Address, totalMixedCoinsAmount, transactionInfo.Labels, transactionInfo.FeeRate, mixedCoins, subtractFee: true));
                                Navigate().To(new OptimisePrivacyViewModel(wallet, transactionInfo, broadcaster, txRes));
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex);
                        await ShowErrorAsync("Transaction Building", ex.ToUserFriendlyString(), "Wasabi was unable to create your transaction.");
                        return;
                    }
                }

                Navigate().To(new PrivacyControlViewModel(wallet, transactionInfo, broadcaster));
            }, nextCommandCanExecute);

            EnableAutoBusyOn(NextCommand);
        }