コード例 #1
0
 protected override void ApplyToConfiguration(IKernel kernel, IConfiguration configuration)
 {
     if (configuration.Attributes["lifestyle"] == null || IsOverWrite)
     {
         configuration.Attributes["lifestyle"] = lifestyle.ToString();
     }
 }
コード例 #2
0
 /// <summary>
 /// Save the object's XML to the XmlWriter.
 /// </summary>
 /// <param name="objWriter">XmlTextWriter to write with.</param>
 public void Save(XmlTextWriter objWriter)
 {
     objWriter.WriteStartElement("lifestyle");
     objWriter.WriteElementString("guid", _guiID.ToString());
     objWriter.WriteElementString("name", _strName);
     objWriter.WriteElementString("cost", _decCost.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("dice", _intDice.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("baselifestyle", _strBaseLifestyle);
     objWriter.WriteElementString("multiplier", _decMultiplier.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("months", _intMonths.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("roommates", _intRoommates.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("percentage", _decPercentage.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("purchased", _blnPurchased.ToString());
     objWriter.WriteElementString("area", _intArea.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("comforts", _intComforts.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("security", _intSecurity.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("basearea", _intBaseArea.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("basecomforts", _intBaseComforts.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("basesecurity", _intBaseSecurity.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("entertainment", _intEntertainment.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("costforearea", _costForArea.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("costforcomforts", _costForComforts.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("costforsecurity", _costForSecurity.ToString(CultureInfo.InvariantCulture));
     objWriter.WriteElementString("source", _strSource);
     objWriter.WriteElementString("page", _strPage);
     objWriter.WriteElementString("trustfund", _blnTrustFund.ToString());
     objWriter.WriteElementString("primarytenant", _primaryTenant.ToString());
     objWriter.WriteElementString("type", _objType.ToString());
     objWriter.WriteElementString("sourceid", SourceID.ToString());
     objWriter.WriteStartElement("lifestylequalities");
     foreach (var objQuality in _lstLifestyleQualities)
     {
         objQuality.Save(objWriter);
     }
     objWriter.WriteEndElement();
     objWriter.WriteStartElement("freegrids");
     foreach (var objQuality in FreeGrids)
     {
         objQuality.Save(objWriter);
     }
     objWriter.WriteEndElement();
     objWriter.WriteElementString("notes", _strNotes);
     objWriter.WriteEndElement();
     _objCharacter.SourceProcess(_strSource);
 }
コード例 #3
0
ファイル: Lifestyle.cs プロジェクト: rmmonster/chummer5a
 /// <summary>
 /// Save the object's XML to the XmlWriter.
 /// </summary>
 /// <param name="objWriter">XmlTextWriter to write with.</param>
 public void Save(XmlTextWriter objWriter)
 {
     objWriter.WriteStartElement("lifestyle");
     objWriter.WriteElementString("guid", _guiID.ToString());
     objWriter.WriteElementString("name", _strName);
     objWriter.WriteElementString("cost", _intCost.ToString());
     objWriter.WriteElementString("dice", _intDice.ToString());
     objWriter.WriteElementString("baselifestyle", _strBaseLifestyle.ToString());
     objWriter.WriteElementString("multiplier", _intMultiplier.ToString());
     objWriter.WriteElementString("months", _intMonths.ToString());
     objWriter.WriteElementString("roommates", _intRoommates.ToString());
     objWriter.WriteElementString("percentage", _intPercentage.ToString());
     objWriter.WriteElementString("lifestylename", _strLifestyleName);
     objWriter.WriteElementString("purchased", _blnPurchased.ToString());
     objWriter.WriteElementString("comforts", _intComforts.ToString());
     objWriter.WriteElementString("area", _intArea.ToString());
     objWriter.WriteElementString("security", _intSecurity.ToString());
     objWriter.WriteElementString("comfortsentertainment", _intComfortsEntertainment.ToString());
     objWriter.WriteElementString("areaentertainment", _intAreaEntertainment.ToString());
     objWriter.WriteElementString("securityentertainment", _intSecurityEntertainment.ToString());
     objWriter.WriteElementString("entertainment", _intEntertainment.ToString());
     objWriter.WriteElementString("baselifestyle", _strBaseLifestyle);
     objWriter.WriteElementString("source", _strSource);
     objWriter.WriteElementString("page", _strPage);
     objWriter.WriteElementString("trustfund", _blnTrustFund.ToString());
     objWriter.WriteElementString("type", _objType.ToString());
     objWriter.WriteElementString("sourceid", SourceID.ToString());
     objWriter.WriteStartElement("lifestylequalities");
     foreach (LifestyleQuality objQuality in _lstLifestyleQualities)
     {
         objQuality.Save(objWriter);
     }
     objWriter.WriteEndElement();
     objWriter.WriteStartElement("freegrids");
     foreach (LifestyleQuality objQuality in _lstFreeGrids)
     {
         objQuality.Save(objWriter);
     }
     objWriter.WriteEndElement();
     objWriter.WriteElementString("notes", _strNotes);
     objWriter.WriteEndElement();
     _objCharacter.SourceProcess(_strSource);
 }
コード例 #4
0
ファイル: Lifestyle.cs プロジェクト: Dherman3607/chummer5a
        /// <summary>
        /// Save the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        public void Save(XmlTextWriter objWriter)
        {
            objWriter.WriteStartElement("lifestyle");
            objWriter.WriteElementString("sourceid", SourceIDString);
            objWriter.WriteElementString("guid", InternalId);
            objWriter.WriteElementString("name", _strName);
            objWriter.WriteElementString("cost", _decCost.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("dice", _intDice.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("baselifestyle", _strBaseLifestyle);
            objWriter.WriteElementString("multiplier", _decMultiplier.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("months", _intIncrements.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("roommates", _intRoommates.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("percentage", _decPercentage.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("area", _intArea.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("comforts", _intComforts.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("security", _intSecurity.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("basearea", _intBaseArea.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("basecomforts", _intBaseComforts.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("basesecurity", _intBaseSecurity.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("costforearea", _decCostForArea.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("costforcomforts", _decCostForComforts.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("costforsecurity", _decCostForSecurity.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("allowbonuslp", _blnAllowBonusLP.ToString());
            objWriter.WriteElementString("bonuslp", _intBonusLP.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("source", _strSource);
            objWriter.WriteElementString("page", _strPage);
            objWriter.WriteElementString("trustfund", _blnTrustFund.ToString());
            objWriter.WriteElementString("primarytenant", _blnIsPrimaryTenant.ToString());
            objWriter.WriteElementString("type", _eType.ToString());
            objWriter.WriteElementString("increment", _eIncrement.ToString());
            objWriter.WriteElementString("sourceid", SourceIDString);
            objWriter.WriteStartElement("lifestylequalities");
            foreach (LifestyleQuality objQuality in _lstLifestyleQualities)
            {
                objQuality.Save(objWriter);
            }
            objWriter.WriteEndElement();
            objWriter.WriteStartElement("freegrids");
            foreach (LifestyleQuality objQuality in _lstFreeGrids)
            {
                objQuality.Save(objWriter);
            }
            objWriter.WriteEndElement();
            objWriter.WriteElementString("notes", _strNotes);
            objWriter.WriteElementString("sortorder", _intSortOrder.ToString());
            objWriter.WriteEndElement();

            _objCharacter.SourceProcess(_strSource);
        }
コード例 #5
0
        private void frmSelectAdvancedLifestyle_Load(object sender, EventArgs e)
        {
            _blnSkipRefresh = true;

            foreach (Label objLabel in this.Controls.OfType <Label>())
            {
                if (objLabel.Text.StartsWith("["))
                {
                    objLabel.Text = "";
                }
            }

            // Load the Lifestyles information.
            _objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");

            // Populate the Advanced Lifestyle ComboBoxes.
            // Comforts.
            List <ListItem> lstComforts = new List <ListItem>();

            foreach (XmlNode objXmlComfort in _objXmlDocument.SelectNodes("/chummer/comforts/comfort"))
            {
                bool blnAdd = true;
                if (_objType != LifestyleType.Advanced && objXmlComfort["slp"] != null)
                {
                    if (objXmlComfort["slp"].InnerText == "remove")
                    {
                        blnAdd = false;
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlComfort["name"].InnerText;
                    if (objXmlComfort["translate"] != null)
                    {
                        objItem.Name = objXmlComfort["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlComfort["name"].InnerText;
                    }
                    lstComforts.Add(objItem);
                }
            }
            cboComforts.ValueMember   = "Value";
            cboComforts.DisplayMember = "Name";
            cboComforts.DataSource    = lstComforts;

            cboComforts.SelectedValue = _objLifestyle.Comforts;
            if (cboComforts.SelectedIndex == -1)
            {
                cboComforts.SelectedIndex = 0;
            }

            // Entertainment.
            List <ListItem> lstEntertainments = new List <ListItem>();

            foreach (XmlNode objXmlEntertainment in _objXmlDocument.SelectNodes("/chummer/entertainments/entertainment"))
            {
                bool blnAdd = true;
                if (_objType != LifestyleType.Advanced && objXmlEntertainment["slp"] != null)
                {
                    if (objXmlEntertainment["slp"].InnerText == "remove")
                    {
                        blnAdd = false;
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlEntertainment["name"].InnerText;
                    if (objXmlEntertainment["translate"] != null)
                    {
                        objItem.Name = objXmlEntertainment["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlEntertainment["name"].InnerText;
                    }
                    lstEntertainments.Add(objItem);
                }
            }
            cboEntertainment.ValueMember   = "Value";
            cboEntertainment.DisplayMember = "Name";
            cboEntertainment.DataSource    = lstEntertainments;

            cboEntertainment.SelectedValue = _objLifestyle.Entertainment;
            if (cboEntertainment.SelectedIndex == -1)
            {
                cboEntertainment.SelectedIndex = 0;
            }

            // Necessities.
            List <ListItem> lstNecessities = new List <ListItem>();

            foreach (XmlNode objXmlNecessity in _objXmlDocument.SelectNodes("/chummer/necessities/necessity"))
            {
                bool blnAdd = true;
                if (_objType != LifestyleType.Advanced && objXmlNecessity["slp"] != null)
                {
                    if (objXmlNecessity["slp"].InnerText == "remove")
                    {
                        blnAdd = false;
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlNecessity["name"].InnerText;
                    if (objXmlNecessity["translate"] != null)
                    {
                        objItem.Name = objXmlNecessity["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlNecessity["name"].InnerText;
                    }
                    lstNecessities.Add(objItem);
                }
            }
            cboNecessities.ValueMember   = "Value";
            cboNecessities.DisplayMember = "Name";
            cboNecessities.DataSource    = lstNecessities;

            cboNecessities.SelectedValue = _objLifestyle.Necessities;
            if (cboNecessities.SelectedIndex == -1)
            {
                cboNecessities.SelectedIndex = 0;
            }

            // Neighborhood.
            List <ListItem> lstNeighborhoods = new List <ListItem>();

            foreach (XmlNode objXmlNeighborhood in _objXmlDocument.SelectNodes("/chummer/neighborhoods/neighborhood"))
            {
                bool blnAdd = true;
                if (_objType != LifestyleType.Advanced && objXmlNeighborhood["slp"] != null)
                {
                    if (objXmlNeighborhood["slp"].InnerText == "remove")
                    {
                        blnAdd = false;
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlNeighborhood["name"].InnerText;
                    if (objXmlNeighborhood["translate"] != null)
                    {
                        objItem.Name = objXmlNeighborhood["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlNeighborhood["name"].InnerText;
                    }
                    lstNeighborhoods.Add(objItem);
                }
            }
            cboNeighborhood.ValueMember   = "Value";
            cboNeighborhood.DisplayMember = "Name";
            cboNeighborhood.DataSource    = lstNeighborhoods;

            cboNeighborhood.SelectedValue = _objLifestyle.Neighborhood;
            if (cboNeighborhood.SelectedIndex == -1)
            {
                cboNeighborhood.SelectedIndex = 0;
            }

            // Security.
            List <ListItem> lstSecurities = new List <ListItem>();

            foreach (XmlNode objXmlSecurity in _objXmlDocument.SelectNodes("/chummer/securities/security"))
            {
                bool blnAdd = true;
                if (_objType != LifestyleType.Advanced && objXmlSecurity["slp"] != null)
                {
                    if (objXmlSecurity["slp"].InnerText == "remove")
                    {
                        blnAdd = false;
                    }
                }

                if (blnAdd)
                {
                    ListItem objItem = new ListItem();
                    objItem.Value = objXmlSecurity["name"].InnerText;
                    if (objXmlSecurity["translate"] != null)
                    {
                        objItem.Name = objXmlSecurity["translate"].InnerText;
                    }
                    else
                    {
                        objItem.Name = objXmlSecurity["name"].InnerText;
                    }
                    lstSecurities.Add(objItem);
                }
            }
            cboSecurity.ValueMember   = "Value";
            cboSecurity.DisplayMember = "Name";
            cboSecurity.DataSource    = lstSecurities;

            cboSecurity.SelectedValue = _objLifestyle.Security;
            if (cboSecurity.SelectedIndex == -1)
            {
                cboSecurity.SelectedIndex = 0;
            }

            // Fill the Positive Qualities list.
            foreach (XmlNode objXmlQuality in _objXmlDocument.SelectNodes("/chummer/qualities/quality[category = \"Positive\" and contains(allowed, \"" + _objType.ToString() + "\") and (" + _objCharacter.Options.BookXPath() + ")]"))
            {
                TreeNode nodQuality = new TreeNode();
                nodQuality.Tag = objXmlQuality["name"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                if (objXmlQuality["translate"] != null)
                {
                    nodQuality.Text = objXmlQuality["translate"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                }
                else
                {
                    nodQuality.Text = objXmlQuality["name"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                }
                trePositiveQualities.Nodes.Add(nodQuality);
            }

            // Fill the Negative Qualities list.
            foreach (XmlNode objXmlQuality in _objXmlDocument.SelectNodes("/chummer/qualities/quality[category = \"Negative\" and contains(allowed, \"" + _objType.ToString() + "\") and (" + _objCharacter.Options.BookXPath() + ")]"))
            {
                TreeNode nodQuality = new TreeNode();
                nodQuality.Tag = objXmlQuality["name"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                if (objXmlQuality["translate"] != null)
                {
                    nodQuality.Text = objXmlQuality["translate"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                }
                else
                {
                    nodQuality.Text = objXmlQuality["name"].InnerText + " [" + objXmlQuality["lp"].InnerText + "LP]";
                }
                treNegativeQualities.Nodes.Add(nodQuality);
            }

            SortTree(trePositiveQualities);
            SortTree(treNegativeQualities);

            if (_objSourceLifestyle != null)
            {
                txtLifestyleName.Text          = _objSourceLifestyle.Name;
                cboComforts.SelectedValue      = _objSourceLifestyle.Comforts;
                cboEntertainment.SelectedValue = _objSourceLifestyle.Entertainment;
                cboNecessities.SelectedValue   = _objSourceLifestyle.Necessities;
                cboNeighborhood.SelectedValue  = _objSourceLifestyle.Neighborhood;
                cboSecurity.SelectedValue      = _objSourceLifestyle.Security;
                nudRoommates.Value             = _objSourceLifestyle.Roommates;
                nudPercentage.Value            = _objSourceLifestyle.Percentage;
                foreach (string strQuality in _objSourceLifestyle.Qualities)
                {
                    foreach (TreeNode objNode in trePositiveQualities.Nodes)
                    {
                        if (objNode.Tag.ToString() == strQuality)
                        {
                            objNode.Checked = true;
                            break;
                        }
                    }
                    foreach (TreeNode objNode in treNegativeQualities.Nodes)
                    {
                        if (objNode.Tag.ToString() == strQuality)
                        {
                            objNode.Checked = true;
                            break;
                        }
                    }
                }
            }

            // Safehouses have a cost per week instead of cost per month.
            if (_objType == LifestyleType.Safehouse)
            {
                lblCostLabel.Text = LanguageManager.Instance.GetString("Label_SelectLifestyle_CostPerWeek");
            }

            _blnSkipRefresh = false;
            CalculateValues();
        }