private async ValueTask RefreshSelectedLifestyle()
        {
            if (_blnSkipRefresh)
            {
                return;
            }

            _objLifestyle.BaseLifestyle = await cboBaseLifestyle.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()) ?? string.Empty;

            XPathNavigator xmlAspect = await _objLifestyle.GetNodeXPathAsync();

            if (xmlAspect != null)
            {
                string strSource = xmlAspect.SelectSingleNode("source")?.Value ?? string.Empty;
                string strPage   = (await xmlAspect.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlAspect.SelectSingleNode("page")?.Value ?? string.Empty;
                if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage))
                {
                    SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language,
                                                                                     GlobalSettings.CultureInfo, _objCharacter);

                    await objSource.SetControlAsync(lblSource);

                    await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = true);
                }
                else
                {
                    await SourceString.Blank.SetControlAsync(lblSource);

                    await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = false);
                }
            }
            else
            {
                await SourceString.Blank.SetControlAsync(lblSource);

                await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = false);
            }

            // Characters with the Trust Fund Quality can have the lifestyle discounted.
            if (_objLifestyle.IsTrustFundEligible)
            {
                await chkTrustFund.DoThreadSafeAsync(x =>
                {
                    x.Visible = true;
                    x.Checked = _objLifestyle.TrustFund;
                });
            }
            else
            {
                await chkTrustFund.DoThreadSafeAsync(x =>
                {
                    x.Checked = false;
                    x.Visible = false;
                });
            }

            if (_objLifestyle.AllowBonusLP)
            {
                await lblBonusLP.DoThreadSafeAsync(x => x.Visible = true);

                await nudBonusLP.DoThreadSafeAsync(x => x.Visible = true);

                await chkBonusLPRandomize.DoThreadSafeAsync(x => x.Visible = true);

                if (await chkBonusLPRandomize.DoThreadSafeFuncAsync(x => x.Checked))
                {
                    int intValue = await GlobalSettings.RandomGenerator.NextD6ModuloBiasRemovedAsync();

                    await nudBonusLP.DoThreadSafeAsync(x =>
                    {
                        x.Enabled       = false;
                        _blnSkipRefresh = true;
                        x.Value         = intValue;
                        _blnSkipRefresh = false;
                    });
                }
                else
                {
                    await nudBonusLP.DoThreadSafeAsync(x => x.Enabled = true);
                }
            }
            else
            {
                await lblBonusLP.DoThreadSafeAsync(x => x.Visible = false);

                await nudBonusLP.DoThreadSafeAsync(x => x.Visible = false);

                await nudBonusLP.DoThreadSafeAsync(x => x.Value = 0);

                await chkBonusLPRandomize.DoThreadSafeAsync(x => x.Visible = false);
            }
        }
Example #2
0
        private async ValueTask RefreshSelectedLifestyle()
        {
            if (_blnSkipRefresh)
            {
                return;
            }

            string strBaseLifestyle = cboBaseLifestyle.SelectedValue?.ToString() ?? string.Empty;

            _objLifestyle.BaseLifestyle = strBaseLifestyle;
            XPathNavigator xmlAspect = await _objLifestyle.GetNodeXPathAsync();

            if (xmlAspect != null)
            {
                string strSource = xmlAspect.SelectSingleNode("source")?.Value ?? string.Empty;
                string strPage   = (await xmlAspect.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlAspect.SelectSingleNode("page")?.Value ?? string.Empty;
                if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage))
                {
                    SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language,
                                                                                     GlobalSettings.CultureInfo, _objCharacter);

                    lblSource.Text = objSource.ToString();
                    await lblSource.SetToolTipAsync(objSource.LanguageBookTooltip);
                }
                else
                {
                    lblSource.Text = string.Empty;
                    await lblSource.SetToolTipAsync(string.Empty);
                }
            }
            else
            {
                lblSource.Text = string.Empty;
                await lblSource.SetToolTipAsync(string.Empty);
            }

            lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text);

            // Characters with the Trust Fund Quality can have the lifestyle discounted.
            if (_objLifestyle.IsTrustFundEligible)
            {
                chkTrustFund.Visible = true;
                chkTrustFund.Checked = _objLifestyle.TrustFund;
            }
            else
            {
                chkTrustFund.Checked = false;
                chkTrustFund.Visible = false;
            }

            if (_objLifestyle.AllowBonusLP)
            {
                lblBonusLP.Visible          = true;
                nudBonusLP.Visible          = true;
                chkBonusLPRandomize.Visible = true;

                if (chkBonusLPRandomize.Checked)
                {
                    nudBonusLP.Enabled = false;
                    _blnSkipRefresh    = true;
                    nudBonusLP.Value   = await GlobalSettings.RandomGenerator.NextD6ModuloBiasRemovedAsync();

                    _blnSkipRefresh = false;
                }
                else
                {
                    nudBonusLP.Enabled = true;
                }
            }
            else
            {
                lblBonusLP.Visible          = false;
                nudBonusLP.Visible          = false;
                nudBonusLP.Value            = 0;
                chkBonusLPRandomize.Visible = false;
            }
        }