コード例 #1
0
ファイル: frmCreate.cs プロジェクト: janhelke/chummer2
        private void cmdAddPower_Click(object sender, EventArgs e)
        {
            frmSelectPower frmPickPower = new frmSelectPower(_objCharacter);
            frmPickPower.ShowDialog(this);

            // Make sure the dialogue window was not canceled.
            if (frmPickPower.DialogResult == DialogResult.Cancel)
                return;

            int i = panPowers.Controls.Count;

            // Open the Cyberware XML file and locate the selected piece.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("powers.xml");

            XmlNode objXmlPower = objXmlDocument.SelectSingleNode("/chummer/powers/power[id = \"" + frmPickPower.SelectedPower + "\"]");

            Power objPower = new Power(_objCharacter);
            objPower.Create(objXmlPower, _objCharacter);
            _objCharacter.Powers.Add(objPower);

            PowerControl objPowerControl = new PowerControl();
            objPowerControl.PowerObject = objPower;

            // Attach an EventHandler for the PowerRatingChanged Event.
            objPowerControl.PowerRatingChanged += objPower_PowerRatingChanged;
            objPowerControl.DeletePower += objPower_DeletePower;

            objPower.Source = objXmlPower["source"].InnerText;
            objPower.Page = objXmlPower["page"].InnerText;
            if (objXmlPower["doublecost"] != null)
                objPower.DoubleCost = false;

            // Set the control's Maximum.
            objPowerControl.RefreshMaximum(_objCharacter.MAG.TotalValue);
            objPowerControl.Top = i * objPowerControl.Height;
            objPowerControl.RefreshTooltip();
            panPowers.Controls.Add(objPowerControl);

            UpdateCharacterInfo();

            _blnIsDirty = true;
            UpdateWindowTitle();

            if (frmPickPower.AddAgain)
                cmdAddPower_Click(sender, e);
        }
コード例 #2
0
ファイル: UniqueTests.cs プロジェクト: janhelke/chummer2
        public void CreateAllPowersTest()
        {
            // Create a new Human character.
            Character objCharacter = new Character();
            objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));

            XmlDocument objXmlDocument = XmlManager.Instance.Load("powers.xml");
            foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/powers/power"))
            {
                Power objPower = new Power(objCharacter);
                objPower.Create(objXmlNode, objCharacter, 1, "", false);
            }
        }