当前位置: 首页>>代码示例>>C#>>正文


C# OperatingSystem.Copy方法代码示例

本文整理汇总了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();
        }
开发者ID:Nebual,项目名称:chummer,代码行数:82,代码来源:frmCareer.cs

示例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();
        }
开发者ID:Nebual,项目名称:chummer,代码行数:101,代码来源:frmCareer.cs

示例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;
                    }
//.........这里部分代码省略.........
开发者ID:Nebual,项目名称:chummer,代码行数:101,代码来源:frmCareer.cs


注:本文中的System.OperatingSystem.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。