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


C# ImprovementManager.RemoveImprovements方法代码示例

本文整理汇总了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;
        }
开发者ID:janhelke,项目名称:chummer2,代码行数:99,代码来源:frmCreateImprovement.cs

示例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;
                    }
                }
            }
        }
开发者ID:hollis21,项目名称:Chummer,代码行数:63,代码来源:clsCommon.cs

示例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);
            }
        }
开发者ID:argo2445,项目名称:chummer5a,代码行数:25,代码来源:CharacterShared.cs


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