本文整理汇总了C#中Chummer.frmSelectNumber.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# frmSelectNumber.ShowDialog方法的具体用法?C# frmSelectNumber.ShowDialog怎么用?C# frmSelectNumber.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chummer.frmSelectNumber
的用法示例。
在下文中一共展示了frmSelectNumber.ShowDialog方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tsWeaponAddAccessory_Click
private void tsWeaponAddAccessory_Click(object sender, EventArgs e)
{
// Make sure a parent item is selected, then open the Select Accessory window.
try
{
if (treWeapons.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Locate the Weapon that is selected in the Tree.
Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
// Accessories cannot be added to Cyberweapons.
if (objWeapon.Cyberware)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberweaponNoAccessory"), LanguageManager.Instance.GetString("MessageTitle_CyberweaponNoAccessory"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objWeapon.Name + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotFindWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
bool blnAllowAccessories = false;
if (objXmlWeapon["allowaccessory"] != null)
{
blnAllowAccessories = Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText);
}
if (!blnAllowAccessories)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
{
bool blnFound = false;
foreach (WeaponAccessory objMod in objWeapon.WeaponAccessories)
{
if (objMod.Mount == objXmlMount.InnerText)
{
blnFound = true;
}
}
if (!blnFound)
{
strMounts += objXmlMount.InnerText + "/";
}
}
// Remove the trailing /
if (strMounts != "" && strMounts.Contains('/'))
strMounts = strMounts.Substring(0, strMounts.Length - 1);
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount,Convert.ToInt32(frmPickWeaponAccessory.SelectedRating));
objAccessory.Parent = objWeapon;
if (objAccessory.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objAccessory.Cost.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
//.........这里部分代码省略.........
示例2: Create
/// <summary>
/// Create a Quality from an XmlNode and return the TreeNodes for it.
/// </summary>
/// <param name="objXmlQuality">XmlNode to create the object from.</param>
/// <param name="objCharacter">Character object the Quality will be added to.</param>
/// <param name="objQualitySource">Source of the Quality.</param>
/// <param name="objNode">TreeNode to populate a TreeView.</param>
/// <param name="objWeapons">List of Weapons that should be added to the Character.</param>
/// <param name="objWeaponNodes">List of TreeNodes to represent the Weapons added.</param>
/// <param name="strForceValue">Force a value to be selected for the Quality.</param>
public virtual void Create(XmlNode objXmlQuality, Character objCharacter, QualitySource objQualitySource, TreeNode objNode, List<Weapon> objWeapons, List<TreeNode> objWeaponNodes, string strForceValue = "")
{
_strName = objXmlQuality["name"].InnerText;
if (objXmlQuality["metagenetic"] != null)
{
_strMetagenetic = objXmlQuality["metagenetic"].InnerText;
}
// Check for a Variable Cost.
if (objXmlQuality["karma"].InnerText.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objXmlQuality["karma"].InnerText.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
string[] strValues = strCost.Split('-');
intMin = Convert.ToInt32(strValues[0]);
intMax = Convert.ToInt32(strValues[1]);
}
else
intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));
if (intMin != 0 || intMax != 0)
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
if (intMax == 0)
intMax = 1000000;
frmPickNumber.Minimum = intMin;
frmPickNumber.Maximum = intMax;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", DisplayNameShort);
frmPickNumber.AllowCancel = false;
frmPickNumber.ShowDialog();
_intBP = frmPickNumber.SelectedValue;
}
}
else
{
_intBP = Convert.ToInt32(objXmlQuality["karma"].InnerText);
}
if (objXmlQuality["lp"] != null)
{
_intLP = Convert.ToInt32(objXmlQuality["lp"].InnerText);
}
_objQualityType = ConvertToQualityType(objXmlQuality["category"].InnerText);
_objQualitySource = objQualitySource;
if (objXmlQuality["print"] != null)
{
if (objXmlQuality["print"].InnerText == "no")
_blnPrint = false;
}
if (objXmlQuality["implemented"] != null)
{
if (objXmlQuality["implemented"].InnerText == "False")
_blnImplemented = false;
}
if (objXmlQuality["contributetolimit"] != null)
{
if (objXmlQuality["contributetolimit"].InnerText == "no")
_blnContributeToLimit = false;
}
_strSource = objXmlQuality["source"].InnerText;
_strPage = objXmlQuality["page"].InnerText;
if (objXmlQuality["mutant"] != null)
_strMutant = "yes";
if (_objQualityType == QualityType.LifeModule)
{
objXmlQuality.TryGetField("stage", out _stage);
}
if(objXmlQuality["id"] != null)
_qualiyGuid = Guid.Parse(objXmlQuality["id"].InnerText);
if (GlobalOptions.Instance.Language != "en-us")
{
XmlDocument objXmlDocument = XmlManager.Instance.Load("qualities.xml");
XmlNode objQualityNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[name = \"" + _strName + "\"]");
if (objQualityNode != null)
{
if (objQualityNode["translate"] != null)
_strAltName = objQualityNode["translate"].InnerText;
if (objQualityNode["altpage"] != null)
_strAltPage = objQualityNode["altpage"].InnerText;
}
}
// Add Weapons if applicable.
if (objXmlQuality.InnerXml.Contains("<addweapon>"))
{
XmlDocument objXmlWeaponDocument = XmlManager.Instance.Load("weapons.xml");
//.........这里部分代码省略.........
示例3: cmdDeleteVehicle_Click
private void cmdDeleteVehicle_Click(object sender, EventArgs e)
{
// Delete the selected Vehicle.
try
{
if (treVehicles.SelectedNode.Level == 0)
return;
}
catch
{
return;
}
if (treVehicles.SelectedNode.Level != 2)
{
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
}
if (treVehicles.SelectedNode.Level == 1)
{
// Locate the Vehicle that is selected in the tree.
Vehicle objVehicle = _objFunctions.FindVehicle(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles);
// Remove any Gear Improvements from the character (primarily those provided by an Emotitoy).
foreach (Gear objGear in objVehicle.Gear)
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
_objCharacter.Vehicles.Remove(objVehicle);
treVehicles.SelectedNode.Remove();
}
else if (treVehicles.SelectedNode.Level == 2)
{
bool blnFound = false;
// Locate the VehicleMod that is selected in the tree.
Vehicle objFoundVehicle = new Vehicle(_objCharacter);
VehicleMod objMod = _objFunctions.FindVehicleMod(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objFoundVehicle);
if (objMod != null)
{
blnFound = true;
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
// Check for Improved Sensor bonus.
if (objMod.Bonus != null)
{
if (objMod.Bonus["improvesensor"] != null)
{
ChangeVehicleSensor(objFoundVehicle, false);
}
}
// If this is the Obsolete Mod, the user must select a percentage. This will create an Expense that costs X% of the Vehicle's base cost to remove the special Obsolete Mod.
if (objMod.Name == "Obsolete" || (objMod.Name == "Obsolescent" && _objOptions.AllowObsolescentUpgrade))
{
frmSelectNumber frmModPercent = new frmSelectNumber();
frmModPercent.Minimum = 0;
frmModPercent.Maximum = 1000;
frmModPercent.Description = LanguageManager.Instance.GetString("String_Retrofit");
frmModPercent.ShowDialog(this);
if (frmModPercent.DialogResult == DialogResult.Cancel)
return;
int intPercentage = frmModPercent.SelectedValue;
int intVehicleCost = Convert.ToInt32(objFoundVehicle.Cost);
// Make sure the character has enough Nuyen for the expense.
int intCost = Convert.ToInt32(Convert.ToDouble(intVehicleCost, GlobalOptions.Instance.CultureInfo) * (Convert.ToDouble(intPercentage, GlobalOptions.Instance.CultureInfo) / 100.0), GlobalOptions.Instance.CultureInfo);
VehicleMod objRetrofit = new VehicleMod(_objCharacter);
XmlDocument objVehiclesDoc = XmlManager.Instance.Load("vehicles.xml");
XmlNode objXmlNode = objVehiclesDoc.SelectSingleNode("/chummer/mods/mod[name = \"Retrofit\"]");
TreeNode objTreeNode = new TreeNode();
objRetrofit.Create(objXmlNode, objTreeNode, 0);
objRetrofit.Cost = intCost.ToString();
objFoundVehicle.Mods.Add(objRetrofit);
treVehicles.SelectedNode.Parent.Nodes.Add(objTreeNode);
}
objFoundVehicle.Mods.Remove(objMod);
treVehicles.SelectedNode.Remove();
}
if (!blnFound)
{
// Locate the Sensor or Ammunition that is selected in the tree.
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (Gear objGear in objCharacterVehicle.Gear)
{
if (objGear.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
if (!_objFunctions.ConfirmDelete(LanguageManager.Instance.GetString("Message_DeleteVehicle")))
return;
// Remove the Gear Weapon created by the Gear if applicable.
if (objGear.WeaponID != Guid.Empty.ToString())
{
//.........这里部分代码省略.........
示例4: cmdQuickenSpell_Click
private void cmdQuickenSpell_Click(object sender, EventArgs e)
{
try
{
if (treSpells.SelectedNode.Level != 1)
return;
}
catch
{
return;
}
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Description = LanguageManager.Instance.GetString("String_QuickeningKarma").Replace("{0}", treSpells.SelectedNode.Text);
frmPickNumber.Minimum = 1;
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
// Make sure the character has enough Karma to improve the Attribute.
int intKarmaCost = frmPickNumber.SelectedValue;
if (intKarmaCost > _objCharacter.Karma)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_NotEnoughKarma"), LanguageManager.Instance.GetString("MessageTitle_NotEnoughKarma"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!ConfirmKarmaExpense(LanguageManager.Instance.GetString("Message_ConfirmKarmaExpenseQuickeningMetamagic").Replace("{0}", intKarmaCost.ToString()).Replace("{1}", treSpells.SelectedNode.Text)))
return;
// Create the Karma expense.
ExpenseLogEntry objExpense = new ExpenseLogEntry();
objExpense.Create(intKarmaCost * -1, LanguageManager.Instance.GetString("String_ExpenseQuickenMetamagic") + " " + treSpells.SelectedNode.Text, ExpenseType.Karma, DateTime.Now);
_objCharacter.ExpenseEntries.Add(objExpense);
_objCharacter.Karma -= intKarmaCost;
ExpenseUndo objUndo = new ExpenseUndo();
objUndo.CreateKarma(KarmaExpenseType.QuickeningMetamagic, "");
objExpense.Undo = objUndo;
UpdateCharacterInfo();
_blnIsDirty = true;
UpdateWindowTitle();
}
示例5: cmdVehicleMoveToInventory_Click
private void cmdVehicleMoveToInventory_Click(object sender, EventArgs e)
{
// Locate the selected Weapon.
bool blnFound = false;
Weapon objWeapon = new Weapon(_objCharacter);
Vehicle objVehicle = new Vehicle(_objCharacter);
VehicleMod objMod = new VehicleMod(_objCharacter);
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
foreach (Weapon objVehicleWeapon in objCharacterVehicle.Weapons)
{
if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objWeapon = objVehicleWeapon;
objVehicle = objCharacterVehicle;
blnFound = true;
break;
}
}
foreach (VehicleMod objVehicleMod in objCharacterVehicle.Mods)
{
foreach (Weapon objVehicleWeapon in objVehicleMod.Weapons)
{
if (objVehicleWeapon.InternalId == treVehicles.SelectedNode.Tag.ToString())
{
objWeapon = objVehicleWeapon;
objVehicle = objCharacterVehicle;
objMod = objVehicleMod;
blnFound = true;
break;
}
}
}
}
if (blnFound){
// Move the Weapons from the Vehicle Mod (or Vehicle) to the character.
if (objMod.InternalId != Guid.Empty.ToString())
objMod.Weapons.Remove(objWeapon);
else
objVehicle.Weapons.Remove(objWeapon);
_objCharacter.Weapons.Add(objWeapon);
TreeNode objNode = new TreeNode();
objNode = treVehicles.SelectedNode;
treVehicles.SelectedNode.Remove();
treWeapons.Nodes[0].Nodes.Add(objNode);
objWeapon.VehicleMounted = false;
objNode.Expand();
}
else
{
// Locate the selected Gear.
Vehicle objSelectedVehicle = new Vehicle(_objCharacter);
Gear objSelectedGear = _objFunctions.FindVehicleGear(treVehicles.SelectedNode.Tag.ToString(), _objCharacter.Vehicles, out objSelectedVehicle);
int intMove = 0;
if (objSelectedGear.Quantity == 1)
intMove = 1;
else
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Minimum = 1;
frmPickNumber.Maximum = objSelectedGear.Quantity;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
intMove = frmPickNumber.SelectedValue;
}
// See if the character already has a matching piece of Gear.
bool blnMatch = false;
Gear objFoundGear = new Gear(_objCharacter);
foreach (Gear objCharacterGear in _objCharacter.Gear)
{
if (objCharacterGear.Name == objSelectedGear.Name && objCharacterGear.Category == objSelectedGear.Category && objCharacterGear.Rating == objSelectedGear.Rating && objCharacterGear.Extra == objSelectedGear.Extra && objCharacterGear.GearName == objSelectedGear.GearName && objCharacterGear.Notes == objSelectedGear.Notes)
{
blnMatch = true;
objFoundGear = objCharacterGear;
if (objCharacterGear.Children.Count == objSelectedGear.Children.Count)
{
for (int i = 0; i <= objCharacterGear.Children.Count - 1; i++)
{
if (objCharacterGear.Children[i].Name != objSelectedGear.Children[i].Name || objCharacterGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objCharacterGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
{
blnMatch = false;
break;
}
}
}
else
blnMatch = false;
}
}
//.........这里部分代码省略.........
示例6: cmdGearSplitQty_Click
private void cmdGearSplitQty_Click(object sender, EventArgs e)
{
// This can only be done with the first level of Nodes.
try
{
if (treGear.SelectedNode.Level != 1)
return;
}
catch
{
return;
}
Gear objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
// Cannot split a stack of 1 item.
if (objSelectedGear.Quantity == 1)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotSplitGear"), LanguageManager.Instance.GetString("MessageTitle_CannotSplitGear"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Minimum = 1;
frmPickNumber.Maximum = objSelectedGear.Quantity - 1;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_SplitGear");
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
// Create a new piece of Gear.
XmlDocument objXmlDocument = XmlManager.Instance.Load("gear.xml");
XmlNode objNode = objXmlDocument.SelectSingleNode("/chummer/gears/gear[name = \"" + objSelectedGear.Name + "\" and category = \"" + objSelectedGear.Category + "\"]");
TreeNode objGearNode = new TreeNode();
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstWeaponNodes = new List<TreeNode>();
Gear objGear = new Gear(_objCharacter);
if (objSelectedGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear = objCommlink;
}
else
objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear.Quantity = frmPickNumber.SelectedValue;
objGear.Equipped = objSelectedGear.Equipped;
objGear.Location = objSelectedGear.Location;
objGear.Notes = objSelectedGear.Notes;
objGearNode.Text = objGear.DisplayName;
objGearNode.ContextMenuStrip = treGear.SelectedNode.ContextMenuStrip;
// Update the selected item.
objSelectedGear.Quantity -= frmPickNumber.SelectedValue;
treGear.SelectedNode.Text = objSelectedGear.DisplayName;
treGear.SelectedNode.Parent.Nodes.Add(objGearNode);
_objCharacter.Gear.Add(objGear);
// Create any Weapons that came with this Gear.
foreach (Weapon objWeapon in lstWeapons)
_objCharacter.Weapons.Add(objWeapon);
foreach (TreeNode objWeaponNode in lstWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
_blnIsDirty = true;
UpdateWindowTitle();
}
示例7: cmdGearMoveToVehicle_Click
private void cmdGearMoveToVehicle_Click(object sender, EventArgs e)
{
frmSelectItem frmPickItem = new frmSelectItem();
frmPickItem.Vehicles = _objCharacter.Vehicles;
frmPickItem.ShowDialog(this);
if (frmPickItem.DialogResult == DialogResult.Cancel)
return;
// Locate the selected Vehicle.
Vehicle objVehicle = new Vehicle(_objCharacter);
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
{
if (objCharacterVehicle.InternalId == frmPickItem.SelectedItem)
{
objVehicle = objCharacterVehicle;
break;
}
}
Gear objSelectedGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
int intMove = 0;
if (objSelectedGear.Quantity == 1)
intMove = 1;
else
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Minimum = 1;
frmPickNumber.Maximum = objSelectedGear.Quantity;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_MoveGear");
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
intMove = frmPickNumber.SelectedValue;
}
// See if the Vehicle already has a matching piece of Gear.
bool blnMatch = false;
Gear objFoundGear = new Gear(_objCharacter);
foreach (Gear objVehicleGear in objVehicle.Gear)
{
if (objVehicleGear.Name == objSelectedGear.Name && objVehicleGear.Category == objSelectedGear.Category && objVehicleGear.Rating == objSelectedGear.Rating && objVehicleGear.Extra == objSelectedGear.Extra && objVehicleGear.GearName == objSelectedGear.GearName && objVehicleGear.Notes == objSelectedGear.Notes)
{
blnMatch = true;
objFoundGear = objVehicleGear;
if (objVehicleGear.Children.Count == objSelectedGear.Children.Count)
{
for (int i = 0; i <= objVehicleGear.Children.Count - 1; i++)
{
if (objVehicleGear.Children[i].Name != objSelectedGear.Children[i].Name || objVehicleGear.Children[i].Extra != objSelectedGear.Children[i].Extra || objVehicleGear.Children[i].Rating != objSelectedGear.Children[i].Rating)
{
blnMatch = false;
break;
}
}
}
else
blnMatch = false;
}
}
if (!blnMatch)
{
// Create a new piece of Gear.
TreeNode objGearNode = new TreeNode();
List<Weapon> lstWeapons = new List<Weapon>();
List<TreeNode> lstWeaponNodes = new List<TreeNode>();
Gear objGear = new Gear(_objCharacter);
if (objSelectedGear.GetType() == typeof(Commlink))
{
Commlink objCommlink = new Commlink(_objCharacter);
objCommlink.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear = objCommlink;
}
else
objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear.Parent = null;
objGear.Quantity = intMove;
objGear.Location = string.Empty;
objGearNode.Text = objGear.DisplayName;
objGearNode.ContextMenuStrip = cmsVehicleGear;
// Locate the Node for the selected Vehicle.
TreeNode nodParent = new TreeNode();
foreach (TreeNode nodNode in treVehicles.Nodes[0].Nodes)
{
if (nodNode.Tag.ToString() == objVehicle.InternalId)
{
nodParent = nodNode;
break;
}
}
nodParent.Nodes.Add(objGearNode);
objVehicle.Gear.Add(objGear);
}
else
//.........这里部分代码省略.........
示例8: cmdGearMergeQty_Click
private void cmdGearMergeQty_Click(object sender, EventArgs e)
{
Gear objGear = _objFunctions.FindGear(treGear.SelectedNode.Tag.ToString(), _objCharacter.Gear);
List<Gear> lstGear = new List<Gear>();
foreach (Gear objCharacterGear in _objCharacter.Gear)
{
bool blnMatch = false;
// Matches must happen on Name, Category, Rating, and Extra, plus all plugins.
if (objCharacterGear.Name == objGear.Name && objCharacterGear.Category == objGear.Category && objCharacterGear.Rating == objGear.Rating && objCharacterGear.Extra == objGear.Extra && objCharacterGear.InternalId != objGear.InternalId)
{
blnMatch = true;
if (objCharacterGear.Children.Count == objGear.Children.Count)
{
for (int i = 0; i <= objCharacterGear.Children.Count - 1; i++)
{
if (objCharacterGear.Children[i].Name != objGear.Children[i].Name || objCharacterGear.Children[i].Extra != objGear.Children[i].Extra || objCharacterGear.Children[i].Rating != objGear.Children[i].Rating)
{
blnMatch = false;
break;
}
}
}
else
blnMatch = false;
}
if (blnMatch)
lstGear.Add(objCharacterGear);
}
// If there were no matches, don't try to merge anything.
if (lstGear.Count == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotMergeGear"), LanguageManager.Instance.GetString("MessageTitle_CannotMergeGear"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Show the Select Item window.
frmSelectItem frmPickItem = new frmSelectItem();
frmPickItem.Gear = lstGear;
frmPickItem.ShowDialog(this);
if (frmPickItem.DialogResult == DialogResult.Cancel)
return;
Gear objSelectedGear = _objFunctions.FindGear(frmPickItem.SelectedItem, _objCharacter.Gear);
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Minimum = 1;
frmPickNumber.Maximum = objGear.Quantity;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_MergeGear");
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
// Increase the quantity for the selected item.
objSelectedGear.Quantity += frmPickNumber.SelectedValue;
// Located the item in the Tree and update its display information.
foreach (TreeNode objParent in treGear.Nodes)
{
foreach (TreeNode objNode in objParent.Nodes)
{
if (objNode.Tag.ToString() == objSelectedGear.InternalId)
{
objNode.Text = objSelectedGear.DisplayName;
break;
}
}
}
// Reduce the quantity for the selected item.
objGear.Quantity -= frmPickNumber.SelectedValue;
// If the quantity has reached 0, delete the item and any Weapons it created.
if (objGear.Quantity == 0)
{
// 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);
//.........这里部分代码省略.........
示例9: tsWeaponAddAccessory_Click
private void tsWeaponAddAccessory_Click(object sender, EventArgs e)
{
// Make sure a parent item is selected, then open the Select Accessory window.
try
{
if (treWeapons.SelectedNode.Level == 0)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_SelectWeaponAccessory"), LanguageManager.Instance.GetString("MessageTitle_SelectWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Locate the Weapon that is selected in the Tree.
Weapon objWeapon = _objFunctions.FindWeapon(treWeapons.SelectedNode.Tag.ToString(), _objCharacter.Weapons);
// Accessories cannot be added to Cyberweapons.
if (objWeapon.Cyberware)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CyberweaponNoAccessory"), LanguageManager.Instance.GetString("MessageTitle_CyberweaponNoAccessory"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Open the Weapons XML file and locate the selected Weapon.
XmlDocument objXmlDocument = XmlManager.Instance.Load("weapons.xml");
XmlNode objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/weapons/weapon[name = \"" + objWeapon.Name + "\"]");
frmSelectWeaponAccessory frmPickWeaponAccessory = new frmSelectWeaponAccessory(_objCharacter, true);
if (objXmlWeapon == null)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the Weapon allows Accessories to be added to it.
if (!Convert.ToBoolean(objXmlWeapon["allowaccessory"].InnerText))
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotModifyWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotModifyWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
XmlNodeList objXmlMountList = objXmlWeapon.SelectNodes("accessorymounts/mount");
string strMounts = "";
foreach (XmlNode objXmlMount in objXmlMountList)
strMounts += objXmlMount.InnerText + "/";
frmPickWeaponAccessory.AllowedMounts = strMounts;
}
frmPickWeaponAccessory.WeaponCost = objWeapon.Cost;
frmPickWeaponAccessory.AccessoryMultiplier = objWeapon.AccessoryMultiplier;
frmPickWeaponAccessory.ShowDialog();
if (frmPickWeaponAccessory.DialogResult == DialogResult.Cancel)
return;
// Locate the selected piece.
objXmlWeapon = objXmlDocument.SelectSingleNode("/chummer/accessories/accessory[name = \"" + frmPickWeaponAccessory.SelectedAccessory + "\"]");
TreeNode objNode = new TreeNode();
WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
objAccessory.Create(objXmlWeapon, objNode, frmPickWeaponAccessory.SelectedMount);
objAccessory.Parent = objWeapon;
if (objAccessory.Cost.StartsWith("Variable"))
{
int intMin = 0;
int intMax = 0;
string strCost = objAccessory.Cost.Replace("Variable(", string.Empty).Replace(")", string.Empty);
if (strCost.Contains("-"))
{
string[] strValues = strCost.Split('-');
intMin = Convert.ToInt32(strValues[0]);
intMax = Convert.ToInt32(strValues[1]);
}
else
intMin = Convert.ToInt32(strCost.Replace("+", string.Empty));
if (intMin != 0 || intMax != 0)
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
if (intMax == 0)
intMax = 1000000;
frmPickNumber.Minimum = intMin;
frmPickNumber.Maximum = intMax;
frmPickNumber.Description = LanguageManager.Instance.GetString("String_SelectVariableCost").Replace("{0}", objAccessory.DisplayNameShort);
frmPickNumber.AllowCancel = false;
frmPickNumber.ShowDialog();
objAccessory.Cost = frmPickNumber.SelectedValue.ToString();
}
}
// Check the item's Cost and make sure the character can afford it.
//.........这里部分代码省略.........
示例10: mnuSpecialCloningMachine_Click
private void mnuSpecialCloningMachine_Click(object sender, EventArgs e)
{
frmSelectNumber frmPickNumber = new frmSelectNumber();
frmPickNumber.Description = LanguageManager.Instance.GetString("String_CloningMachineNumber");
frmPickNumber.Minimum = 1;
frmPickNumber.ShowDialog(this);
if (frmPickNumber.DialogResult == DialogResult.Cancel)
return;
int intClones = 0;
try
{
intClones = Convert.ToInt32(frmPickNumber.SelectedValue);
}
catch
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CloningMachineNumberRequired"), LanguageManager.Instance.GetString("MessageTitle_CloningMachineNumberRequired"), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
for (int i = 1; i <= intClones; i++)
GlobalOptions.Instance.MainForm.LoadCharacter(_objCharacter.FileName, false, _objCharacter.Alias + " " + i.ToString(), true);
}