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


C# Chummer.frmSellItem类代码示例

本文整理汇总了C#中Chummer.frmSellItem的典型用法代码示例。如果您正苦于以下问题:C# frmSellItem类的具体用法?C# frmSellItem怎么用?C# frmSellItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


frmSellItem类属于Chummer命名空间,在下文中一共展示了frmSellItem类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: tsWeaponSell_Click

        private void tsWeaponSell_Click(object sender, EventArgs e)
        {
            // Delete the selected Weapon.
            try
            {
                if (treWeapons.SelectedNode.Level == 1)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    // Locate the Weapon that is selected in the tree.
                    foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                    {
                        if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objWeapon = objCharacterWeapon;
                            break;
                        }
                    }

                    // Cyberweapons cannot be removed through here and must be done by removing the piece of Cyberware.
                    if (objWeapon.Cyberware)
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveCyberweapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveCyberweapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (objWeapon.Category == "Gear")
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveGearWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveGearWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (objWeapon.Category.StartsWith("Quality"))
                    {
                        MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveQualityWeapon"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveQualityWeapon"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

                    if (frmSell.DialogResult == DialogResult.Cancel)
                        return;

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeapon") + " " + objWeapon.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objCharacter.Weapons.Remove(objWeapon);
                    treWeapons.SelectedNode.Remove();
                }
                else if (treWeapons.SelectedNode.Level > 1)
                {
                    Weapon objWeapon = new Weapon(_objCharacter);
                    // Locate the Weapon that is selected in the tree.
                    foreach (Weapon objCharacterWeapon in _objCharacter.Weapons)
                    {
                        if (objCharacterWeapon.InternalId == treWeapons.SelectedNode.Parent.Tag.ToString())
                        {
                            objWeapon = objCharacterWeapon;
                            break;
                        }
                    }

                    WeaponAccessory objAccessory = new WeaponAccessory(_objCharacter);
                    // Locate the Accessory that is selected in the tree.
                    foreach (WeaponAccessory objCharacterAccessory in objWeapon.WeaponAccessories)
                    {
                        if (objCharacterAccessory.InternalId == treWeapons.SelectedNode.Tag.ToString())
                        {
                            objAccessory = objCharacterAccessory;
                            break;
                        }
                    }

                    if (objAccessory.Name != "")
                    {
                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

                        if (frmSell.DialogResult == DialogResult.Cancel)
                            return;

                        // Record the Weapon's original cost.
                        int intOriginal = objWeapon.TotalCost;

                        objWeapon.WeaponAccessories.Remove(objAccessory);
                        treWeapons.SelectedNode.Remove();

                        int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objWeapon.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldWeaponAccessory") + " " + objAccessory.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;
                    }

                    WeaponMod objMod = new WeaponMod(_objCharacter);
                    // Locate the Mod that is selected in the tree.
                    foreach (WeaponMod objCharacterMod in objWeapon.WeaponMods)
                    {
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例2: tsVehicleSell_Click

        private void tsVehicleSell_Click(object sender, EventArgs e)
        {
            // Delete the selected Vehicle.
            try
            {
                if (treVehicles.SelectedNode.Level == 1)
                {
                    Vehicle objVehicle = new Vehicle(_objCharacter);
                    // Locate the Vehicle that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        if (objCharacterVehicle.InternalId == treVehicles.SelectedNode.Tag.ToString())
                        {
                            objVehicle = objCharacterVehicle;
                            break;
                        }
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

                    if (frmSell.DialogResult == DialogResult.Cancel)
                        return;

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicle") + " " + objVehicle.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objCharacter.Vehicles.Remove(objVehicle);
                    treVehicles.SelectedNode.Remove();
                }
                else if (treVehicles.SelectedNode.Level == 2)
                {
                    // Locate the VehicleMod that is selected in the tree.
                    foreach (Vehicle objCharacterVehicle in _objCharacter.Vehicles)
                    {
                        foreach (VehicleMod objMod in objCharacterVehicle.Mods)
                        {
                            if (objMod.InternalId == treVehicles.SelectedNode.Tag.ToString())
                            {
                                // Do not allow VehicleMods that come with a Vehicle to be removed.
                                if (objMod.IncludedInVehicle)
                                {
                                    MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveVehicleMod"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveVehicleMod"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                else
                                {
                                    frmSellItem frmSell = new frmSellItem();
                                    frmSell.ShowDialog(this);

                                    if (frmSell.DialogResult == DialogResult.Cancel)
                                        return;

                                    // Record the original value of the Vehicle.
                                    int intOriginal = objCharacterVehicle.TotalCost;

                                    // Check for Improved Sensor bonus.
                                    if (objMod.Bonus != null)
                                    {
                                        if (objMod.Bonus["improvesensor"] != null)
                                        {
                                            ChangeVehicleSensor(objCharacterVehicle, false);
                                        }
                                    }

                                    objCharacterVehicle.Mods.Remove(objMod);
                                    treVehicles.SelectedNode.Remove();

                                    // Create the Expense Log Entry for the sale.
                                    int intAmount = Convert.ToInt32(Convert.ToDouble(intOriginal - objCharacterVehicle.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldVehicleMod") + " " + objMod.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                                    _objCharacter.ExpenseEntries.Add(objExpense);
                                    _objCharacter.Nuyen += intAmount;
                                }
                                break;
                            }
                        }
                    }

                    // 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())
                            {
                                frmSellItem frmSell = new frmSellItem();
                                frmSell.ShowDialog(this);

                                if (frmSell.DialogResult == DialogResult.Cancel)
                                    return;

                                // Record the original value of the vehicle.
                                int intOriginal = objCharacterVehicle.TotalCost;

//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例3: tsArmorSell_Click

        private void tsArmorSell_Click(object sender, EventArgs e)
        {
            // Delete the selected piece of Armor.
            try
            {
                if (treArmor.SelectedNode.Level == 1)
                {
                    // Locate the piece of Armor that is selected in the tree.
                    Armor objArmor = _objFunctions.FindArmor(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

                    if (frmSell.DialogResult == DialogResult.Cancel)
                        return;

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objArmor.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldArmor") + " " + objArmor.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    // Remove any Improvements created by the Armor and its children.
                    foreach (ArmorMod objMod in objArmor.ArmorMods)
                    {
                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.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() == objMod.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 == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);
                    }
                    _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Armor, objArmor.InternalId);

                    _objCharacter.Armor.Remove(objArmor);
                    treArmor.SelectedNode.Remove();
                }
                else if (treArmor.SelectedNode.Level == 2)
                {
                    // Locate the ArmorMod that is selected in the tree.
                    bool blnIsMod = false;
                    ArmorMod objMod = _objFunctions.FindArmorMod(treArmor.SelectedNode.Tag.ToString(), _objCharacter.Armor);
                    if (objMod != null)
                        blnIsMod = true;

                    if (blnIsMod)
                    {
                        // Record the cost of the Armor with the ArmorMod.
                        int intOriginal = objMod.Parent.TotalCost;

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

                        if (frmSell.DialogResult == DialogResult.Cancel)
                            return;

                        // Remove the Cyberweapon created by the Mod if applicable.
                        if (objMod.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() == objMod.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 == objMod.WeaponID)
                                    objRemoveWeapon = objWeapon;
                            }
                            _objCharacter.Weapons.Remove(objRemoveWeapon);
                        }

                        // Remove any Improvements created by the ArmorMod.
                        _objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.ArmorMod, objMod.InternalId);

                        objMod.Parent.ArmorMods.Remove(objMod);
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例4: tsCyberwareSell_Click

        private void tsCyberwareSell_Click(object sender, EventArgs e)
        {
            try
            {
                if (treCyberware.SelectedNode.Level > 0)
                {
                    bool blnFound = false;
                    Cyberware objCyberware = new Cyberware(_objCharacter);
                    Cyberware objParent = new Cyberware(_objCharacter);
                    // Locate the piece of Cyberware that is selected in the tree.
                    foreach (Cyberware objCharacterCyberware in _objCharacter.Cyberware)
                    {
                        if (objCharacterCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
                        {
                            objCyberware = objCharacterCyberware;
                            blnFound = true;
                            break;
                        }
                        foreach (Cyberware objChildCyberware in objCharacterCyberware.Children)
                        {
                            if (objChildCyberware.InternalId == treCyberware.SelectedNode.Tag.ToString())
                            {
                                objCyberware = objChildCyberware;
                                objParent = objCharacterCyberware;
                                blnFound = true;
                                break;
                            }
                        }
                    }

                    if (blnFound)
                    {
                        if (objCyberware.Capacity == "[*]" && treCyberware.SelectedNode.Level == 2)
                        {
                            MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotRemoveCyberware"), LanguageManager.Instance.GetString("MessageTitle_CannotRemoveCyberware"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        frmSellItem frmSell = new frmSellItem();
                        frmSell.ShowDialog(this);

                        if (frmSell.DialogResult == DialogResult.Cancel)
                            return;

                        // Create the Expense Log Entry for the sale.
                        int intAmount = Convert.ToInt32(Convert.ToDouble(objCyberware.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                        ExpenseLogEntry objExpense = new ExpenseLogEntry();
                        string strEntry = "";
                        if (objCyberware.SourceType == Improvement.ImprovementSource.Cyberware)
                            strEntry = LanguageManager.Instance.GetString("String_ExpenseSoldCyberware");
                        else
                            strEntry = LanguageManager.Instance.GetString("String_ExpenseSoldBioware");
                        objExpense.Create(intAmount, strEntry + " " + objCyberware.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                        _objCharacter.ExpenseEntries.Add(objExpense);
                        _objCharacter.Nuyen += intAmount;

                        // Run through the Cyberware's child elements and remove any Improvements and Cyberweapons.
                        foreach (Cyberware objChildCyberware in objCyberware.Children)
                        {
                            _objImprovementManager.RemoveImprovements(objCyberware.SourceType, objChildCyberware.InternalId);
                            if (objChildCyberware.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() == objChildCyberware.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 == objChildCyberware.WeaponID)
                                        objRemoveWeapon = objWeapon;
                                }
                                _objCharacter.Weapons.Remove(objRemoveWeapon);
                            }
                        }
                        // Remove the Children.
                        objCyberware.Children.Clear();

                        // Remove the Cyberweapon created by the Cyberware if applicable.
                        if (objCyberware.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() == objCyberware.WeaponID)
                                    objRemoveNode = objWeaponNode;
                            }
                            treWeapons.Nodes.Remove(objRemoveNode);

                            // Remove the Weapon from the Character.
                            Weapon objRemoveWeapon = new Weapon(_objCharacter);
                            foreach (Weapon objWeapon in _objCharacter.Weapons)
                            {
//.........这里部分代码省略.........
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:101,代码来源:frmCareer.cs

示例5: sellItemToolStripMenuItem_Click

        private void sellItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Delete the selected Gear.
            try
            {
                if (treGear.SelectedNode.Level > 0)
                {
                    Gear objGear = new Gear(_objCharacter);
                    Gear objParent = new Gear(_objCharacter);
                    // Locate the piece of Gear that is selected in the tree.
                    foreach (Gear objCharacterGear in _objCharacter.Gear)
                    {
                        if (objCharacterGear.InternalId == treGear.SelectedNode.Tag.ToString())
                        {
                            objGear = objCharacterGear;
                            break;
                        }
                        foreach (Gear objChildGear in objCharacterGear.Children)
                        {
                            if (objChildGear.InternalId == treGear.SelectedNode.Tag.ToString())
                            {
                                objGear = objChildGear;
                                objParent = objCharacterGear;
                                break;
                            }
                        }
                    }

                    frmSellItem frmSell = new frmSellItem();
                    frmSell.ShowDialog(this);

                    if (frmSell.DialogResult == DialogResult.Cancel)
                        return;

                    // Create the Expense Log Entry for the sale.
                    int intAmount = Convert.ToInt32(Convert.ToDouble(objGear.TotalCost, GlobalOptions.Instance.CultureInfo) * frmSell.SellPercent);
                    ExpenseLogEntry objExpense = new ExpenseLogEntry();
                    objExpense.Create(intAmount, LanguageManager.Instance.GetString("String_ExpenseSoldGear") + " " + objGear.DisplayNameShort, ExpenseType.Nuyen, DateTime.Now);
                    _objCharacter.ExpenseEntries.Add(objExpense);
                    _objCharacter.Nuyen += intAmount;

                    _objFunctions.DeleteGear(objGear, treWeapons, _objImprovementManager);

                    _objCharacter.Gear.Remove(objGear);
                    treGear.SelectedNode.Remove();

                    // If the Parent is populated, remove the item from its Parent.
                    objParent.Children.Remove(objGear);
                }
                _objController.PopulateFocusList(treFoci);
                UpdateCharacterInfo();
                RefreshSelectedGear();

                _blnIsDirty = true;
                UpdateWindowTitle();
            }
            catch
            {
            }
        }
开发者ID:Althalusdlg,项目名称:chummer5a,代码行数:60,代码来源:frmCareer.cs


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