本文整理汇总了C#中Chummer.ListItem类的典型用法代码示例。如果您正苦于以下问题:C# ListItem类的具体用法?C# ListItem怎么用?C# ListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListItem类属于Chummer命名空间,在下文中一共展示了ListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: frmSelectExoticSkill_Load
private void frmSelectExoticSkill_Load(object sender, EventArgs e)
{
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument = XmlManager.Instance.Load("skills.xml");
List<ListItem> lstSkills = new List<ListItem>();
// Build the list of Exotic Active Skills from the Skills file.
XmlNodeList objXmlSkillList = objXmlDocument.SelectNodes("/chummer/skills/skill[exotic = \"Yes\"]");
foreach (XmlNode objXmlSkill in objXmlSkillList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlSkill["name"].InnerText;
if (objXmlSkill.Attributes != null)
{
if (objXmlSkill["translate"] != null)
objItem.Name = objXmlSkill["translate"].InnerText;
else
objItem.Name = objXmlSkill["name"].InnerText;
}
else
objItem.Name = objXmlSkill["name"].InnerXml;
lstSkills.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstSkills.Sort(objSort.Compare);
cboCategory.ValueMember = "Value";
cboCategory.DisplayMember = "Name";
cboCategory.DataSource = lstSkills;
// Select the first Skill in the list.
cboCategory.SelectedIndex = 0;
}
示例2: cboCategory_SelectedIndexChanged
private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
{
// Update the list of Kits based on the selected Category.
List<ListItem> lstKit = new List<ListItem>();
// Retrieve the list of Kits for the selected Category.
XmlNodeList objXmlPacksList = _objXmlDocument.SelectNodes("/chummer/packs/pack[category = \"" + cboCategory.SelectedValue + "\"]");
foreach (XmlNode objXmlPack in objXmlPacksList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlPack["name"].InnerText;
if (objXmlPack["translate"] != null)
objItem.Name = objXmlPack["translate"].InnerText;
else
objItem.Name = objXmlPack["name"].InnerText;
lstKit.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstKit.Sort(objSort.Compare);
lstKits.DataSource = null;
lstKits.ValueMember = "Value";
lstKits.DisplayMember = "Name";
lstKits.DataSource = lstKit;
if (lstKits.Items.Count == 0)
treContents.Nodes.Clear();
if (cboCategory.SelectedValue.ToString() == "Custom")
cmdDelete.Visible = true;
else
cmdDelete.Visible = false;
}
示例3: frmSelectMartialArtManeuver_Load
private void frmSelectMartialArtManeuver_Load(object sender, EventArgs e)
{
foreach (Label objLabel in this.Controls.OfType<Label>())
{
if (objLabel.Text.StartsWith("["))
objLabel.Text = "";
}
List<ListItem> lstManeuver = new List<ListItem>();
// Load the Martial Art information.
_objXmlDocument = XmlManager.Instance.Load("martialarts.xml");
// Populate the Martial Art Maneuver list.
XmlNodeList objManeuverList = _objXmlDocument.SelectNodes("/chummer/maneuvers/maneuver[" + _objCharacter.Options.BookXPath() + "]");
foreach (XmlNode objXmlManeuver in objManeuverList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlManeuver["name"].InnerText;
if (objXmlManeuver["translate"] != null)
objItem.Name = objXmlManeuver["translate"].InnerText;
else
objItem.Name = objXmlManeuver["name"].InnerText;
lstManeuver.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstManeuver.Sort(objSort.Compare);
lstManeuvers.DataSource = null;
lstManeuvers.ValueMember = "Value";
lstManeuvers.DisplayMember = "Name";
lstManeuvers.DataSource = lstManeuver;
}
示例4: frmSelectSetting_Load
private void frmSelectSetting_Load(object sender, EventArgs e)
{
// Build the list of XML files found in the settings directory.
List<ListItem> lstSettings = new List<ListItem>();
string settingsDirectoryPath = Path.Combine(Environment.CurrentDirectory, "settings");
foreach (string strFileName in Directory.GetFiles(settingsDirectoryPath, "*.xml"))
{
// Load the file so we can get the Setting name.
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.Load(strFileName);
string strSettingsName = objXmlDocument.SelectSingleNode("/settings/name").InnerText;
ListItem objItem = new ListItem();
objItem.Value = Path.GetFileName(strFileName);
objItem.Name = strSettingsName;
lstSettings.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstSettings.Sort(objSort.Compare);
cboSetting.DataSource = lstSettings;
cboSetting.ValueMember = "Value";
cboSetting.DisplayMember = "Name";
// Attempt to make default.xml the default one. If it could not be found in the list, select the first item instead.
cboSetting.SelectedIndex = cboSetting.FindStringExact("Default Settings");
if (cboSetting.SelectedIndex == -1)
cboSetting.SelectedIndex = 0;
}
示例5: frmSelectSetting_Load
private void frmSelectSetting_Load(object sender, EventArgs e)
{
// Build the list of XML files found in the settings directory.
List<ListItem> lstSettings = new List<ListItem>();
foreach (string strFileName in Directory.GetFiles(Path.Combine(GlobalOptions.ApplicationPath(), "settings"), "*.xml"))
{
// Remove the path from the file name.
string strSettingsFile = strFileName;
strSettingsFile = strSettingsFile.Replace(Path.Combine(GlobalOptions.ApplicationPath(), "settings"), string.Empty);
strSettingsFile = strSettingsFile.Replace(Path.DirectorySeparatorChar, ' ').Trim();
// Load the file so we can get the Setting name.
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.Load(strFileName);
string strSettingsName = objXmlDocument.SelectSingleNode("/settings/name").InnerText;
ListItem objItem = new ListItem();
objItem.Value = strSettingsFile;
objItem.Name = strSettingsName;
lstSettings.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstSettings.Sort(objSort.Compare);
cboSetting.DataSource = lstSettings;
cboSetting.ValueMember = "Value";
cboSetting.DisplayMember = "Name";
// Attempt to make default.xml the default one. If it could not be found in the list, select the first item instead.
cboSetting.SelectedIndex = cboSetting.FindStringExact("Default Settings");
if (cboSetting.SelectedIndex == -1)
cboSetting.SelectedIndex = 0;
}
示例6: frmSelectMentorSpirit_Load
private void frmSelectMentorSpirit_Load(object sender, EventArgs e)
{
if (_strXmlFile == "paragons.xml")
this.Text = LanguageManager.Instance.GetString("Title_SelectMentorSpirit_Paragon");
foreach (Label objLabel in this.Controls.OfType<Label>())
{
if (objLabel.Text.StartsWith("["))
objLabel.Text = "";
}
// Load the Mentor information.
_objXmlDocument = XmlManager.Instance.Load(_strXmlFile);
List<ListItem> lstMentors = new List<ListItem>();
// Populate the Mentor list.
XmlNodeList objXmlMentorList = _objXmlDocument.SelectNodes("/chummer/mentors/mentor[(" + _objCharacter.Options.BookXPath() + ")]");
foreach (XmlNode objXmlMentor in objXmlMentorList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlMentor["name"].InnerText;
if (objXmlMentor["translate"] != null)
objItem.Name = objXmlMentor["translate"].InnerText;
else
objItem.Name = objXmlMentor["name"].InnerText;
lstMentors.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstMentors.Sort(objSort.Compare);
lstMentor.DataSource = null;
lstMentor.ValueMember = "Value";
lstMentor.DisplayMember = "Name";
lstMentor.DataSource = lstMentors;
}
示例7: frmSelectWeaponCategory_Load
private void frmSelectWeaponCategory_Load(object sender, EventArgs e)
{
_objXmlDocument = XmlManager.Instance.Load("weapons.xml");
// Build a list of Weapon Categories found in the Weapons file.
XmlNodeList objXmlCategoryList;
List<ListItem> lstCategory = new List<ListItem>();
if (_strForceCategory != "")
{
objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category[. = \"" + _strForceCategory + "\"]");
}
else
{
objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category");
}
foreach (XmlNode objXmlCategory in objXmlCategoryList)
{
if (WeaponType != null)
{
if (objXmlCategory.Attributes["type"] == null)
continue;
if (objXmlCategory.Attributes["type"].Value != WeaponType)
continue;
}
ListItem objItem = new ListItem();
objItem.Value = objXmlCategory.InnerText;
if (objXmlCategory.Attributes != null)
{
if (objXmlCategory.Attributes["translate"] != null)
objItem.Name = objXmlCategory.Attributes["translate"].InnerText;
else
objItem.Name = objXmlCategory.InnerText;
}
else
objItem.Name = objXmlCategory.InnerText;
lstCategory.Add(objItem);
}
// Add the Cyberware Category.
if (/*_strForceCategory == "" ||*/ _strForceCategory == "Cyberware")
{
ListItem objItem = new ListItem();
objItem.Value = "Cyberware";
objItem.Name = "Cyberware";
lstCategory.Add(objItem);
}
cboCategory.ValueMember = "Value";
cboCategory.DisplayMember = "Name";
cboCategory.DataSource = lstCategory;
// Select the first Skill in the list.
cboCategory.SelectedIndex = 0;
if (cboCategory.Items.Count == 1)
cmdOK_Click(sender, e);
}
示例8: frmSelectBP
public frmSelectBP(Character objCharacter, bool blnUseCurrentValues = false)
{
_objCharacter = objCharacter;
_objOptions = _objCharacter.Options;
_blnUseCurrentValues = blnUseCurrentValues;
InitializeComponent();
LanguageManager.Instance.Load(this);
// Populate the Build Method list.
List<ListItem> lstBuildMethod = new List<ListItem>();
//ListItem objBP = new ListItem();
//objBP.Value = "BP";
//objBP.Name = LanguageManager.Instance.GetString("String_BP");
//ListItem objKarma = new ListItem();
//objKarma.Value = "Karma";
//objKarma.Name = LanguageManager.Instance.GetString("String_Karma");
ListItem objPriority = new ListItem();
objPriority.Value = "Priority";
objPriority.Name = LanguageManager.Instance.GetString("String_Priority");
//lstBuildMethod.Add(objBP);
//lstBuildMethod.Add(objKarma);
lstBuildMethod.Add(objPriority);
cboBuildMethod.DataSource = lstBuildMethod;
cboBuildMethod.ValueMember = "Value";
cboBuildMethod.DisplayMember = "Name";
cboBuildMethod.SelectedValue = _objOptions.BuildMethod;
nudBP.Value = _objOptions.BuildPoints;
nudMaxAvail.Value = _objOptions.Availability;
toolTip1.SetToolTip(chkIgnoreRules, LanguageManager.Instance.GetString("Tip_SelectBP_IgnoreRules"));
if (blnUseCurrentValues)
{
//if (objCharacter.BuildMethod == CharacterBuildMethod.Karma)
//{
// cboBuildMethod.SelectedValue = "Karma";
// nudBP.Value = objCharacter.BuildKarma;
//}
//else if (objCharacter.BuildMethod == CharacterBuildMethod.BP)
//{
// cboBuildMethod.SelectedValue = "BP";
// nudBP.Value = objCharacter.BuildPoints;
//}
cboBuildMethod.SelectedValue = "Priority";
nudBP.Value = objCharacter.BuildKarma;
nudMaxAvail.Value = objCharacter.MaximumAvailability;
cboBuildMethod.Enabled = false;
}
}
示例9: SinglePower
/// <summary>
/// Limit the list to a single Power.
/// </summary>
/// <param name="strValue">Single Power to display.</param>
public void SinglePower(string strValue)
{
List<ListItem> lstItems = new List<ListItem>();
ListItem objItem = new ListItem();
objItem.Value = strValue;
objItem.Name = strValue;
lstItems.Add(objItem);
cboPower.DataSource = null;
cboPower.ValueMember = "Value";
cboPower.DisplayMember = "Name";
cboPower.DataSource = lstItems;
}
示例10: frmReload_Load
private void frmReload_Load(object sender, EventArgs e)
{
List<ListItem> lstAmmo = new List<ListItem>();
// Add each of the items to a new List since we need to also grab their plugin information.
foreach (Gear objGear in _lstAmmo)
{
ListItem objAmmo = new ListItem();
objAmmo.Value = objGear.InternalId;
objAmmo.Name = objGear.DisplayNameShort;
objAmmo.Name += " x" + objGear.Quantity.ToString();
if (objGear.Parent != null)
{
if (objGear.Parent.DisplayNameShort != string.Empty)
{
objAmmo.Name += " (" + objGear.Parent.DisplayNameShort;
if (objGear.Parent.Location != string.Empty)
objAmmo.Name += " @ " + objGear.Parent.Location;
objAmmo.Name += ")";
}
}
if (objGear.Location != string.Empty)
objAmmo.Name += " (" + objGear.Location + ")";
// Retrieve the plugin information if it has any.
if (objGear.Children.Count > 0)
{
string strPlugins = "";
foreach (Gear objChild in objGear.Children)
{
strPlugins += objChild.DisplayNameShort + ", ";
}
// Remove the trailing comma.
strPlugins = strPlugins.Substring(0, strPlugins.Length - 2);
// Append the plugin information to the name.
objAmmo.Name += " [" + strPlugins + "]";
}
lstAmmo.Add(objAmmo);
}
// Populate the lists.
cboAmmo.DataSource = lstAmmo;
cboAmmo.ValueMember = "Value";
cboAmmo.DisplayMember = "Name";
cboType.DataSource = _lstCount;
// If there's only 1 value in each list, the character doesn't have a choice, so just accept it.
if (cboAmmo.Items.Count == 1 && cboType.Items.Count == 1)
AcceptForm();
}
示例11: frmSelectLifestyleQuality_Load
private void frmSelectLifestyleQuality_Load(object sender, EventArgs e)
{
_objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");
foreach (Label objLabel in this.Controls.OfType<Label>())
{
if (objLabel.Text.StartsWith("["))
objLabel.Text = "";
}
// Load the Quality information.
_objXmlDocument = XmlManager.Instance.Load("lifestyles.xml");
// Populate the Quality Category list.
XmlNodeList objXmlCategoryList = _objXmlDocument.SelectNodes("/chummer/categories/category");
foreach (XmlNode objXmlCategory in objXmlCategoryList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlCategory.InnerText;
if (objXmlCategory.Attributes != null)
{
if (objXmlCategory.Attributes["translate"] != null)
objItem.Name = objXmlCategory.Attributes["translate"].InnerText;
else
objItem.Name = objXmlCategory.InnerText;
}
else
objItem.Name = objXmlCategory.InnerXml;
_lstCategory.Add(objItem);
}
cboCategory.ValueMember = "Value";
cboCategory.DisplayMember = "Name";
cboCategory.DataSource = _lstCategory;
// Select the first Category in the list.
if (_strSelectCategory == "")
cboCategory.SelectedIndex = 0;
else
cboCategory.SelectedValue = _strSelectCategory;
if (cboCategory.SelectedIndex == -1)
cboCategory.SelectedIndex = 0;
// Change the BP Label to Karma if the character is being built with Karma instead (or is in Career Mode).
if (_objCharacter.BuildMethod == CharacterBuildMethod.Karma || _objCharacter.BuildMethod == CharacterBuildMethod.Priority || _objCharacter.Created)
lblBPLabel.Text = LanguageManager.Instance.GetString("Label_Karma");
BuildQualityList();
}
示例12: frmCreateImprovement_Load
private void frmCreateImprovement_Load(object sender, EventArgs e)
{
List<ListItem> lstTypes = new List<ListItem>();
_objDocument = XmlManager.Instance.Load("improvements.xml");
// Populate the Improvement Type list.
XmlNodeList objXmlImprovementList = _objDocument.SelectNodes("/chummer/improvements/improvement");
foreach (XmlNode objXmlImprovement in objXmlImprovementList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlImprovement["id"].InnerText;
if (objXmlImprovement["translate"] != null)
objItem.Name = objXmlImprovement["translate"].InnerText;
else
objItem.Name = objXmlImprovement["name"].InnerText;
lstTypes.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstTypes.Sort(objSort.Compare);
cboImprovemetType.ValueMember = "Value";
cboImprovemetType.DisplayMember = "Name";
cboImprovemetType.DataSource = lstTypes;
// Load the information from the passed Improvement if one has been given.
if (_objEditImprovement != null)
{
cboImprovemetType.SelectedValue = _objEditImprovement.CustomId;
txtName.Text = _objEditImprovement.CustomName;
if (nudMax.Visible)
nudMax.Value = _objEditImprovement.Maximum;
if (nudMin.Visible)
nudMin.Value = _objEditImprovement.Minimum;
if (nudVal.Visible)
{
// specificattribute stores the Value in Augmented instead.
if (_objEditImprovement.CustomId == "specificattribute")
nudVal.Value = _objEditImprovement.Augmented;
else
nudVal.Value = _objEditImprovement.Value;
}
if (chkApplyToRating.Visible)
chkApplyToRating.Checked = _objEditImprovement.AddToRating;
else
chkApplyToRating.Checked = false;
if (txtSelect.Visible)
txtSelect.Text = _objEditImprovement.ImprovedName;
}
}
示例13: frmSelectMartialArtAdvantage_Load
private void frmSelectMartialArtAdvantage_Load(object sender, EventArgs e)
{
foreach (Label objLabel in this.Controls.OfType<Label>())
{
if (objLabel.Text.StartsWith("["))
objLabel.Text = "";
}
List<ListItem> lstAdvantage = new List<ListItem>();
// Load the Martial Art information.
_objXmlDocument = XmlManager.Instance.Load("martialarts.xml");
// Populate the Martial Art Advantage list.
XmlNodeList objXmlAdvantageList = _objXmlDocument.SelectNodes("/chummer/martialarts/martialart[(" + _objCharacter.Options.BookXPath() + ") and name = \"" + _strMartialArt + "\"]/techniques/technique");
foreach (XmlNode objXmlAdvantage in objXmlAdvantageList)
{
ListItem objItem = new ListItem();
objItem.Value = objXmlAdvantage["name"].InnerText;
if (objXmlAdvantage.Attributes["translate"] != null)
objItem.Name = objXmlAdvantage.Attributes["translate"].InnerText;
else
objItem.Name = objXmlAdvantage["name"].InnerText;
bool blnIsNew = true;
foreach (MartialArt objMartialArt in _objCharacter.MartialArts)
{
if (objMartialArt.Name == _strMartialArt)
{
foreach (MartialArtAdvantage objMartialArtAdvantage in objMartialArt.Advantages)
{
if (objMartialArtAdvantage.Name == objItem.Value)
{
blnIsNew = false;
}
}
}
}
if (blnIsNew)
lstAdvantage.Add(objItem);
}
SortListItem objSort = new SortListItem();
lstAdvantage.Sort(objSort.Compare);
lstAdvantages.DataSource = null;
lstAdvantages.ValueMember = "Value";
lstAdvantages.DisplayMember = "Name";
lstAdvantages.DataSource = lstAdvantage;
}
示例14: LimitToList
/// <summary>
/// Limit the list to a few Powers.
/// </summary>
/// <param name="strValue">List of Powers.</param>
public void LimitToList(List<string> strValue)
{
_lstPowers.Clear();
foreach (string strPower in strValue)
{
ListItem objItem = new ListItem();
objItem.Value = strPower;
objItem.Name = strPower;
_lstPowers.Add(objItem);
}
cboPower.DataSource = null;
cboPower.DataSource = _lstPowers;
cboPower.ValueMember = "Value";
cboPower.DisplayMember = "Name";
}
示例15: LimitToList
/// <summary>
/// Limit the list to a few Limits.
/// </summary>
/// <param name="strValue">List of Limits.</param>
public void LimitToList(List<string> strValue)
{
_lstLimits.Clear();
foreach (string strLimit in strValue)
{
ListItem objItem = new ListItem();
objItem.Value = strLimit;
objItem.Name = LanguageManager.Instance.GetString("String_Limit" + strLimit + "Short");
_lstLimits.Add(objItem);
}
cboLimit.DataSource = null;
cboLimit.DataSource = _lstLimits;
cboLimit.ValueMember = "Value";
cboLimit.DisplayMember = "Name";
}