private void UpdateViewForListOption(Constraint ct, int value)
        {
            IEnumerable <OptionValue> values = _selectedOption.Option.Values;

            if (ct.Require.Any())
            {
                value             = ct.Require[0];
                CompatibilityNote = $"{ResourceHelper.Get(StringKey.ThisOptionCannotBeChangedDueToCompatibility)} ({string.Join(", ", ct.ParticipatingMods.Values)})";
                ComboBoxIsEnabled = false;
            }
            else if (ct.Forbid.Any())
            {
                var remove = values.Where(v => ct.Forbid.Contains(v.Value));
                CompatibilityNote = string.Format(ResourceHelper.Get(StringKey.TheFollowingValuesHaveBeenRemovedDueToCompatibility), string.Join(", ", remove.Select(o => o.Name)), string.Join(", ", ct.ParticipatingMods.Values));
                values            = values.Except(remove);
                if (!values.Any(v => v.Value == value))
                {
                    value = values.First().Value;
                }
                ComboBoxIsEnabled = true;
            }
            else
            {
                CompatibilityNote = string.Empty;
                ComboBoxIsEnabled = true;
            }

            CheckBoxVisibility = Visibility.Hidden;
            ComboBoxVisibility = Visibility.Visible;

            DropdownOptions.Clear();
            DropdownOptions       = values.Select(v => new OptionValueViewModel(v)).ToList();
            DropdownSelectedIndex = DropdownOptions.FindIndex(m => m.OptionValue.Value == value);
        }
Пример #2
0
        private void UpdateViewForListOption(Constraint ct, int value)
        {
            IEnumerable <OptionValue> values = _selectedOption.Option.Values;

            if (ct.Require.Any())
            {
                value             = ct.Require[0];
                CompatibilityNote = $"This option cannot be changed due to compatibility with other mods ({string.Join(", ", ct.ParticipatingMods.Values)})";
                ComboBoxIsEnabled = false;
            }
            else if (ct.Forbid.Any())
            {
                var remove = values.Where(v => ct.Forbid.Contains(v.Value));
                CompatibilityNote = $"The following values: {string.Join(", ", remove.Select(o => o.Name))} have been removed due to compatibility with other mods ({string.Join(", ", ct.ParticipatingMods.Values)})";
                values            = values.Except(remove);
                if (!values.Any(v => v.Value == value))
                {
                    value = values.First().Value;
                }
                ComboBoxIsEnabled = true;
            }
            else
            {
                CompatibilityNote = string.Empty;
                ComboBoxIsEnabled = true;
            }

            CheckBoxVisibility = Visibility.Hidden;
            ComboBoxVisibility = Visibility.Visible;

            DropdownOptions.Clear();
            DropdownOptions       = values.Select(v => new OptionValueViewModel(v)).ToList();
            DropdownSelectedIndex = DropdownOptions.FindIndex(m => m.OptionValue.Value == value);
        }
Пример #3
0
        private static DropdownOption[] GetOpenPayoutData(FinancialTransaction transaction)
        {
            DateTime transactionDateTime = transaction.DateTime;
            Int64    matchAmount         = transaction.Rows.AmountCentsTotal;

            DropdownOptions result = new DropdownOptions();

            List <DropdownOption> listExact    = new List <DropdownOption>();
            List <DropdownOption> listTolerant = new List <DropdownOption>();

            Payouts openPayouts = Payouts.ForOrganization(transaction.Organization);

            foreach (Payout payout in openPayouts)
            {
                if (payout.AmountCents > -matchAmount * 95 / 100 &&
                    payout.AmountCents < -matchAmount * 105 / 100)
                {
                    string description = String.Format(Resources.Pages.Ledgers.BalanceTransactions_PayoutMatch, payout.Identity,
                                                       payout.ExpectedTransactionDate, payout.Recipient, payout.Organization.Currency.DisplayCode, payout.AmountCents / 100.0,
                                                       payout.Specification);

                    if (payout.AmountCents == -matchAmount)
                    {
                        listExact.Add(new DropdownOption
                        {
                            id     = payout.Identity.ToString(CultureInfo.InvariantCulture),
                            @group = Resources.Pages.Ledgers.BalanceTransactions_ExactMatches,
                            text   = description
                        });
                    }
                    else
                    {
                        listTolerant.Add(new DropdownOption
                        {
                            id     = payout.Identity.ToString(CultureInfo.InvariantCulture),
                            @group = Resources.Pages.Ledgers.BalanceTransactions_FivePercentMatches,
                            text   = description
                        });
                    }
                }
            }

            List <DropdownOption> listCombined = new List <DropdownOption>();

            listCombined.AddRange(listExact);
            listCombined.AddRange(listTolerant);

            return(listCombined.ToArray());
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            DropdownOptions option = (DropdownOptions)comboBox1.SelectedValue;

            Translator.LatinEnglishCharacter additionalOption = new Translator.LatinEnglishCharacter();
            if (QWYXstate["CheckBoxEnabled"] == false && QWYXstate["ComboBoxEnabled"] == true)
            {
                additionalOption = (Translator.LatinEnglishCharacter)comboBox2.SelectedValue;
            }
            switch (option)
            {
            case DropdownOptions.Filesystem:
                if (!String.IsNullOrEmpty(filesystemFileName))
                {
                    string textFromFile = _filer.ReadFromFile(filesystemFileName);
                    TranslationHandler(additionalOption, textFromFile);
                }
                break;

            case DropdownOptions.Web:
                if (!String.IsNullOrEmpty(webFileLocation))
                {
                    webTranslationHandler(additionalOption);
                }
                else
                {
                    button2.PerformClick();
                    webTranslationHandler(additionalOption);
                }
                break;

            case DropdownOptions.Input:
                if (!(String.IsNullOrWhiteSpace(textBox2.Text) || String.IsNullOrEmpty(textBox2.Text)))
                {
                    TranslationHandler(additionalOption, textBox2.Text);
                }
                else
                {
                    MessageBox.Show("The field is empty.", applicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            default:
                break;
            }
            textBox2.Text = String.Empty;
        }
        private void UpdateViewForDropdownSelectionChanged()
        {
            if (_selectedOption == null || DropdownSelectedIndex == -1)
            {
                return;
            }

            OptionValue o = DropdownOptions.ElementAt(DropdownSelectedIndex)?.OptionValue;

            if (o != null)
            {
                ImageOptionSource = SetPreviewImage(_imageReader(o.PreviewFile));
            }
            else
            {
                ImageOptionSource = null;
            }

            SetupAudioPreview(o);

            _values[_selectedOption.Option.ID] = o.Value;
        }
Пример #6
0
        private static DropdownOption[] GetOpenOutboundInvoiceData(FinancialTransaction transaction)
        {
            DateTime txDateTime  = transaction.DateTime;
            Int64    matchAmount = transaction.Rows.AmountCentsTotal;

            DropdownOptions result = new DropdownOptions();

            List <DropdownOption> listExact    = new List <DropdownOption>();
            List <DropdownOption> listTolerant = new List <DropdownOption>();
            List <DropdownOption> listRefMatch = new List <DropdownOption>();

            OutboundInvoices invoices = OutboundInvoices.ForOrganization(transaction.Organization);

            foreach (OutboundInvoice invoice in invoices)
            {
                if (invoice.AmountCents > matchAmount * 95 / 100 &&
                    invoice.AmountCents < matchAmount * 105 / 100)
                {
                    string description = String.Format(Resources.Pages.Ledgers.BalanceTransactions_OutboundInvoiceMatch, invoice.OrganizationSequenceId,
                                                       invoice.CustomerName, invoice.DueDate, invoice.DisplayNativeAmount);

                    if (invoice.HasNativeCurrency)
                    {
                        description += " (" + transaction.Organization.Currency.DisplayCode + " " +
                                       (invoice.AmountCents / 100.0).ToString("N2") + ")";
                    }

                    bool invoiceIdMatch = DescriptionContainsInvoiceReference(invoice.Reference, invoice.TheirReference, transaction.Description);

                    if (invoiceIdMatch)
                    {
                        listRefMatch.Add(new DropdownOption
                        {
                            id     = invoice.Identity.ToString(CultureInfo.InvariantCulture),
                            @group = Resources.Pages.Ledgers.BalanceTransactions_MostProbableMatch,
                            text   = description
                        });
                    }
                    if (invoice.AmountCents == matchAmount)
                    {
                        listExact.Add(new DropdownOption
                        {
                            id     = invoice.Identity.ToString(CultureInfo.InvariantCulture),
                            @group = Resources.Pages.Ledgers.BalanceTransactions_ExactMatches,
                            text   = description
                        });
                    }
                    else
                    {
                        listTolerant.Add(new DropdownOption
                        {
                            id     = invoice.Identity.ToString(CultureInfo.InvariantCulture),
                            @group = Resources.Pages.Ledgers.BalanceTransactions_FivePercentMatches,
                            text   = description
                        });
                    }
                }
            }

            List <DropdownOption> listCombined = new List <DropdownOption>();

            listCombined.AddRange(listRefMatch);
            listCombined.AddRange(listExact);
            listCombined.AddRange(listTolerant);

            return(listCombined.ToArray());
        }