示例#1
0
        public QrCodeDialog(SettingsManager.ConfigElementContact contact)
        {
            this.SetWindowProperties(
                Desktop.Properties.Resources.TextQrCode,
                new Size(0, 0)
                );

            Address = contact.Address;
            Label   = contact.Label;

            RenderContent();
        }
示例#2
0
        void SendTransaction()
        {
            // Disable auto-saving settings
            SettingsManager.IsAutoSaveEnabled = false;
            SettingsManager.General.TransactionsDefaultMixCount = ViewModel.MixCount;

            var tableLayoutRecipientsRows = TableLayoutRecipients.Rows;
            var recipientsCount = tableLayoutRecipientsRows.Count - 1;
            var isExchangeSendWithoutPaymentIdQuestionShowable = ViewModel.PaymentId.Length == 0;

            var recipientsList = new List<TransferRecipient>(recipientsCount);
            var contactDictionary = new Dictionary<string, string>(recipientsCount);

            // Check each recipient's validity, and add them to a dictionary
            for (var i = recipientsCount - 1; i >= 0; i--) {
                var recipient = tableLayoutRecipientsRows[i].Cells[0].Control as CoinSender;
                Debug.Assert(recipient != null, "recipient != null");

                if (!recipient.IsRecipientValid()) {
                    // TODO: Notify the user about the first recipient being invalid
                    //ListBoxRecipients.ScrollIntoView(recipients[firstInvalidRecipient]);
                    //ListBoxRecipients.SelectedIndex = firstInvalidRecipient;
                    //this.SetFocusedElement(ListBoxRecipients);
                    this.ShowError(Desktop.Properties.Resources.SendCoinsTransactionCouldNotBeSent);
                    return;
                }

                // Check whether the address belongs to an exchange
                if (isExchangeSendWithoutPaymentIdQuestionShowable && Utilities.DataSourceExchangeAddresses.Contains(recipient.Address)) {
                    if (this.ShowQuestion(Desktop.Properties.Resources.SendCoinsExchangeSendWithoutPaymentIdQuestionMessage, Desktop.Properties.Resources.SendCoinsExchangeSendWithoutPaymentIdQuestionTitle)) {
                        return;
                    }
                    isExchangeSendWithoutPaymentIdQuestionShowable = false;
                }

                recipientsList.Add(new TransferRecipient(recipient.Address, recipient.Amount));

                if (recipient.Label.Length != 0) {
                    contactDictionary.Add(recipient.Label, recipient.Address);
                }
            }

            // Check for the validity of the payment ID
            if (!MoneroAPI.Utilities.IsPaymentIdValid(ViewModel.PaymentId)) {
                this.ShowError(Desktop.Properties.Resources.SendCoinsInvalidPaymentId);
                return;
            }

            // Initiate a new transaction
            var isTransferSuccessful = Utilities.MoneroRpcManager.AccountManager.SendTransaction(
                recipientsList,
                ViewModel.PaymentId.ToLower(Utilities.InvariantCulture),
                ViewModel.MixCount
            );

            // Add new people to the address book
            foreach (var keyValuePair in contactDictionary) {
                var contact = new SettingsManager.ConfigElementContact(keyValuePair.Key, keyValuePair.Value);
                var editIndex = Utilities.DataSourceAddressBook.IndexOfLabel(contact.Label);

                if (editIndex < 0) {
                    Utilities.DataSourceAddressBook.Add(contact);
                } else {
                    Utilities.DataSourceAddressBook.RemoveAt(editIndex);
                    Utilities.DataSourceAddressBook.Insert(editIndex, contact);
                }
            }

            // Save settings
            SettingsManager.IsAutoSaveEnabled = true;
            SettingsManager.SaveSettings();

            if (isTransferSuccessful) {
                // TODO: Notify the user about the transaction's success
                Application.Instance.AsyncInvoke(Clear);
            } else {
                // Show a warning whether the transaction could not be sent
                this.ShowError(Desktop.Properties.Resources.SendCoinsTransactionCouldNotBeSent);
            }
        }
示例#3
0
        void SendTransaction()
        {
            // Disable auto-saving settings
            SettingsManager.IsAutoSaveEnabled = false;
            SettingsManager.General.TransactionsDefaultMixCount = ViewModel.MixCount;

            var tableLayoutRecipientsRows = TableLayoutRecipients.Rows;
            var recipientsCount           = tableLayoutRecipientsRows.Count - 1;
            var isExchangeSendWithoutPaymentIdQuestionShowable = ViewModel.PaymentId.Length == 0;

            var recipientsList    = new List <TransferRecipient>(recipientsCount);
            var contactDictionary = new Dictionary <string, string>(recipientsCount);

            // Check each recipient's validity, and add them to a dictionary
            for (var i = recipientsCount - 1; i >= 0; i--)
            {
                var recipient = tableLayoutRecipientsRows[i].Cells[0].Control as CoinSender;
                Debug.Assert(recipient != null, "recipient != null");

                if (!recipient.IsRecipientValid())
                {
                    // TODO: Notify the user about the first recipient being invalid
                    //ListBoxRecipients.ScrollIntoView(recipients[firstInvalidRecipient]);
                    //ListBoxRecipients.SelectedIndex = firstInvalidRecipient;
                    //this.SetFocusedElement(ListBoxRecipients);
                    this.ShowError(Desktop.Properties.Resources.SendCoinsTransactionCouldNotBeSent);
                    return;
                }

                // Check whether the address belongs to an exchange
                if (isExchangeSendWithoutPaymentIdQuestionShowable && Utilities.DataSourceExchangeAddresses.Contains(recipient.Address))
                {
                    if (this.ShowQuestion(Desktop.Properties.Resources.SendCoinsExchangeSendWithoutPaymentIdQuestionMessage, Desktop.Properties.Resources.SendCoinsExchangeSendWithoutPaymentIdQuestionTitle))
                    {
                        return;
                    }
                    isExchangeSendWithoutPaymentIdQuestionShowable = false;
                }

                recipientsList.Add(new TransferRecipient(recipient.Address, recipient.Amount));

                if (recipient.Label.Length != 0)
                {
                    contactDictionary.Add(recipient.Label, recipient.Address);
                }
            }

            // Check for the validity of the payment ID
            if (!MoneroAPI.Utilities.IsPaymentIdValid(ViewModel.PaymentId))
            {
                this.ShowError(Desktop.Properties.Resources.SendCoinsInvalidPaymentId);
                return;
            }

            // Initiate a new transaction
            var isTransferSuccessful = Utilities.MoneroRpcManager.AccountManager.SendTransaction(
                recipientsList,
                ViewModel.PaymentId.ToLower(Utilities.InvariantCulture),
                ViewModel.MixCount
                );

            // Add new people to the address book
            foreach (var keyValuePair in contactDictionary)
            {
                var contact   = new SettingsManager.ConfigElementContact(keyValuePair.Key, keyValuePair.Value);
                var editIndex = Utilities.DataSourceAddressBook.IndexOfLabel(contact.Label);

                if (editIndex < 0)
                {
                    Utilities.DataSourceAddressBook.Add(contact);
                }
                else
                {
                    Utilities.DataSourceAddressBook.RemoveAt(editIndex);
                    Utilities.DataSourceAddressBook.Insert(editIndex, contact);
                }
            }

            // Save settings
            SettingsManager.IsAutoSaveEnabled = true;
            SettingsManager.SaveSettings();

            if (isTransferSuccessful)
            {
                // TODO: Notify the user about the transaction's success
                Application.Instance.AsyncInvoke(Clear);
            }
            else
            {
                // Show a warning whether the transaction could not be sent
                this.ShowError(Desktop.Properties.Resources.SendCoinsTransactionCouldNotBeSent);
            }
        }