本文整理汇总了C#中System.OperatingSystem.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# OperatingSystem.Copy方法的具体用法?C# OperatingSystem.Copy怎么用?C# OperatingSystem.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.OperatingSystem
的用法示例。
在下文中一共展示了OperatingSystem.Copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 if (objSelectedGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOS = new OperatingSystem(_objCharacter);
objOS.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear = objOS;
}
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();
}
示例2: cmdVehicleMoveToInventory_Click
//.........这里部分代码省略.........
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;
}
}
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 if (objSelectedGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOS = new OperatingSystem(_objCharacter);
objOS.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear = objOS;
}
else
objGear.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear.Parent = null;
objGear.Quantity = intMove;
objGearNode.Text = objGear.DisplayName;
objGearNode.ContextMenuStrip = cmsGear;
treGear.Nodes[0].Nodes.Add(objGearNode);
_objCharacter.Gear.Add(objGear);
// Create any Weapons that came with this Gear.
foreach (Weapon objGearWeapon in lstWeapons)
_objCharacter.Weapons.Add(objGearWeapon);
foreach (TreeNode objWeaponNode in lstWeaponNodes)
{
objWeaponNode.ContextMenuStrip = cmsWeapon;
treWeapons.Nodes[0].Nodes.Add(objWeaponNode);
treWeapons.Nodes[0].Expand();
}
AddGearImprovements(objGear);
UpdateCharacterInfo();
}
else
{
// Everything matches up, so just increase the quantity.
objFoundGear.Quantity += intMove;
foreach (TreeNode nodGear in treGear.Nodes[0].Nodes)
{
if (nodGear.Tag.ToString() == objFoundGear.InternalId)
nodGear.Text = objFoundGear.DisplayName;
}
}
// Update the selected item.
objSelectedGear.Quantity -= intMove;
if (objSelectedGear.Quantity == 0)
{
// The quantity has reached 0, so remove it entirely.
treVehicles.SelectedNode.Remove();
foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
objCharacterVehicle.Gear.Remove(objSelectedGear);
}
else
treVehicles.SelectedNode.Text = objSelectedGear.DisplayName;
}
_blnIsDirty = true;
UpdateWindowTitle();
}
示例3: 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 if (objSelectedGear.GetType() == typeof(OperatingSystem))
{
OperatingSystem objOS = new OperatingSystem(_objCharacter);
objOS.Copy(objSelectedGear, objGearNode, lstWeapons, lstWeaponNodes);
objGear = objOS;
}
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;
}
//.........这里部分代码省略.........