本文整理汇总了C#中Chummer.ImprovementManager.RemoveImprovements方法的典型用法代码示例。如果您正苦于以下问题:C# ImprovementManager.RemoveImprovements方法的具体用法?C# ImprovementManager.RemoveImprovements怎么用?C# ImprovementManager.RemoveImprovements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.ImprovementManager
的用法示例。
在下文中一共展示了ImprovementManager.RemoveImprovements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcceptForm
/// <summary>
/// Accept the values on the Form and create the required XML data.
/// </summary>
private void AcceptForm()
{
// Make sure a value has been selected if necessary.
if (txtSelect.Visible && txtSelect.Text == string.Empty)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectItem"), LanguageManager.Instance.GetString("MessageTitle_SelectItem"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Make sure a value has been provided for the name.
if (txtName.Text == string.Empty)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_ImprovementName"), LanguageManager.Instance.GetString("MessageTitle_ImprovementName"), MessageBoxButtons.OK, MessageBoxIcon.Error);
txtName.Focus();
return;
}
MemoryStream objStream = new MemoryStream();
XmlWriter objWriter = XmlWriter.Create(objStream);
// Build the XML for the Improvement.
XmlNode objFetchNode = _objDocument.SelectSingleNode("/chummer/improvements/improvement[id = \"" + cboImprovemetType.SelectedValue + "\"]");
objWriter.WriteStartDocument();
// <bonus>
objWriter.WriteStartElement("bonus");
// <whatever element>
objWriter.WriteStartElement(objFetchNode["internal"].InnerText);
string strRating = "";
if (chkApplyToRating.Checked)
strRating = "<applytorating>yes</applytorating>";
// Retrieve the XML data from the document and replace the values as necessary.
string strXml = objFetchNode["xml"].InnerText;
strXml = strXml.Replace("{val}", nudVal.Value.ToString());
strXml = strXml.Replace("{min}", nudMin.Value.ToString());
strXml = strXml.Replace("{max}", nudMax.Value.ToString());
strXml = strXml.Replace("{aug}", nudAug.Value.ToString());
strXml = strXml.Replace("{select}", txtSelect.Text);
strXml = strXml.Replace("{applytorating}", strRating);
objWriter.WriteRaw(strXml);
// Write the rest of the document.
// </whatever element>
objWriter.WriteEndElement();
// </bonus>
objWriter.WriteEndElement();
objWriter.WriteEndDocument();
objWriter.Flush();
objStream.Flush();
objStream.Position = 0;
// Read it back in as an XmlDocument.
StreamReader objReader = new StreamReader(objStream);
XmlDocument objBonusXML = new XmlDocument();
string strXML = objReader.ReadToEnd();
objBonusXML.LoadXml(strXML);
objWriter.Close();
objStream.Close();
// Pluck out the bonus information.
XmlNode objNode = objBonusXML.SelectSingleNode("/bonus");
// Pass it to the Improvement Manager so that it can be added to the character.
ImprovementManager objImprovementManager = new ImprovementManager(_objCharacter);
string strGuid = Guid.NewGuid().ToString();
objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Custom, strGuid, objNode, false, 1, txtName.Text);
// If an Improvement was passed in, remove it from the character.
string strNotes = "";
int intOrder = 0;
if (_objEditImprovement != null)
{
// Copy the notes over to the new item.
strNotes = _objEditImprovement.Notes;
intOrder = _objEditImprovement.SortOrder;
objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Custom, _objEditImprovement.SourceName);
}
// Find the newly-created Improvement and attach its custom name.
foreach (Improvement objImprovement in _objCharacter.Improvements)
{
if (objImprovement.SourceName == strGuid)
{
objImprovement.CustomName = txtName.Text;
objImprovement.CustomId = cboImprovemetType.SelectedValue.ToString();
objImprovement.Custom = true;
objImprovement.Notes = strNotes;
objImprovement.SortOrder = intOrder;
}
}
this.DialogResult = DialogResult.OK;
}
示例2: DeleteGear
/// <summary>
/// Recursive method to delete a piece of Gear and its Improvements from the character.
/// </summary>
/// <param name="objGear">Gear to delete.</param>
/// <param name="treWeapons">TreeView that holds the list of Weapons.</param>
/// <param name="objImprovementManager">Improvement Manager the character is using.</param>
public void DeleteGear(Gear objGear, TreeView treWeapons, ImprovementManager objImprovementManager)
{
// Remove any children the Gear may have.
foreach (Gear objChild in objGear.Children)
DeleteGear(objChild, treWeapons, objImprovementManager);
// Remove the Gear Weapon created by the Gear if applicable.
if (objGear.WeaponID != Guid.Empty.ToString())
{
// Remove the Weapon from the TreeView.
TreeNode objRemoveNode = new TreeNode();
foreach (TreeNode objWeaponNode in treWeapons.Nodes[0].Nodes)
{
if (objWeaponNode.Tag.ToString() == objGear.WeaponID)
objRemoveNode = objWeaponNode;
}
treWeapons.Nodes.Remove(objRemoveNode);
// Remove the Weapon from the Character.
Weapon objRemoveWeapon = new Weapon(_objCharacter);
foreach (Weapon objWeapon in _objCharacter.Weapons)
{
if (objWeapon.InternalId == objGear.WeaponID)
objRemoveWeapon = objWeapon;
}
_objCharacter.Weapons.Remove(objRemoveWeapon);
}
objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
// If a Focus is being removed, make sure the actual Focus is being removed from the character as well.
if (objGear.Category == "Foci" || objGear.Category == "Metamagic Foci")
{
List<Focus> lstRemoveFoci = new List<Focus>();
foreach (Focus objFocus in _objCharacter.Foci)
{
if (objFocus.GearId == objGear.InternalId)
lstRemoveFoci.Add(objFocus);
}
foreach (Focus objFocus in lstRemoveFoci)
_objCharacter.Foci.Remove(objFocus);
}
// If a Stacked Focus is being removed, make sure the Stacked Foci and its bonuses are being removed.
if (objGear.Category == "Stacked Focus")
{
foreach (StackedFocus objStack in _objCharacter.StackedFoci)
{
if (objStack.GearId == objGear.InternalId)
{
objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId);
_objCharacter.StackedFoci.Remove(objStack);
break;
}
}
}
}
示例3: UpdateArmorRating
/// <summary>
/// Update the label and tooltip for the character's Armor Rating.
/// </summary>
/// <param name="lblArmor"></param>
/// <param name="tipTooltip"></param>
protected void UpdateArmorRating(Label lblArmor, ToolTip tipTooltip, ImprovementManager _objImprovementManager)
{
// Armor Ratings.
lblArmor.Text = _objCharacter.TotalArmorRating.ToString();
string strArmorToolTip = "";
strArmorToolTip = LanguageManager.Instance.GetString("Tip_Armor") + " (" + _objCharacter.ArmorRating.ToString() + ")";
if (_objCharacter.ArmorRating != _objCharacter.TotalArmorRating)
strArmorToolTip += " + " + LanguageManager.Instance.GetString("Tip_Modifiers") + " (" +
(_objCharacter.TotalArmorRating - _objCharacter.ArmorRating).ToString() + ")";
tipTooltip.SetToolTip(lblArmor, strArmorToolTip);
// Remove any Improvements from Armor Encumbrance.
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance");
// Create the Armor Encumbrance Improvements.
if (_objCharacter.ArmorEncumbrance < 0)
{
_objImprovementManager.CreateImprovement("AGI", Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance", Improvement.ImprovementType.Attribute, "", 0, 1, 0, 0, _objCharacter.ArmorEncumbrance);
_objImprovementManager.CreateImprovement("REA", Improvement.ImprovementSource.ArmorEncumbrance, "Armor Encumbrance", Improvement.ImprovementType.Attribute, "", 0, 1, 0, 0, _objCharacter.ArmorEncumbrance);
}
}