private void treQualities_AfterSelect(object sender, TreeViewEventArgs e) { string strSource = string.Empty; string strPage = string.Empty; string strSourceIDString = treQualities.SelectedNode?.Tag.ToString(); if (!string.IsNullOrEmpty(strSourceIDString)) { XmlNode objXmlQuality = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = " + strSourceIDString.CleanXPath() + ']'); if (objXmlQuality != null) { strSource = objXmlQuality["source"]?.InnerText ?? string.Empty; strPage = objXmlQuality["altpage"]?.InnerText ?? objXmlQuality["page"]?.InnerText ?? string.Empty; } } if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage)) { SourceString objSource = new SourceString(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); } else { lblSource.Text = string.Empty; lblSource.SetToolTip(string.Empty); } lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); }
private void lstArt_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } string strSelected = lstArt.SelectedValue?.ToString(); if (string.IsNullOrEmpty(strSelected)) { tlpRight.Visible = false; return; } // Retrieve the information for the selected art XPathNavigator objXmlMetamagic = _objXmlDocument.SelectSingleNode(_strBaseXPath + "[id = " + strSelected.CleanXPath() + ']'); if (objXmlMetamagic == null) { tlpRight.Visible = false; return; } string strSource = objXmlMetamagic.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = objXmlMetamagic.SelectSingleNodeAndCacheExpression("altpage")?.Value ?? objXmlMetamagic.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); tlpRight.Visible = true; }
private async void lstQualities_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } _blnLoading = true; XPathNavigator xmlQuality = null; string strSelectedQuality = lstQualities.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedQuality)) { xmlQuality = _xmlBaseQualityDataNode.SelectSingleNode("qualities/quality[id = " + strSelectedQuality.CleanXPath() + ']'); } if (xmlQuality != null) { nudRating.ValueAsInt = nudRating.MinimumAsInt; int intMaxRating = int.MaxValue; if (xmlQuality.TryGetInt32FieldQuickly("limit", ref intMaxRating) && xmlQuality.SelectSingleNode("nolevels") == null) { lblRatingNALabel.Visible = false; nudRating.MaximumAsInt = intMaxRating; nudRating.Visible = true; } else { lblRatingNALabel.Visible = true; nudRating.MaximumAsInt = 1; nudRating.ValueAsInt = 1; nudRating.Visible = false; } await UpdateCostLabel(xmlQuality); string strSource = xmlQuality.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await xmlQuality.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlQuality.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); await lblSource.SetToolTipAsync(objSource.LanguageBookTooltip); lblSourceLabel.Visible = lblSource.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; } else { tlpRight.Visible = false; } _blnLoading = false; }
private async void lstPowers_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } string strSelectedId = lstPowers.SelectedValue?.ToString(); XPathNavigator objXmlPower = null; if (!string.IsNullOrEmpty(strSelectedId)) { objXmlPower = _xmlBasePowerDataNode.SelectSingleNode("powers/power[id = " + strSelectedId.CleanXPath() + ']'); } if (objXmlPower != null) { string strSpace = await LanguageManager.GetStringAsync("String_Space"); // Display the information for the selected Power. string strPowerPointsText = objXmlPower.SelectSingleNode("points")?.Value ?? string.Empty; if (objXmlPower.SelectSingleNode("levels")?.Value == bool.TrueString) { strPowerPointsText += strSpace + '/' + strSpace + await LanguageManager.GetStringAsync("Label_Power_Level"); } string strExtrPointCost = objXmlPower.SelectSingleNode("extrapointcost")?.Value; if (!string.IsNullOrEmpty(strExtrPointCost)) { strPowerPointsText = strExtrPointCost + strSpace + '+' + strSpace + strPowerPointsText; } lblPowerPoints.Text = strPowerPointsText; string strSource = objXmlPower.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? objXmlPower.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); await lblSource.SetToolTipAsync(objSource.LanguageBookTooltip); lblPowerPointsLabel.Visible = !string.IsNullOrEmpty(lblPowerPoints.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; } else { tlpRight.Visible = false; } }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private async ValueTask UpdateSelectedVehicle() { if (_blnLoading) { return; } string strSelectedId = await lstVehicle.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); XPathNavigator objXmlVehicle = null; if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected Vehicle. objXmlVehicle = _xmlBaseVehicleDataNode.SelectSingleNode("vehicles/vehicle[id = " + strSelectedId.CleanXPath() + ']'); } if (objXmlVehicle == null) { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); return; } await this.DoThreadSafeAsync(x => x.SuspendLayout()); try { string strHandling = objXmlVehicle.SelectSingleNode("handling")?.Value; await lblVehicleHandling.DoThreadSafeAsync(x => x.Text = strHandling); string strAccel = objXmlVehicle.SelectSingleNode("accel")?.Value; await lblVehicleAccel.DoThreadSafeAsync(x => x.Text = strAccel); string strSpeed = objXmlVehicle.SelectSingleNode("speed")?.Value; await lblVehicleSpeed.DoThreadSafeAsync(x => x.Text = strSpeed); string strPilot = objXmlVehicle.SelectSingleNode("pilot")?.Value; await lblVehiclePilot.DoThreadSafeAsync(x => x.Text = strPilot); string strBody = objXmlVehicle.SelectSingleNode("body")?.Value; await lblVehicleBody.DoThreadSafeAsync(x => x.Text = strBody); string strArmor = objXmlVehicle.SelectSingleNode("armor")?.Value; await lblVehicleArmor.DoThreadSafeAsync(x => x.Text = strArmor); string strSeats = objXmlVehicle.SelectSingleNode("seats")?.Value; await lblVehicleSeats.DoThreadSafeAsync(x => x.Text = strSeats); string strSensor = objXmlVehicle.SelectSingleNode("sensor")?.Value; await lblVehicleSensor.DoThreadSafeAsync(x => x.Text = strSensor); await lblVehicleHandlingLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strHandling)); await lblVehicleAccelLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strAccel)); await lblVehicleSpeedLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strSpeed)); await lblVehiclePilotLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strPilot)); await lblVehicleBodyLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strBody)); await lblVehicleArmorLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strArmor)); await lblVehicleSeatsLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strSeats)); await lblVehicleSensorLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strSensor)); AvailabilityValue objTotalAvail = new AvailabilityValue(0, objXmlVehicle.SelectSingleNode("avail")?.Value, await chkUsedVehicle.DoThreadSafeFuncAsync(x => x.Checked) ? -4 : 0); string strAvail = objTotalAvail.ToString(); await lblVehicleAvail.DoThreadSafeAsync(x => x.Text = strAvail); await lblVehicleAvailLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strAvail)); bool blnCanBlackMarketDiscount = _setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value); await chkBlackMarketDiscount.DoThreadSafeAsync(x => { x.Enabled = blnCanBlackMarketDiscount; if (!x.Checked) { x.Checked = GlobalSettings.AssumeBlackMarket && blnCanBlackMarketDiscount; } else if (!blnCanBlackMarketDiscount) { //Prevent chkBlackMarketDiscount from being checked if the category doesn't match. x.Checked = false; } }); await UpdateSelectedVehicleCost(); string strSource = objXmlVehicle.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await objXmlVehicle.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? objXmlVehicle.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync( strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSource.SetControlAsync(lblSource); await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(objSource.ToString())); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } finally { await this.DoThreadSafeAsync(x => x.ResumeLayout()); } }
private void lstDrug_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } _blnLoading = true; XPathNavigator xmlDrug = null; string strSelectedId = lstDrug.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected piece of Drug. xmlDrug = _xmlBaseDrugDataNode.SelectSingleNode(_strNodeXPath + "[id = " + strSelectedId.CleanXPath() + "]"); } string strForceGrade; if (xmlDrug != null) { strForceGrade = xmlDrug.SelectSingleNode("forcegrade")?.Value; // If the piece has a Rating value, enable the Rating control, otherwise, disable it and set its value to 0. XPathNavigator xmlRatingNode = xmlDrug.SelectSingleNode("rating"); if (xmlRatingNode != null) { string strMinRating = xmlDrug.SelectSingleNode("minrating")?.Value; int intMinRating = 1; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMinRating) && !int.TryParse(strMinRating, out intMinRating)) { strMinRating = strMinRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString(GlobalOptions.InvariantCultureInfo)); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMinRating, out bool blnIsSuccess); intMinRating = blnIsSuccess ? ((double)objProcess).StandardRound() : 1; } nudRating.Minimum = intMinRating; string strMaxRating = xmlRatingNode.Value; int intMaxRating = 0; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMaxRating) && !int.TryParse(strMaxRating, out intMaxRating)) { strMaxRating = strMaxRating.CheapReplace("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString(GlobalOptions.InvariantCultureInfo)) .CheapReplace("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString(GlobalOptions.InvariantCultureInfo)); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMaxRating, out bool blnIsSuccess); intMaxRating = blnIsSuccess ? ((double)objProcess).StandardRound() : 1; } nudRating.Maximum = intMaxRating; if (chkHideOverAvailLimit.Checked) { int intAvailModifier = strForceGrade == "None" ? 0 : _intAvailModifier; while (nudRating.Maximum > intMinRating && !xmlDrug.CheckAvailRestriction(_objCharacter, nudRating.MaximumAsInt, intAvailModifier)) { nudRating.Maximum -= 1; } } if (chkShowOnlyAffordItems.Checked && !chkFree.Checked) { decimal decCostMultiplier = 1 + nudMarkup.Value / 100.0m; if (chkBlackMarketDiscount.Checked) { decCostMultiplier *= 0.9m; } while (nudRating.Maximum > intMinRating && !xmlDrug.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier, nudRating.MaximumAsInt)) { nudRating.Maximum -= 1; } } nudRating.Value = nudRating.Minimum; nudRating.Enabled = nudRating.Minimum != nudRating.Maximum; nudRating.Visible = true; lblRatingNALabel.Visible = false; lblRatingLabel.Visible = true; } else { lblRatingLabel.Visible = true; lblRatingNALabel.Visible = true; nudRating.Minimum = 0; nudRating.Value = 0; nudRating.Visible = false; } string strSource = xmlDrug.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = xmlDrug.SelectSingleNode("altpage")?.Value ?? xmlDrug.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); Grade objForcedGrade = null; if (!string.IsNullOrEmpty(strForceGrade)) { // Force the Drug to be a particular Grade. if (cboGrade.Enabled) { cboGrade.Enabled = false; } objForcedGrade = _lstGrades.FirstOrDefault(x => x.Name == strForceGrade); strForceGrade = objForcedGrade?.SourceId.ToString("D", GlobalOptions.InvariantCultureInfo); } else { cboGrade.Enabled = !_blnLockGrade; if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D", GlobalOptions.InvariantCultureInfo) ?? cboGrade.SelectedValue?.ToString(); objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D", GlobalOptions.InvariantCultureInfo) == strForceGrade); } } chkBlackMarketDiscount.Enabled = _objCharacter.BlackMarketDiscount; if (!chkBlackMarketDiscount.Checked) { chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket && _setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category") ?.Value); } else if (!_setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category")?.Value)) { //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match. chkBlackMarketDiscount.Checked = false; } // We may need to rebuild the Grade list since Cultured Bioware is not allowed to select Standard (Second-Hand) as Grade and ForceGrades can change. PopulateGrades(xmlDrug.SelectSingleNode("nosecondhand") != null || !cboGrade.Enabled && objForcedGrade?.SecondHand != true, false, strForceGrade); /* * string strNotes = xmlDrug.SelectSingleNode("altnotes")?.Value ?? xmlDrug.SelectSingleNode("notes")?.Value; * if (!string.IsNullOrEmpty(strNotes)) * { * lblDrugNotes.Visible = true; * lblDrugNotesLabel.Visible = true; * lblDrugNotes.Text = strNotes; * } * else * { * lblDrugNotes.Visible = false; * lblDrugNotesLabel.Visible = false; * }*/ tlpRight.Visible = true; } else { tlpRight.Visible = false; cboGrade.Enabled = !_blnLockGrade; strForceGrade = string.Empty; Grade objForcedGrade = null; if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D", GlobalOptions.InvariantCultureInfo) ?? cboGrade.SelectedValue?.ToString(); objForcedGrade = _objForcedGrade ?? _lstGrades.FirstOrDefault(x => x.SourceId.ToString("D", GlobalOptions.InvariantCultureInfo) == strForceGrade); } PopulateGrades(_blnLockGrade && objForcedGrade?.SecondHand != true, false, strForceGrade); chkBlackMarketDiscount.Checked = false; } _blnLoading = false; UpdateDrugInfo(); }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private async ValueTask UpdateSelectedVehicle() { if (_blnLoading) { return; } string strSelectedId = lstVehicle.SelectedValue?.ToString(); XPathNavigator objXmlVehicle = null; if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected Vehicle. objXmlVehicle = _xmlBaseVehicleDataNode.SelectSingleNode("vehicles/vehicle[id = " + strSelectedId.CleanXPath() + ']'); } if (objXmlVehicle == null) { tlpRight.Visible = false; return; } SuspendLayout(); lblVehicleHandling.Text = objXmlVehicle.SelectSingleNode("handling")?.Value; lblVehicleAccel.Text = objXmlVehicle.SelectSingleNode("accel")?.Value; lblVehicleSpeed.Text = objXmlVehicle.SelectSingleNode("speed")?.Value; lblVehiclePilot.Text = objXmlVehicle.SelectSingleNode("pilot")?.Value; lblVehicleBody.Text = objXmlVehicle.SelectSingleNode("body")?.Value; lblVehicleArmor.Text = objXmlVehicle.SelectSingleNode("armor")?.Value; lblVehicleSeats.Text = objXmlVehicle.SelectSingleNode("seats")?.Value; lblVehicleSensor.Text = objXmlVehicle.SelectSingleNode("sensor")?.Value; lblVehicleHandlingLabel.Visible = !string.IsNullOrEmpty(lblVehicleHandling.Text); lblVehicleAccelLabel.Visible = !string.IsNullOrEmpty(lblVehicleAccel.Text); lblVehicleSpeedLabel.Visible = !string.IsNullOrEmpty(lblVehicleSpeed.Text); lblVehiclePilotLabel.Visible = !string.IsNullOrEmpty(lblVehiclePilot.Text); lblVehicleBodyLabel.Visible = !string.IsNullOrEmpty(lblVehicleBody.Text); lblVehicleArmorLabel.Visible = !string.IsNullOrEmpty(lblVehicleArmor.Text); lblVehicleSeatsLabel.Visible = !string.IsNullOrEmpty(lblVehicleSeats.Text); lblVehicleSensorLabel.Visible = !string.IsNullOrEmpty(lblVehicleSensor.Text); AvailabilityValue objTotalAvail = new AvailabilityValue(0, objXmlVehicle.SelectSingleNode("avail")?.Value, chkUsedVehicle.Checked ? -4 : 0); lblVehicleAvail.Text = objTotalAvail.ToString(); lblVehicleAvailLabel.Visible = !string.IsNullOrEmpty(lblVehicleAvail.Text); bool blnCanBlackMarketDiscount = _setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value); chkBlackMarketDiscount.Enabled = blnCanBlackMarketDiscount; if (!chkBlackMarketDiscount.Checked) { chkBlackMarketDiscount.Checked = GlobalSettings.AssumeBlackMarket && blnCanBlackMarketDiscount; } else if (!blnCanBlackMarketDiscount) { //Prevent chkBlackMarketDiscount from being checked if the category doesn't match. chkBlackMarketDiscount.Checked = false; } UpdateSelectedVehicleCost(); string strSource = objXmlVehicle.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await objXmlVehicle.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? objXmlVehicle.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); await lblSource.SetToolTipAsync(objSource.LanguageBookTooltip); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; ResumeLayout(); }
/// <summary> /// Refresh the information for the selected Vehicle. /// </summary> private void UpdateSelectedVehicle() { if (_blnLoading) { return; } string strSelectedId = lstVehicle.SelectedValue?.ToString(); XPathNavigator objXmlVehicle = null; if (!string.IsNullOrEmpty(strSelectedId)) { // Retireve the information for the selected Vehicle. objXmlVehicle = _xmlBaseVehicleDataNode.SelectSingleNode("vehicles/vehicle[id = " + strSelectedId.CleanXPath() + "]"); } if (objXmlVehicle == null) { tlpRight.Visible = false; return; } decimal decCostModifier = 1.0m; if (chkUsedVehicle.Checked) { decCostModifier -= (nudUsedVehicleDiscount.Value / 100.0m); } SuspendLayout(); lblVehicleHandling.Text = objXmlVehicle.SelectSingleNode("handling")?.Value; lblVehicleAccel.Text = objXmlVehicle.SelectSingleNode("accel")?.Value; lblVehicleSpeed.Text = objXmlVehicle.SelectSingleNode("speed")?.Value; lblVehiclePilot.Text = objXmlVehicle.SelectSingleNode("pilot")?.Value; lblVehicleBody.Text = objXmlVehicle.SelectSingleNode("body")?.Value; lblVehicleArmor.Text = objXmlVehicle.SelectSingleNode("armor")?.Value; lblVehicleSeats.Text = objXmlVehicle.SelectSingleNode("seats")?.Value; lblVehicleSensor.Text = objXmlVehicle.SelectSingleNode("sensor")?.Value; lblVehicleHandlingLabel.Visible = !string.IsNullOrEmpty(lblVehicleHandling.Text); lblVehicleAccelLabel.Visible = !string.IsNullOrEmpty(lblVehicleAccel.Text); lblVehicleSpeedLabel.Visible = !string.IsNullOrEmpty(lblVehicleSpeed.Text); lblVehiclePilotLabel.Visible = !string.IsNullOrEmpty(lblVehiclePilot.Text); lblVehicleBodyLabel.Visible = !string.IsNullOrEmpty(lblVehicleBody.Text); lblVehicleArmorLabel.Visible = !string.IsNullOrEmpty(lblVehicleArmor.Text); lblVehicleSeatsLabel.Visible = !string.IsNullOrEmpty(lblVehicleSeats.Text); lblVehicleSensorLabel.Visible = !string.IsNullOrEmpty(lblVehicleSensor.Text); AvailabilityValue objTotalAvail = new AvailabilityValue(0, objXmlVehicle.SelectSingleNode("avail")?.Value, chkUsedVehicle.Checked ? -4 : 0); lblVehicleAvail.Text = objTotalAvail.ToString(); lblVehicleAvailLabel.Visible = !string.IsNullOrEmpty(lblVehicleAvail.Text); chkBlackMarketDiscount.Enabled = _objCharacter.BlackMarketDiscount; if (!chkBlackMarketDiscount.Checked) { chkBlackMarketDiscount.Checked = GlobalOptions.AssumeBlackMarket && _setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category") ?.Value); } else if (!_setBlackMarketMaps.Contains(objXmlVehicle.SelectSingleNode("category")?.Value)) { //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match. chkBlackMarketDiscount.Checked = false; } // Apply the cost multiplier to the Vehicle (will be 1 unless Used Vehicle is selected) string strCost = objXmlVehicle.SelectSingleNode("cost")?.Value ?? string.Empty; if (strCost.StartsWith("Variable", StringComparison.Ordinal)) { lblVehicleCost.Text = strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')'); lblVehicleCostLabel.Visible = !string.IsNullOrEmpty(lblVehicleCost.Text); lblTest.Text = string.Empty; lblTestLabel.Visible = false; } else { decimal decCost = 0.0m; if (!chkFreeItem.Checked) { if (decimal.TryParse(strCost, NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out decimal decTmp)) { decCost = decTmp; } // Apply the markup if applicable. decCost *= decCostModifier; decCost *= 1 + (nudMarkup.Value / 100.0m); if (chkBlackMarketDiscount.Checked) { decCost *= 0.9m; } if (_setDealerConnectionMaps != null) { if (_setDealerConnectionMaps.Any(set => objXmlVehicle.SelectSingleNode("category")?.Value.StartsWith(set, StringComparison.Ordinal) == true)) { decCost *= 0.9m; } } } lblVehicleCost.Text = decCost.ToString(_objCharacter.Options.NuyenFormat, GlobalOptions.CultureInfo) + '¥'; lblVehicleCostLabel.Visible = !string.IsNullOrEmpty(lblVehicleCost.Text); lblTest.Text = _objCharacter.AvailTest(decCost, lblVehicleAvail.Text); lblTestLabel.Visible = !string.IsNullOrEmpty(lblTest.Text); } string strSource = objXmlVehicle.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = objXmlVehicle.SelectSingleNode("altpage")?.Value ?? objXmlVehicle.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; ResumeLayout(); }
private async void trePowers_AfterSelect(object sender, TreeViewEventArgs e) { await lblPowerPoints.DoThreadSafeAsync(x => x.Visible = false); await lblPowerPointsLabel.DoThreadSafeAsync(x => x.Visible = false); string strSelectedPower = await trePowers.DoThreadSafeFuncAsync(x => x.SelectedNode.Tag?.ToString()); if (!string.IsNullOrEmpty(strSelectedPower)) { XPathNavigator objXmlPower = _xmlBaseCritterPowerDataNode.SelectSingleNode("powers/power[id = " + strSelectedPower.CleanXPath() + ']'); if (objXmlPower != null) { string strCategory = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("category"))?.Value ?? string.Empty; await lblCritterPowerCategory.DoThreadSafeAsync(x => x.Text = strCategory); string strType = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("type"))?.Value ?? string.Empty; switch (strType) { case "M": strType = await LanguageManager.GetStringAsync("String_SpellTypeMana"); break; case "P": strType = await LanguageManager.GetStringAsync("String_SpellTypePhysical"); break; } await lblCritterPowerType.DoThreadSafeAsync(x => x.Text = strType); string strAction = objXmlPower.SelectSingleNode("action")?.Value ?? string.Empty; switch (strAction) { case "Auto": strAction = await LanguageManager.GetStringAsync("String_ActionAutomatic"); break; case "Free": strAction = await LanguageManager.GetStringAsync("String_ActionFree"); break; case "Simple": strAction = await LanguageManager.GetStringAsync("String_ActionSimple"); break; case "Complex": strAction = await LanguageManager.GetStringAsync("String_ActionComplex"); break; case "Special": strAction = await LanguageManager.GetStringAsync("String_SpellDurationSpecial"); break; } await lblCritterPowerAction.DoThreadSafeAsync(x => x.Text = strAction); string strRange = objXmlPower.SelectSingleNode("range")?.Value ?? string.Empty; if (!string.IsNullOrEmpty(strRange)) { strRange = await strRange.CheapReplaceAsync("Self", () => LanguageManager.GetStringAsync("String_SpellRangeSelf")) .CheapReplaceAsync("Special", () => LanguageManager.GetStringAsync("String_SpellDurationSpecial")) .CheapReplaceAsync("LOS", () => LanguageManager.GetStringAsync("String_SpellRangeLineOfSight")) .CheapReplaceAsync("LOI", () => LanguageManager.GetStringAsync("String_SpellRangeLineOfInfluence")) .CheapReplaceAsync("Touch", () => LanguageManager.GetStringAsync("String_SpellRangeTouchLong")) .CheapReplaceAsync("T", () => LanguageManager.GetStringAsync("String_SpellRangeTouch")) .CheapReplaceAsync("(A)", async() => '(' + await LanguageManager.GetStringAsync("String_SpellRangeArea") + ')') .CheapReplaceAsync("MAG", () => LanguageManager.GetStringAsync("String_AttributeMAGShort")); } await lblCritterPowerRange.DoThreadSafeAsync(x => x.Text = strRange); string strDuration = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("duration"))?.Value ?? string.Empty; switch (strDuration) { case "Instant": strDuration = await LanguageManager.GetStringAsync("String_SpellDurationInstantLong"); break; case "Sustained": strDuration = await LanguageManager.GetStringAsync("String_SpellDurationSustained"); break; case "Always": strDuration = await LanguageManager.GetStringAsync("String_SpellDurationAlways"); break; case "Special": strDuration = await LanguageManager.GetStringAsync("String_SpellDurationSpecial"); break; } await lblCritterPowerDuration.DoThreadSafeAsync(x => x.Text = strDuration); string strSource = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("source"))?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("page"))?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSource.SetControlAsync(lblCritterPowerSource); bool blnVisible = await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("rating") != null; await nudCritterPowerRating.DoThreadSafeAsync(x => x.Visible = blnVisible); string strKarma = (await objXmlPower.SelectSingleNodeAndCacheExpressionAsync("karma"))?.Value ?? "0"; await lblKarma.DoThreadSafeAsync(x => x.Text = strKarma); // If the character is a Free Spirit, populate the Power Points Cost as well. if (_objCharacter.Metatype == "Free Spirit") { XPathNavigator xmlOptionalPowerCostNode = _xmlMetatypeDataNode.SelectSingleNode("optionalpowers/power[. = " + objXmlPower.SelectSingleNode("name")?.Value.CleanXPath() + "]/@cost"); if (xmlOptionalPowerCostNode != null) { await lblPowerPoints.DoThreadSafeAsync(x => { x.Text = xmlOptionalPowerCostNode.Value; x.Visible = true; }); await lblPowerPointsLabel.DoThreadSafeAsync(x => x.Visible = true); } } await lblCritterPowerTypeLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strType)); await lblCritterPowerActionLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strAction)); await lblCritterPowerRangeLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strRange)); await lblCritterPowerDurationLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strDuration)); await lblCritterPowerSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(objSource.ToString())); await lblKarmaLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strKarma)); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); } } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); } }
private void lstQualities_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } string strSpace = LanguageManager.GetString("String_Space"); XPathNavigator xmlQuality = null; string strSelectedQuality = lstQualities.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedQuality)) { xmlQuality = _xmlBaseQualityDataNode.SelectSingleNode("qualities/quality[id = " + strSelectedQuality.CleanXPath() + "]"); } if (xmlQuality != null) { if (chkFree.Checked) { lblBP.Text = 0.ToString(GlobalOptions.CultureInfo); } else { string strKarma = xmlQuality.SelectSingleNode("karma")?.Value ?? string.Empty; if (strKarma.StartsWith("Variable(", StringComparison.Ordinal)) { int intMin; int intMax = int.MaxValue; string strCost = strKarma.TrimStartOnce("Variable(", true).TrimEndOnce(')'); if (strCost.Contains('-')) { string[] strValues = strCost.Split('-'); int.TryParse(strValues[0], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out intMin); int.TryParse(strValues[1], NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out intMax); } else { int.TryParse(strCost.FastEscape('+'), NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out intMin); } lblBP.Text = intMax == int.MaxValue ? intMin.ToString(GlobalOptions.CultureInfo) : string.Format(GlobalOptions.CultureInfo, "{0}{1}-{1}{2}", intMin, strSpace, intMax); } else { int.TryParse(strKarma, NumberStyles.Any, GlobalOptions.InvariantCultureInfo, out int intBP); if (xmlQuality.SelectSingleNode("costdiscount").RequirementsMet(_objCharacter)) { string strValue = xmlQuality.SelectSingleNode("costdiscount/value")?.Value; switch (xmlQuality.SelectSingleNode("category")?.Value) { case "Positive": intBP += Convert.ToInt32(strValue, GlobalOptions.InvariantCultureInfo); break; case "Negative": intBP -= Convert.ToInt32(strValue, GlobalOptions.InvariantCultureInfo); break; } } if (_objCharacter.Created && !_objCharacter.Options.DontDoubleQualityPurchases) { string strDoubleCostCareer = xmlQuality.SelectSingleNode("doublecareer")?.Value; if (string.IsNullOrEmpty(strDoubleCostCareer) || strDoubleCostCareer != bool.FalseString) { intBP *= 2; } } lblBP.Text = (intBP * _objCharacter.Options.KarmaQuality).ToString(GlobalOptions.CultureInfo); if (!_objCharacter.Created && _objCharacter.FreeSpells > 0 && Convert.ToBoolean(xmlQuality.SelectSingleNode("canbuywithspellpoints")?.Value, GlobalOptions.InvariantCultureInfo)) { int i = (intBP * _objCharacter.Options.KarmaQuality); int spellPoints = 0; while (i > 0) { i -= 5; spellPoints++; } lblBP.Text += string.Format(GlobalOptions.CultureInfo, "{0}/{0}{1}{0}{2}", LanguageManager.GetString("String_Space"), spellPoints, LanguageManager.GetString("String_SpellPoints")); lblBP.ToolTipText = LanguageManager.GetString("Tip_SelectSpell_MasteryQuality"); } else { lblBP.ToolTipText = string.Empty; } } } lblBPLabel.Visible = lblBP.Visible = !string.IsNullOrEmpty(lblBP.Text); string strSource = xmlQuality.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = xmlQuality.SelectSingleNode("altpage")?.Value ?? xmlQuality.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); lblSourceLabel.Visible = lblSource.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; } else { tlpRight.Visible = false; } }
private void RefreshSelectedMetavariant() { string strSpace = LanguageManager.GetString("String_Space"); XPathNavigator objXmlMetatype = null; XPathNavigator objXmlMetavariant = null; string strSelectedMetatype = lstMetatypes.SelectedValue?.ToString(); if (!string.IsNullOrEmpty(strSelectedMetatype)) { objXmlMetatype = _xmlBaseMetatypeDataNode.SelectSingleNode("metatypes/metatype[id = " + strSelectedMetatype.CleanXPath() + "]"); string strSelectedMetavariant = cboMetavariant.SelectedValue?.ToString(); if (objXmlMetatype != null && !string.IsNullOrEmpty(strSelectedMetavariant) && strSelectedMetavariant != "None") { objXmlMetavariant = objXmlMetatype.SelectSingleNode("metavariants/metavariant[id = " + strSelectedMetavariant.CleanXPath() + "]"); } } string strAttributeFormat = "{0}/{1}{2}({3})"; if (objXmlMetavariant != null) { cmdOK.Enabled = true; if (objXmlMetatype.SelectSingleNode("forcecreature") == null) { lblBOD.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("bodmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("bodmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("bodaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblAGI.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("agimin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("agimax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("agiaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblREA.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("reamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("reamax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("reaaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblSTR.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("strmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("strmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("straug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblCHA.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("chamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("chamax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("chaaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblINT.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("intmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("intmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("intaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblLOG.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("logmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("logmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("logaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblWIL.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetavariant.SelectSingleNode("wilmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetavariant.SelectSingleNode("wilmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetavariant.SelectSingleNode("wilaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); } else { lblBOD.Text = objXmlMetavariant.SelectSingleNode("bodmin")?.Value ?? objXmlMetatype.SelectSingleNode("bodmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblAGI.Text = objXmlMetavariant.SelectSingleNode("agimin")?.Value ?? objXmlMetatype.SelectSingleNode("agimin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblREA.Text = objXmlMetavariant.SelectSingleNode("reamin")?.Value ?? objXmlMetatype.SelectSingleNode("reamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblSTR.Text = objXmlMetavariant.SelectSingleNode("strmin")?.Value ?? objXmlMetatype.SelectSingleNode("strmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblCHA.Text = objXmlMetavariant.SelectSingleNode("chamin")?.Value ?? objXmlMetatype.SelectSingleNode("chamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblINT.Text = objXmlMetavariant.SelectSingleNode("intmin")?.Value ?? objXmlMetatype.SelectSingleNode("intmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblLOG.Text = objXmlMetavariant.SelectSingleNode("logmin")?.Value ?? objXmlMetatype.SelectSingleNode("logmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblWIL.Text = objXmlMetavariant.SelectSingleNode("wilmin")?.Value ?? objXmlMetatype.SelectSingleNode("wilmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); } // ReSharper disable once IdentifierTypo StringBuilder sbdQualities = new StringBuilder(); // Build a list of the Metavariant's Qualities. foreach (XPathNavigator objXmlQuality in objXmlMetavariant.Select("qualities/*/quality")) { if (!GlobalOptions.Language.Equals(GlobalOptions.DefaultLanguage, StringComparison.OrdinalIgnoreCase)) { sbdQualities.Append(_xmlBaseQualityDataNode.SelectSingleNode("qualities/quality[name = " + objXmlQuality.Value.CleanXPath() + "]/translate")?.Value ?? objXmlQuality.Value); string strSelect = objXmlQuality.SelectSingleNode("@select")?.Value; if (!string.IsNullOrEmpty(strSelect)) { sbdQualities.Append(LanguageManager.GetString("String_Space") + '('); sbdQualities.Append(_objCharacter.TranslateExtra(strSelect)); sbdQualities.Append(')'); } } else { sbdQualities.Append(objXmlQuality.Value); string strSelect = objXmlQuality.SelectSingleNode("@select")?.Value; if (!string.IsNullOrEmpty(strSelect)) { sbdQualities.Append(LanguageManager.GetString("String_Space") + '('); sbdQualities.Append(strSelect); sbdQualities.Append(')'); } } sbdQualities.Append(Environment.NewLine); } lblQualities.Text = sbdQualities.Length == 0 ? LanguageManager.GetString("String_None") : sbdQualities.ToString(); lblKarma.Text = objXmlMetavariant.SelectSingleNode("karma")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); string strSource = objXmlMetavariant.SelectSingleNode("source")?.Value; if (!string.IsNullOrEmpty(strSource)) { string strPage = objXmlMetavariant.SelectSingleNode("altpage")?.Value ?? objXmlMetavariant.SelectSingleNode("page")?.Value; if (!string.IsNullOrEmpty(strPage)) { SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); } else { string strUnknown = LanguageManager.GetString("String_Unknown"); lblSource.Text = strUnknown; lblSource.SetToolTip(strUnknown); } } else { string strUnknown = LanguageManager.GetString("String_Unknown"); lblSource.Text = strUnknown; lblSource.SetToolTip(strUnknown); } } else if (objXmlMetatype != null) { cmdOK.Enabled = true; if (objXmlMetatype.SelectSingleNode("forcecreature") == null) { lblBOD.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("bodmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("bodmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("bodaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblAGI.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("agimin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("agimax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("agiaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblREA.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("reamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("reamax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("reaaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblSTR.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("strmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("strmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("straug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblCHA.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("chamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("chamax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("chaaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblINT.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("intmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("intmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("intaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblLOG.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("logmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("logmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("logaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); lblWIL.Text = string.Format(GlobalOptions.CultureInfo, strAttributeFormat, objXmlMetatype.SelectSingleNode("wilmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), objXmlMetatype.SelectSingleNode("wilmax")?.Value ?? 0.ToString(GlobalOptions.CultureInfo), strSpace, objXmlMetatype.SelectSingleNode("wilaug")?.Value ?? 0.ToString(GlobalOptions.CultureInfo)); } else { lblBOD.Text = objXmlMetatype.SelectSingleNode("bodmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblAGI.Text = objXmlMetatype.SelectSingleNode("agimin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblREA.Text = objXmlMetatype.SelectSingleNode("reamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblSTR.Text = objXmlMetatype.SelectSingleNode("strmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblCHA.Text = objXmlMetatype.SelectSingleNode("chamin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblINT.Text = objXmlMetatype.SelectSingleNode("intmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblLOG.Text = objXmlMetatype.SelectSingleNode("logmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); lblWIL.Text = objXmlMetatype.SelectSingleNode("wilmin")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); } // ReSharper disable once IdentifierTypo StringBuilder sbdQualities = new StringBuilder(); // Build a list of the Metatype's Positive Qualities. foreach (XPathNavigator objXmlQuality in objXmlMetatype.Select("qualities/*/quality")) { if (!GlobalOptions.Language.Equals(GlobalOptions.DefaultLanguage, StringComparison.OrdinalIgnoreCase)) { sbdQualities.Append(_xmlBaseQualityDataNode.SelectSingleNode("qualities/quality[name = " + objXmlQuality.Value.CleanXPath() + "]/translate")?.Value ?? objXmlQuality.Value); string strSelect = objXmlQuality.SelectSingleNode("@select")?.Value; if (!string.IsNullOrEmpty(strSelect)) { sbdQualities.Append(LanguageManager.GetString("String_Space") + '('); sbdQualities.Append(_objCharacter.TranslateExtra(strSelect)); sbdQualities.Append(')'); } } else { sbdQualities.Append(objXmlQuality.Value); string strSelect = objXmlQuality.SelectSingleNode("@select")?.Value; if (!string.IsNullOrEmpty(strSelect)) { sbdQualities.Append(LanguageManager.GetString("String_Space") + '('); sbdQualities.Append(strSelect); sbdQualities.Append(')'); } } sbdQualities.Append(Environment.NewLine); } lblQualities.Text = sbdQualities.Length == 0 ? LanguageManager.GetString("String_None") : sbdQualities.ToString(); lblKarma.Text = objXmlMetatype.SelectSingleNode("karma")?.Value ?? 0.ToString(GlobalOptions.CultureInfo); string strSource = objXmlMetatype.SelectSingleNode("source")?.Value; if (!string.IsNullOrEmpty(strSource)) { string strPage = objXmlMetatype.SelectSingleNode("altpage")?.Value ?? objXmlMetatype.SelectSingleNode("page")?.Value; if (!string.IsNullOrEmpty(strPage)) { SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); } else { string strUnknown = LanguageManager.GetString("String_Unknown"); lblSource.Text = strUnknown; lblSource.SetToolTip(strUnknown); } } else { string strUnknown = LanguageManager.GetString("String_Unknown"); lblSource.Text = strUnknown; lblSource.SetToolTip(strUnknown); } } else { lblBOD.Text = string.Empty; lblAGI.Text = string.Empty; lblREA.Text = string.Empty; lblSTR.Text = string.Empty; lblCHA.Text = string.Empty; lblINT.Text = string.Empty; lblLOG.Text = string.Empty; lblWIL.Text = string.Empty; lblQualities.Text = string.Empty; lblKarma.Text = string.Empty; lblSource.Text = string.Empty; cmdOK.Enabled = false; } lblBODLabel.Visible = !string.IsNullOrEmpty(lblBOD.Text); lblAGILabel.Visible = !string.IsNullOrEmpty(lblAGI.Text); lblREALabel.Visible = !string.IsNullOrEmpty(lblREA.Text); lblSTRLabel.Visible = !string.IsNullOrEmpty(lblSTR.Text); lblCHALabel.Visible = !string.IsNullOrEmpty(lblCHA.Text); lblINTLabel.Visible = !string.IsNullOrEmpty(lblINT.Text); lblLOGLabel.Visible = !string.IsNullOrEmpty(lblLOG.Text); lblWILLabel.Visible = !string.IsNullOrEmpty(lblWIL.Text); lblQualitiesLabel.Visible = !string.IsNullOrEmpty(lblQualities.Text); lblKarmaLabel.Visible = !string.IsNullOrEmpty(lblKarma.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); }
private void RefreshSelectedLifestyle() { if (_blnSkipRefresh) { return; } string strBaseLifestyle = cboBaseLifestyle.SelectedValue?.ToString() ?? string.Empty; _objLifestyle.BaseLifestyle = strBaseLifestyle; XmlNode xmlAspect = _objLifestyle.GetNode(); if (xmlAspect != null) { string strSource = xmlAspect["source"]?.InnerText ?? string.Empty; string strPage = xmlAspect["altpage"]?.InnerText ?? xmlAspect["page"]?.InnerText ?? string.Empty; if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage)) { SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); } else { lblSource.Text = string.Empty; lblSource.SetToolTip(string.Empty); } } else { lblSource.Text = string.Empty; lblSource.SetToolTip(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 = GlobalOptions.RandomGenerator.NextD6ModuloBiasRemoved(); _blnSkipRefresh = false; } else { nudBonusLP.Enabled = true; } } else { lblBonusLP.Visible = false; nudBonusLP.Visible = false; nudBonusLP.Value = 0; chkBonusLPRandomize.Visible = false; } }
private async void lstMetamagic_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } string strSelectedId = await lstMetamagic.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected metamagic/echo. XPathNavigator objXmlMetamagic = _objXmlDocument.SelectSingleNode(_strRootXPath + "[id = " + strSelectedId.CleanXPath() + ']'); if (objXmlMetamagic != null) { string strSource = objXmlMetamagic.SelectSingleNode("source")?.Value; string strPage = (await objXmlMetamagic.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? objXmlMetamagic.SelectSingleNode("page")?.Value; SourceString objSourceString = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSourceString.SetControlAsync(lblSource); await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(objSourceString.ToString())); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); } } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); } }
private void lstComplexForms_SelectedIndexChanged(object sender, EventArgs e) { string strSelectedComplexFormId = lstComplexForms.SelectedValue?.ToString(); if (_blnLoading || string.IsNullOrEmpty(strSelectedComplexFormId)) { tlpRight.Visible = false; return; } // Display the Complex Form information. XPathNavigator xmlComplexForm = _xmlBaseComplexFormsNode.SelectSingleNode("complexform[id = " + strSelectedComplexFormId.CleanXPath() + ']'); if (xmlComplexForm == null) { tlpRight.Visible = false; return; } SuspendLayout(); switch (xmlComplexForm.SelectSingleNode("duration")?.Value) { case "P": lblDuration.Text = LanguageManager.GetString("String_SpellDurationPermanent"); break; case "S": lblDuration.Text = LanguageManager.GetString("String_SpellDurationSustained"); break; case "Special": lblDuration.Text = LanguageManager.GetString("String_SpellDurationSpecial"); break; default: lblDuration.Text = LanguageManager.GetString("String_SpellDurationInstant"); break; } switch (xmlComplexForm.SelectSingleNode("target")?.Value) { case "Persona": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetPersona"); break; case "Device": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetDevice"); break; case "File": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetFile"); break; case "Self": lblTarget.Text = LanguageManager.GetString("String_SpellRangeSelf"); break; case "Sprite": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetSprite"); break; case "Host": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetHost"); break; case "IC": lblTarget.Text = LanguageManager.GetString("String_ComplexFormTargetIC"); break; default: lblTarget.Text = LanguageManager.GetString("String_None"); break; } string strFv = xmlComplexForm.SelectSingleNode("fv")?.Value.Replace('/', '÷').Replace('*', '×') ?? string.Empty; if (!GlobalSettings.Language.Equals(GlobalSettings.DefaultLanguage, StringComparison.OrdinalIgnoreCase)) { strFv = strFv.CheapReplace("L", () => LanguageManager.GetString("String_ComplexFormLevel")) .CheapReplace("Overflow damage", () => LanguageManager.GetString("String_SpellOverflowDamage")) .CheapReplace("Damage Value", () => LanguageManager.GetString("String_SpellDamageValue")) .CheapReplace("Toxin DV", () => LanguageManager.GetString("String_SpellToxinDV")) .CheapReplace("Disease DV", () => LanguageManager.GetString("String_SpellDiseaseDV")) .CheapReplace("Radiation Power", () => LanguageManager.GetString("String_SpellRadiationPower")); } lblFV.Text = strFv; string strSource = xmlComplexForm.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = xmlComplexForm.SelectSingleNodeAndCacheExpression("altpage")?.Value ?? xmlComplexForm.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); lblDurationLabel.Visible = !string.IsNullOrEmpty(lblDuration.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); lblFVLabel.Visible = !string.IsNullOrEmpty(lblFV.Text); lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); tlpRight.Visible = true; ResumeLayout(); }
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; } }
private async void lstQualities_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } _blnLoading = true; try { XPathNavigator xmlQuality = null; string strSelectedQuality = await lstQualities.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); if (!string.IsNullOrEmpty(strSelectedQuality)) { xmlQuality = _xmlBaseQualityDataNode.SelectSingleNode( "qualities/quality[id = " + strSelectedQuality.CleanXPath() + ']'); } if (xmlQuality != null) { await nudRating.DoThreadSafeAsync(x => x.ValueAsInt = x.MinimumAsInt); int intMaxRating = int.MaxValue; if (xmlQuality.TryGetInt32FieldQuickly("limit", ref intMaxRating) && xmlQuality.SelectSingleNode("nolevels") == null) { await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = false); await nudRating.DoThreadSafeAsync(x => { x.MaximumAsInt = intMaxRating; x.Visible = true; }); } else { await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = true); await nudRating.DoThreadSafeAsync(x => { x.MaximumAsInt = 1; x.ValueAsInt = 1; x.Visible = false; }); } await UpdateCostLabel(xmlQuality); string strSource = xmlQuality.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await xmlQuality.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlQuality.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync( strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSource.SetControlAsync(lblSource); await lblSourceLabel.DoThreadSafeAsync( x => x.Visible = !string.IsNullOrEmpty(objSource.ToString())); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); } } finally { _blnLoading = false; } }
private async void lstDrug_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } _blnLoading = true; XPathNavigator xmlDrug = null; string strSelectedId = await lstDrug.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); if (!string.IsNullOrEmpty(strSelectedId)) { // Retrieve the information for the selected piece of Drug. xmlDrug = _xmlBaseDrugDataNode.SelectSingleNode(_strNodeXPath + "[id = " + strSelectedId.CleanXPath() + ']'); } string strForceGrade; if (xmlDrug != null) { strForceGrade = xmlDrug.SelectSingleNode("forcegrade")?.Value; // If the piece has a Rating value, enable the Rating control, otherwise, disable it and set its value to 0. XPathNavigator xmlRatingNode = xmlDrug.SelectSingleNode("rating"); if (xmlRatingNode != null) { string strMinRating = xmlDrug.SelectSingleNode("minrating")?.Value; int intMinRating = 1; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMinRating) && !int.TryParse(strMinRating, out intMinRating)) { strMinRating = await strMinRating .CheapReplaceAsync("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum) .ToString(GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum) .ToString(GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString( GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString( GlobalSettings.InvariantCultureInfo)); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMinRating, out bool blnIsSuccess); intMinRating = blnIsSuccess ? ((double)objProcess).StandardRound() : 1; } await nudRating.DoThreadSafeAsync(x => x.Minimum = intMinRating); string strMaxRating = xmlRatingNode.Value; int intMaxRating = 0; // Not a simple integer, so we need to start mucking around with strings if (!string.IsNullOrEmpty(strMaxRating) && !int.TryParse(strMaxRating, out intMaxRating)) { strMaxRating = await strMaxRating .CheapReplaceAsync("MaximumSTR", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.TotalBody * 2) : _objCharacter.STR.TotalMaximum) .ToString(GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MaximumAGI", () => (ParentVehicle != null ? Math.Max(1, ParentVehicle.Pilot * 2) : _objCharacter.AGI.TotalMaximum) .ToString(GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MinimumSTR", () => (ParentVehicle?.TotalBody ?? 3).ToString( GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("MinimumAGI", () => (ParentVehicle?.Pilot ?? 3).ToString( GlobalSettings.InvariantCultureInfo)); object objProcess = CommonFunctions.EvaluateInvariantXPath(strMaxRating, out bool blnIsSuccess); intMaxRating = blnIsSuccess ? ((double)objProcess).StandardRound() : 1; } await nudRating.DoThreadSafeAsync(x => x.Maximum = intMaxRating); if (await chkHideOverAvailLimit.DoThreadSafeFuncAsync(x => x.Checked)) { int intAvailModifier = strForceGrade == "None" ? 0 : _intAvailModifier; await nudRating.DoThreadSafeAsync(x => { while (x.Maximum > intMinRating && !xmlDrug.CheckAvailRestriction(_objCharacter, x.MaximumAsInt, intAvailModifier)) { --x.Maximum; } }); } if (await chkShowOnlyAffordItems.DoThreadSafeFuncAsync(x => x.Checked) && !await chkFree.DoThreadSafeFuncAsync(x => x.Checked)) { decimal decCostMultiplier = 1 + nudMarkup.Value / 100.0m; if (await chkBlackMarketDiscount.DoThreadSafeFuncAsync(x => x.Checked)) { decCostMultiplier *= 0.9m; } await nudRating.DoThreadSafeAsync(x => { while (x.Maximum > intMinRating && !xmlDrug.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier, x.MaximumAsInt)) { --x.Maximum; } }); } await nudRating.DoThreadSafeAsync(x => { x.Value = x.Minimum; x.Enabled = x.Minimum != x.Maximum; x.Visible = true; }); await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = false); await lblRatingLabel.DoThreadSafeAsync(x => x.Visible = true); } else { await lblRatingLabel.DoThreadSafeAsync(x => x.Visible = true); await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = true); await nudRating.DoThreadSafeAsync(x => { x.Minimum = 0; x.Value = 0; x.Visible = false; }); } string strSource = xmlDrug.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await xmlDrug.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlDrug.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSource = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSource.SetControlAsync(lblSource); await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(objSource.ToString())); Grade objForcedGrade = null; if (!string.IsNullOrEmpty(strForceGrade)) { // Force the Drug to be a particular Grade. await cboGrade.DoThreadSafeAsync(x => { if (x.Enabled) { x.Enabled = false; } }); objForcedGrade = _lstGrades.Find(x => x.Name == strForceGrade); strForceGrade = objForcedGrade?.SourceId.ToString("D", GlobalSettings.InvariantCultureInfo); } else { await cboGrade.DoThreadSafeAsync(x => x.Enabled = !_blnLockGrade); if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D", GlobalSettings.InvariantCultureInfo) ?? cboGrade.SelectedValue?.ToString(); objForcedGrade = _objForcedGrade ?? _lstGrades.Find(x => x.SourceId.ToString("D", GlobalSettings.InvariantCultureInfo) == strForceGrade); } } bool blnCanBlackMarketDiscount = _setBlackMarketMaps.Contains(xmlDrug.SelectSingleNode("category")?.Value); await chkBlackMarketDiscount.DoThreadSafeAsync(x => { x.Enabled = blnCanBlackMarketDiscount; if (!x.Checked) { x.Checked = GlobalSettings.AssumeBlackMarket && blnCanBlackMarketDiscount; } else if (!blnCanBlackMarketDiscount) { //Prevent chkBlackMarketDiscount from being checked if the category doesn't match. x.Checked = false; } }); // We may need to rebuild the Grade list since Cultured Bioware is not allowed to select Standard (Second-Hand) as Grade and ForceGrades can change. await PopulateGrades(xmlDrug.SelectSingleNode("nosecondhand") != null || !await cboGrade.DoThreadSafeFuncAsync(x => x.Enabled) && objForcedGrade?.SecondHand != true, false, strForceGrade); /* * string strNotes = xmlDrug.SelectSingleNode("altnotes")?.Value ?? xmlDrug.SelectSingleNode("notes")?.Value; * if (!string.IsNullOrEmpty(strNotes)) * { * await lblDrugNotesLabel.DoThreadSafeAsync(x => x.Visible = true); * await lblDrugNotes.DoThreadSafeAsync(x => * { * x.Text = strNotes; * x.Visible = true; * }); * } * else * { * await lblDrugNotes.DoThreadSafeAsync(x => x.Visible = false); * await lblDrugNotesLabel.DoThreadSafeAsync(x => x.Visible = false); * }*/ await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); await cboGrade.DoThreadSafeAsync(x => x.Enabled = !_blnLockGrade); strForceGrade = string.Empty; Grade objForcedGrade = null; if (_blnLockGrade) { strForceGrade = _objForcedGrade?.SourceId.ToString("D", GlobalSettings.InvariantCultureInfo) ?? await cboGrade.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); objForcedGrade = _objForcedGrade ?? _lstGrades.Find(x => x.SourceId.ToString("D", GlobalSettings.InvariantCultureInfo) == strForceGrade); } await PopulateGrades(_blnLockGrade && objForcedGrade?.SecondHand != true, false, strForceGrade); await chkBlackMarketDiscount.DoThreadSafeAsync(x => x.Checked = false); } _blnLoading = false; await UpdateDrugInfo(); }
private void trePowers_AfterSelect(object sender, TreeViewEventArgs e) { lblPowerPoints.Visible = false; lblPowerPointsLabel.Visible = false; string strSelectedPower = trePowers.SelectedNode.Tag?.ToString(); if (!string.IsNullOrEmpty(strSelectedPower)) { XPathNavigator objXmlPower = _xmlBaseCritterPowerDataNode.SelectSingleNode("powers/power[id = " + strSelectedPower.CleanXPath() + "]"); if (objXmlPower != null) { lblCritterPowerCategory.Text = objXmlPower.SelectSingleNode("category")?.Value ?? string.Empty; switch (objXmlPower.SelectSingleNode("type")?.Value) { case "M": lblCritterPowerType.Text = LanguageManager.GetString("String_SpellTypeMana"); break; case "P": lblCritterPowerType.Text = LanguageManager.GetString("String_SpellTypePhysical"); break; default: lblCritterPowerType.Text = string.Empty; break; } switch (objXmlPower.SelectSingleNode("action")?.Value) { case "Auto": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionAutomatic"); break; case "Free": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionFree"); break; case "Simple": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionSimple"); break; case "Complex": lblCritterPowerAction.Text = LanguageManager.GetString("String_ActionComplex"); break; case "Special": lblCritterPowerAction.Text = LanguageManager.GetString("String_SpellDurationSpecial"); break; default: lblCritterPowerAction.Text = string.Empty; break; } string strRange = objXmlPower.SelectSingleNode("range")?.Value ?? string.Empty; if (!string.IsNullOrEmpty(strRange)) { strRange = strRange.CheapReplace("Self", () => LanguageManager.GetString("String_SpellRangeSelf")) .CheapReplace("Special", () => LanguageManager.GetString("String_SpellDurationSpecial")) .CheapReplace("LOS", () => LanguageManager.GetString("String_SpellRangeLineOfSight")) .CheapReplace("LOI", () => LanguageManager.GetString("String_SpellRangeLineOfInfluence")) .CheapReplace("T", () => LanguageManager.GetString("String_SpellRangeTouch")) .CheapReplace("(A)", () => "(" + LanguageManager.GetString("String_SpellRangeArea") + ')') .CheapReplace("MAG", () => LanguageManager.GetString("String_AttributeMAGShort")); } lblCritterPowerRange.Text = strRange; string strDuration = objXmlPower.SelectSingleNode("duration")?.Value ?? string.Empty; switch (strDuration) { case "Instant": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationInstantLong"); break; case "Sustained": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationSustained"); break; case "Always": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationAlways"); break; case "Special": lblCritterPowerDuration.Text = LanguageManager.GetString("String_SpellDurationSpecial"); break; default: lblCritterPowerDuration.Text = strDuration; break; } string strSource = objXmlPower.SelectSingleNode("source")?.Value ?? LanguageManager.GetString("String_Unknown"); string strPage = objXmlPower.SelectSingleNode("altpage")?.Value ?? objXmlPower.SelectSingleNode("page")?.Value ?? LanguageManager.GetString("String_Unknown"); SourceString objSource = new SourceString(strSource, strPage, GlobalOptions.Language, GlobalOptions.CultureInfo, _objCharacter); lblCritterPowerSource.Text = objSource.ToString(); lblCritterPowerSource.SetToolTip(objSource.LanguageBookTooltip); nudCritterPowerRating.Visible = objXmlPower.SelectSingleNode("rating") != null; lblKarma.Text = objXmlPower.SelectSingleNode("karma")?.Value ?? "0"; // If the character is a Free Spirit, populate the Power Points Cost as well. if (_objCharacter.Metatype == "Free Spirit") { XPathNavigator xmlOptionalPowerCostNode = _xmlMetatypeDataNode.SelectSingleNode("optionalpowers/power[. = " + objXmlPower.SelectSingleNode("name")?.Value.CleanXPath() + "]/@cost"); if (xmlOptionalPowerCostNode != null) { lblPowerPoints.Text = xmlOptionalPowerCostNode.Value; lblPowerPoints.Visible = true; lblPowerPointsLabel.Visible = true; } } } lblCritterPowerTypeLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerType.Text); lblCritterPowerActionLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerAction.Text); lblCritterPowerRangeLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerRange.Text); lblCritterPowerDurationLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerDuration.Text); lblCritterPowerSourceLabel.Visible = !string.IsNullOrEmpty(lblCritterPowerSource.Text); lblKarmaLabel.Visible = !string.IsNullOrEmpty(lblKarma.Text); tlpRight.Visible = true; } else { tlpRight.Visible = false; } }
private async void lstMartialArts_SelectedIndexChanged(object sender, EventArgs e) { if (_blnLoading) { return; } string strSelectedId = await lstMartialArts.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); if (!string.IsNullOrEmpty(strSelectedId)) { // Populate the Martial Arts list. XPathNavigator objXmlArt = _xmlBaseMartialArtsNode.SelectSingleNode("martialart[id = " + strSelectedId.CleanXPath() + ']'); if (objXmlArt != null) { string strKarmaCost = (await objXmlArt.SelectSingleNodeAndCacheExpressionAsync("cost"))?.Value ?? 7.ToString(GlobalSettings.CultureInfo); await lblKarmaCost.DoThreadSafeAsync(x => x.Text = strKarmaCost); await lblKarmaCostLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strKarmaCost)); string strTechniques; using (new FetchSafelyFromPool <StringBuilder>(Utils.StringBuilderPool, out StringBuilder sbdTechniques)) { foreach (XPathNavigator xmlMartialArtsTechnique in await objXmlArt.SelectAndCacheExpressionAsync( "techniques/technique")) { string strLoopTechniqueName = (await xmlMartialArtsTechnique.SelectSingleNodeAndCacheExpressionAsync("name"))?.Value ?? string.Empty; if (!string.IsNullOrEmpty(strLoopTechniqueName)) { XPathNavigator xmlTechniqueNode = _xmlBaseMartialArtsTechniquesNode.SelectSingleNode( "technique[name = " + strLoopTechniqueName.CleanXPath() + " and (" + _objCharacter.Settings.BookXPath() + ")]"); if (xmlTechniqueNode != null) { if (sbdTechniques.Length > 0) { sbdTechniques.AppendLine(','); } sbdTechniques.Append( !GlobalSettings.Language.Equals(GlobalSettings.DefaultLanguage, StringComparison.OrdinalIgnoreCase) ? (await xmlTechniqueNode.SelectSingleNodeAndCacheExpressionAsync("translate"))?.Value ?? strLoopTechniqueName : strLoopTechniqueName); } } } strTechniques = sbdTechniques.ToString(); } await lblIncludedTechniques.DoThreadSafeAsync(x => x.Text = strTechniques); await gpbIncludedTechniques.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strTechniques)); string strSource = (await objXmlArt.SelectSingleNodeAndCacheExpressionAsync("source"))?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await objXmlArt.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? (await objXmlArt.SelectSingleNodeAndCacheExpressionAsync("page"))?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSourceString = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSourceString.SetControlAsync(lblSource); string strSourceText = objSourceString.ToString(); await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strSourceText)); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); await gpbIncludedTechniques.DoThreadSafeAsync(x => x.Visible = false); } } else { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); await gpbIncludedTechniques.DoThreadSafeAsync(x => x.Visible = false); } }
/// <summary> /// Calculate the LP value for the selected items. /// </summary> private void CalculateValues(bool blnIncludePercentage = true) { if (_blnSkipRefresh) { return; } decimal decBaseCost = 0; decimal decCost = 0; decimal decMod = 0; string strBaseLifestyle = string.Empty; // Get the base cost of the lifestyle string strSelectedId = cboLifestyle.SelectedValue?.ToString(); if (strSelectedId != null) { XmlNode objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/lifestyles/lifestyle[id = " + strSelectedId.CleanXPath() + ']'); if (objXmlAspect != null) { objXmlAspect.TryGetStringFieldQuickly("name", ref strBaseLifestyle); decimal decTemp = 0; if (objXmlAspect.TryGetDecFieldQuickly("cost", ref decTemp)) { decBaseCost += decTemp; } string strSource = objXmlAspect["source"]?.InnerText; string strPage = objXmlAspect["altpage"]?.InnerText ?? objXmlAspect["page"]?.InnerText; if (!string.IsNullOrEmpty(strSource) && !string.IsNullOrEmpty(strPage)) { SourceString objSource = new SourceString(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); lblSource.Text = objSource.ToString(); lblSource.SetToolTip(objSource.LanguageBookTooltip); } else { lblSource.Text = LanguageManager.GetString("String_Unknown"); lblSource.SetToolTip(LanguageManager.GetString("String_Unknown")); } lblSourceLabel.Visible = !string.IsNullOrEmpty(lblSource.Text); // Add the flat costs from qualities foreach (TreeNode objNode in treQualities.Nodes) { if (objNode.Checked) { string strCost = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = " + objNode.Tag.ToString().CleanXPath() + "]/cost")?.InnerText; if (!string.IsNullOrEmpty(strCost)) { object objProcess = CommonFunctions.EvaluateInvariantXPath(strCost, out bool blnIsSuccess); if (blnIsSuccess) { decCost += Convert.ToDecimal(objProcess, GlobalSettings.InvariantCultureInfo); } } } } decimal decBaseMultiplier = 0; if (blnIncludePercentage) { // Add the modifiers from qualities foreach (TreeNode objNode in treQualities.Nodes) { if (!objNode.Checked) { continue; } objXmlAspect = _objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = " + objNode.Tag.ToString().CleanXPath() + ']'); if (objXmlAspect == null) { continue; } if (objXmlAspect.TryGetDecFieldQuickly("multiplier", ref decTemp)) { decMod += decTemp / 100.0m; } if (objXmlAspect.TryGetDecFieldQuickly("multiplierbaseonly", ref decTemp)) { decBaseMultiplier += decTemp / 100.0m; } } // Check for modifiers in the improvements decMod += ImprovementManager.ValueOf(_objCharacter, Improvement.ImprovementType.LifestyleCost) / 100.0m; } decBaseCost += decBaseCost * decBaseMultiplier; if (nudRoommates.Value > 0) { decBaseCost *= 1.0m + Math.Max(nudRoommates.Value / 10.0m, 0); } } } decimal decNuyen = decBaseCost + decBaseCost * decMod + decCost; lblCost.Text = decNuyen.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + '¥'; if (nudPercentage.Value != 100 || nudRoommates.Value != 0 && !chkPrimaryTenant.Checked) { decimal decDiscount = decNuyen; decDiscount *= nudPercentage.Value / 100; if (nudRoommates.Value != 0) { decDiscount /= nudRoommates.Value; } lblCost.Text += LanguageManager.GetString("String_Space") + '(' + decDiscount.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + "¥)"; } lblCostLabel.Visible = !string.IsNullOrEmpty(lblCost.Text); // Characters with the Trust Fund Quality can have the lifestyle discounted. if (Lifestyle.StaticIsTrustFundEligible(_objCharacter, strBaseLifestyle)) { chkTrustFund.Visible = true; chkTrustFund.Checked = _objSourceLifestyle?.TrustFund ?? !_objCharacter.Lifestyles.Any(x => x.TrustFund); } else { chkTrustFund.Checked = false; chkTrustFund.Visible = false; } }
private async ValueTask UpdateGearInfo(bool blnUpdateMountComboBoxes = true) { if (_blnLoading) { return; } XPathNavigator xmlAccessory = null; string strSelectedId = await lstAccessory.DoThreadSafeFuncAsync(x => x.SelectedValue?.ToString()); // Retrieve the information for the selected Accessory. if (!string.IsNullOrEmpty(strSelectedId)) { xmlAccessory = _xmlBaseChummerNode.SelectSingleNode("accessories/accessory[id = " + strSelectedId.CleanXPath() + ']'); } if (xmlAccessory == null) { await tlpRight.DoThreadSafeAsync(x => x.Visible = false); return; } string strRC = xmlAccessory.SelectSingleNode("rc")?.Value; if (!string.IsNullOrEmpty(strRC)) { await lblRCLabel.DoThreadSafeAsync(x => x.Visible = true); await lblRC.DoThreadSafeAsync(x => { x.Visible = true; x.Text = strRC; }); } else { await lblRC.DoThreadSafeAsync(x => x.Visible = false); await lblRCLabel.DoThreadSafeAsync(x => x.Visible = false); } if (int.TryParse(xmlAccessory.SelectSingleNode("rating")?.Value, out int intMaxRating) && intMaxRating > 0) { await nudRating.DoThreadSafeAsync(x => x.Maximum = intMaxRating); if (await chkHideOverAvailLimit.DoThreadSafeFuncAsync(x => x.Checked)) { await nudRating.DoThreadSafeAsync(x => { while (x.Maximum > x.Minimum && !xmlAccessory.CheckAvailRestriction(_objCharacter, x.MaximumAsInt)) { --x.Maximum; } }); } if (await chkShowOnlyAffordItems.DoThreadSafeFuncAsync(x => x.Checked) && !await chkFreeItem.DoThreadSafeFuncAsync(x => x.Checked)) { decimal decCostMultiplier = 1 + (await nudMarkup.DoThreadSafeFuncAsync(x => x.Value) / 100.0m); if (_setBlackMarketMaps.Contains(xmlAccessory.SelectSingleNode("category")?.Value)) { decCostMultiplier *= 0.9m; } await nudRating.DoThreadSafeAsync(x => { while (x.Maximum > x.Minimum && !xmlAccessory.CheckNuyenRestriction(_objCharacter.Nuyen, decCostMultiplier, x.MaximumAsInt)) { --x.Maximum; } }); } await nudRating.DoThreadSafeAsync(x => { x.Enabled = nudRating.Maximum != nudRating.Minimum; x.Visible = true; }); await lblRatingLabel.DoThreadSafeAsync(x => x.Visible = true); await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = false); } else { await lblRatingNALabel.DoThreadSafeAsync(x => x.Visible = true); await nudRating.DoThreadSafeAsync(x => { x.Enabled = false; x.Visible = false; }); await lblRatingLabel.DoThreadSafeAsync(x => x.Visible = true); } if (blnUpdateMountComboBoxes) { string strDataMounts = xmlAccessory.SelectSingleNode("mount")?.Value; List <string> strMounts = new List <string>(1); if (!string.IsNullOrEmpty(strDataMounts)) { strMounts.AddRange(strDataMounts.SplitNoAlloc('/', StringSplitOptions.RemoveEmptyEntries)); } strMounts.Add("None"); List <string> strAllowed = new List <string>(_lstAllowedMounts) { "None" }; string strSelectedMount = await cboMount.DoThreadSafeFuncAsync(x => { x.Visible = true; x.Items.Clear(); foreach (string strCurrentMount in strMounts) { if (!string.IsNullOrEmpty(strCurrentMount)) { foreach (string strAllowedMount in strAllowed) { if (strCurrentMount == strAllowedMount) { x.Items.Add(strCurrentMount); } } } } x.Enabled = x.Items.Count > 1; x.SelectedIndex = 0; return(x.SelectedItem.ToString()); }); await lblMountLabel.DoThreadSafeAsync(x => x.Visible = true); List <string> strExtraMounts = new List <string>(1); string strExtraMount = xmlAccessory.SelectSingleNode("extramount")?.Value; if (!string.IsNullOrEmpty(strExtraMount)) { foreach (string strItem in strExtraMount.SplitNoAlloc('/', StringSplitOptions.RemoveEmptyEntries)) { strExtraMounts.Add(strItem); } } strExtraMounts.Add("None"); await cboExtraMount.DoThreadSafeFuncAsync(x => { x.Items.Clear(); foreach (string strCurrentMount in strExtraMounts) { if (!string.IsNullOrEmpty(strCurrentMount)) { foreach (string strAllowedMount in strAllowed) { if (strCurrentMount == strAllowedMount) { x.Items.Add(strCurrentMount); } } } } x.Enabled = x.Items.Count > 1; x.SelectedIndex = 0; if (strSelectedMount != "None" && x.SelectedItem.ToString() != "None" && strSelectedMount == x.SelectedItem.ToString()) { ++x.SelectedIndex; } x.Visible = x.Enabled && x.SelectedItem.ToString() != "None"; return(x.Visible); }).ContinueWith(y => lblExtraMountLabel.DoThreadSafeAsync(x => x.Visible = y.Result)).Unwrap(); } int intRating = await nudRating.DoThreadSafeFuncAsync(x => x.ValueAsInt); // Avail. // If avail contains "F" or "R", remove it from the string so we can use the expression. string strAvail = new AvailabilityValue(intRating, xmlAccessory.SelectSingleNode("avail")?.Value) .ToString(); await lblAvail.DoThreadSafeAsync(x => x.Text = strAvail); await lblAvailLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(strAvail)); if (!await chkFreeItem.DoThreadSafeFuncAsync(x => x.Checked)) { string strCost = "0"; if (xmlAccessory.TryGetStringFieldQuickly("cost", ref strCost)) { strCost = (await strCost.CheapReplaceAsync("Weapon Cost", () => _objParentWeapon.OwnCost.ToString(GlobalSettings.InvariantCultureInfo)) .CheapReplaceAsync("Weapon Total Cost", () => _objParentWeapon.MultipliableCost(null) .ToString(GlobalSettings.InvariantCultureInfo))) .Replace("Rating", intRating.ToString(GlobalSettings.CultureInfo)); } if (strCost.StartsWith("Variable(", StringComparison.Ordinal)) { decimal decMin; decimal decMax = decimal.MaxValue; strCost = strCost.TrimStartOnce("Variable(", true).TrimEndOnce(')'); if (strCost.Contains('-')) { string[] strValues = strCost.Split('-'); decimal.TryParse(strValues[0], NumberStyles.Any, GlobalSettings.InvariantCultureInfo, out decMin); decimal.TryParse(strValues[1], NumberStyles.Any, GlobalSettings.InvariantCultureInfo, out decMax); } else { decimal.TryParse(strCost.FastEscape('+'), NumberStyles.Any, GlobalSettings.InvariantCultureInfo, out decMin); } if (decMax == decimal.MaxValue) { await lblCost.DoThreadSafeAsync( x => x.Text = decMin.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + "¥+"); } else { string strSpace = await LanguageManager.GetStringAsync("String_Space"); await lblCost.DoThreadSafeAsync( x => x.Text = decMin.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + strSpace + '-' + strSpace + decMax.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + '¥'); } await lblTest.DoThreadSafeAsync(x => x.Text = _objCharacter.AvailTest(decMax, strAvail)); } else { object objProcess = CommonFunctions.EvaluateInvariantXPath(strCost, out bool blnIsSuccess); decimal decCost = blnIsSuccess ? Convert.ToDecimal(objProcess, GlobalSettings.InvariantCultureInfo) : 0; // Apply any markup. decCost *= 1 + (await nudMarkup.DoThreadSafeFuncAsync(x => x.Value) / 100.0m); if (await chkBlackMarketDiscount.DoThreadSafeFuncAsync(x => x.Checked)) { decCost *= 0.9m; } decCost *= _objParentWeapon.AccessoryMultiplier; if (!string.IsNullOrEmpty(_objParentWeapon.DoubledCostModificationSlots)) { string[] astrParentDoubledCostModificationSlots = _objParentWeapon.DoubledCostModificationSlots.Split('/', StringSplitOptions.RemoveEmptyEntries); if (astrParentDoubledCostModificationSlots.Contains(await cboMount.DoThreadSafeFuncAsync(x => x.SelectedItem?.ToString())) || astrParentDoubledCostModificationSlots.Contains(await cboExtraMount.DoThreadSafeFuncAsync(x => x.SelectedItem?.ToString()))) { decCost *= 2; } } await lblCost.DoThreadSafeAsync(x => x.Text = decCost.ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + '¥'); await lblTest.DoThreadSafeAsync(x => x.Text = _objCharacter.AvailTest(decCost, strAvail)); } } else { await lblCost.DoThreadSafeAsync(x => x.Text = (0.0m).ToString(_objCharacter.Settings.NuyenFormat, GlobalSettings.CultureInfo) + '¥'); await lblTest.DoThreadSafeAsync(x => x.Text = _objCharacter.AvailTest(0, strAvail)); } XPathNavigator xmlAccessoryRatingLabel = xmlAccessory.SelectSingleNode("ratinglabel"); string strRatingLabel = xmlAccessoryRatingLabel != null ? string.Format(GlobalSettings.CultureInfo, await LanguageManager.GetStringAsync("Label_RatingFormat"), await LanguageManager.GetStringAsync(xmlAccessoryRatingLabel.Value)) : await LanguageManager.GetStringAsync("Label_Rating"); await lblRatingLabel.DoThreadSafeAsync(x => x.Text = strRatingLabel); await lblCost.DoThreadSafeFuncAsync(x => x.Text) .ContinueWith(y => lblCostLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(y.Result))) .Unwrap(); await lblTest.DoThreadSafeFuncAsync(x => x.Text) .ContinueWith(y => lblTestLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(y.Result))) .Unwrap(); await chkBlackMarketDiscount.DoThreadSafeAsync(x => { x.Enabled = _blnIsParentWeaponBlackMarketAllowed; if (!x.Checked) { x.Checked = GlobalSettings.AssumeBlackMarket && _blnIsParentWeaponBlackMarketAllowed; } else if (!_blnIsParentWeaponBlackMarketAllowed) { //Prevent chkBlackMarketDiscount from being checked if the gear category doesn't match. x.Checked = false; } }); string strSource = xmlAccessory.SelectSingleNode("source")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); string strPage = (await xmlAccessory.SelectSingleNodeAndCacheExpressionAsync("altpage"))?.Value ?? xmlAccessory.SelectSingleNode("page")?.Value ?? await LanguageManager.GetStringAsync("String_Unknown"); SourceString objSourceString = await SourceString.GetSourceStringAsync(strSource, strPage, GlobalSettings.Language, GlobalSettings.CultureInfo, _objCharacter); await objSourceString.SetControlAsync(lblSource); await lblSourceLabel.DoThreadSafeAsync(x => x.Visible = !string.IsNullOrEmpty(objSourceString.ToString())); await tlpRight.DoThreadSafeAsync(x => x.Visible = true); }