rendered paste bodyusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;
namespace WindowsFormsApplication3
{
public partial class Main : Form
{
// set up buffers
List<string> catBufferList = new List<string>();
List<string> recBufferList = new List<string>();
List<string> recBufferName = new List<string>();
List<string> woodBufferList = new List<string>();
List<string> boneBufferList = new List<string>();
List<string> clothBufferList = new List<string>();
List<string> leatherBufferList = new List<string>();
List<string> metalBufferList = new List<string>();
List<string> _type = new List<string>();
List<string> _weapons = new List<string>();
List<string> _weaponsLoaded = new List<string>();
List<string> _armor = new List<string>();
List<string> _items = new List<string>();
List<string> _woodmats = new List<string>();
List<string> _bonemats = new List<string>();
List<string> _clothmats = new List<string>();
List<string> _metalmats = new List<string>();
List<string> _leathermats = new List<string>();
List<string> _woodmats2 = new List<string>();
List<string> _bonemats2 = new List<string>();
List<string> _clothmats2 = new List<string>();
List<string> _metalmats2 = new List<string>();
List<string> _leathermats2 = new List<string>();
List<string> _matTypes = new List<string>();
List<string> _matTypes2 = new List<string>();
List<string> _cats = new List<string>();
List<string> _cats2 = new List<string>();
string bufferString;
string currentBuffer;
string primaryMatTypeIndex;
string secondaryMatTypeIndex;
int mat1_ID;
string mat1_Name;
int mat1_Weight;
int mat1_Thickness;
int mat1_Density;
int mat1_Purity;
int mat1_Age;
int mat1_Integrity;
int mat1_Elasticity;
int mat2_ID;
string mat2_Name;
int mat2_Weight;
int mat2_Thickness;
int mat2_Density;
int mat2_Purity;
int mat2_Age;
int mat2_Integrity;
int mat2_Elasticity;
int cat_ID;
string cat_Name;
int cat_AWeight;
int cat_Viscosity;
int cat_Melt;
int cat_Freeze;
string cat_Type;
string cat_Mole;
string cat_Half;
int globalItemSpeed = 1;
string globalItemType;
public Main()
{
InitializeComponent();
_type.Add("Weapon");
_type.Add("Armor");
_type.Add("Item");
_matTypes.Add("Bone");
_matTypes.Add("Wood");
_matTypes.Add("Leather");
_matTypes.Add("Cloth");
_matTypes.Add("Metal");
_matTypes2.Add("Bone");
_matTypes2.Add("Wood");
_matTypes2.Add("Leather");
_matTypes2.Add("Cloth");
_matTypes2.Add("Metal");
currentBuffer = "recBufferList";
if (File.Exists("catalyst.xml"))
{
preLoadCatalyst();
}
if (File.Exists("recipe.xml"))
{
preLoadRecipe();
}
if (File.Exists("wood.xml"))
{
preLoadWood();
}
if (File.Exists("bone.xml"))
{
preLoadBone();
}
if (File.Exists("cloth.xml"))
{
preLoadCloth();
}
if (File.Exists("leather.xml"))
{
preLoadLeather();
}
if (File.Exists("metal.xml"))
{
preLoadMetal();
}
listBox1.DataSource = _type;
listBox2.DataSource = _weapons;
listBox5.DataSource = _cats;
listBox3.DataSource = _bonemats;
listBox4.DataSource = _bonemats2;
listBox7.DataSource = _matTypes;
listBox8.DataSource = _matTypes2;
listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
listBox3.SelectedIndexChanged += new EventHandler(listBox3_SelectedIndexChanged);
listBox4.SelectedIndexChanged += new EventHandler(listBox4_SelectedIndexChanged);
listBox5.SelectedIndexChanged += new EventHandler(listBox5_SelectedIndexChanged);
listBox7.SelectedIndexChanged += new EventHandler(listBox7_SelectedIndexChanged);
listBox8.SelectedIndexChanged += new EventHandler(listBox8_SelectedIndexChanged);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedValue.ToString() == "Weapon")
{
listBox2.DataSource = _weapons;
globalItemType = "Weapon";
}
else if (listBox1.SelectedValue.ToString() == "Armor")
{
listBox2.DataSource = _armor;
globalItemType = "Armor";
}
else if (listBox1.SelectedValue.ToString() == "Item")
{
listBox2.DataSource = _items;
globalItemType = "Item";
}
}
public void preLoadRecipe()
{
string file = "recipe.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
int count = xmlDoc.SelectNodes("/Catalysts/catalyst").Count;
foreach (XmlNode node in xmlDoc.SelectNodes("Recipes/Recipe"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["RecipeName"].InnerText;
string xml_type = node["RecipeType"].InnerText;
string xml_mat1 = node["Material1"].InnerText;
string xml_mat2 = node["Material2"].InnerText;
string xml_dmg = node["DamageValue"].InnerText;
string xml_armor = node["ArmorValue"].InnerText;
if (xml_type == "Weapon" || xml_type == "WEAPON")
{
_weapons.Add(xml_name);
}
if (xml_type == "Armor" || xml_type == "ARMOR")
{
_armor.Add(xml_name);
}
if (xml_type == "Item" || xml_type == "ITEM")
{
_items.Add(xml_name);
}
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_mat1 + "," + xml_mat2 + "," + xml_dmg + "," + xml_armor;
recBufferList.Add(bufferString);
}
}
public void preLoadWood()
{
string file = "wood.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Woods/Wood"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_type = node["Weight"].InnerText;
string xml_aw = node["Thickness"].InnerText;
string xml_v = node["Density"].InnerText;
string xml_mt = node["Purity"].InnerText;
string xml_ft = node["Age"].InnerText;
_woodmats.Add(xml_name);
_woodmats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft;
woodBufferList.Add(bufferString);
}
}
public void preLoadBone()
{
string file = "bone.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Bones/Bone"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_type = node["Weight"].InnerText;
string xml_aw = node["Thickness"].InnerText;
string xml_v = node["Density"].InnerText;
string xml_mt = node["Purity"].InnerText;
string xml_ft = node["Age"].InnerText;
_bonemats.Add(xml_name);
_bonemats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft;
boneBufferList.Add(bufferString);
}
}
public void preLoadCloth()
{
string file = "cloth.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Cloths/Cloth"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_type = node["Weight"].InnerText;
string xml_aw = node["Integrity"].InnerText;
string xml_v = node["Elasticity"].InnerText;
string xml_mt = node["Purity"].InnerText;
string xml_ft = node["Age"].InnerText;
_clothmats.Add(xml_name);
_clothmats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft;
clothBufferList.Add(bufferString);
}
}
public void preLoadLeather()
{
string file = "leather.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Leathers/Leather"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_type = node["Weight"].InnerText;
string xml_aw = node["Integrity"].InnerText;
string xml_v = node["Elasticity"].InnerText;
string xml_mt = node["Purity"].InnerText;
string xml_ft = node["Age"].InnerText;
_leathermats.Add(xml_name);
_leathermats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft;
leatherBufferList.Add(bufferString);
}
}
public void preLoadMetal()
{
string file = "metal.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Metals/Metal"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_type = node["Weight"].InnerText;
string xml_aw = node["Density"].InnerText;
string xml_v = node["Malleability"].InnerText;
string xml_mt = node["Integrity"].InnerText;
string xml_ft = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
_metalmats.Add(xml_name);
_metalmats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft + "," + xml_age;
metalBufferList.Add(bufferString);
}
}
public void preLoadCatalyst()
{
string file = "catalyst.xml";
XmlDocument xmlDoc = new XmlDocument(); //* create an xml document object.
xmlDoc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in xmlDoc.SelectNodes("Catalysts/Catalyst"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["CatalystName"].InnerText;
string xml_type = node["CatalystType"].InnerText;
string xml_aw = node["AtomicWeight"].InnerText;
string xml_v = node["Viscosity"].InnerText;
string xml_mt = node["MeltingTemperature"].InnerText;
string xml_ft = node["FreezingTemperature"].InnerText;
string xml_mbt = node["MolecularBondType"].InnerText;
string xml_hl = node["HalfLife"].InnerText;
_cats.Add(xml_name);
_cats2.Add(xml_name);
bufferString = xml_id + "," + xml_name + "," + xml_type + "," + xml_aw + "," + xml_v + "," + xml_mt + "," + xml_ft + "," + xml_mbt + "," + xml_hl;
catBufferList.Add(bufferString);
}
}
private void listBox7_SelectedIndexChanged(object sender, EventArgs e)
{
string selection = listBox7.SelectedValue.ToString();
if (selection == "Wood")
{
listBox3.DataSource = _woodmats;
}
else if (selection == "Bone")
{
listBox3.DataSource = _bonemats;
}
else if (selection == "Leather")
{
listBox3.DataSource = _leathermats;
}
else if (selection == "Cloth")
{
listBox3.DataSource = _clothmats;
}
else if (selection == "Metal")
{
listBox3.DataSource = _metalmats;
}
primaryMatTypeIndex = selection;
}
private void listBox8_SelectedIndexChanged(object sender, EventArgs e)
{
string selection = listBox8.SelectedValue.ToString();
if (selection == "Wood")
{
listBox4.DataSource = _woodmats2;
}
else if (selection == "Bone")
{
listBox4.DataSource = _bonemats2;
}
else if (selection == "Leather")
{
listBox4.DataSource = _leathermats2;
}
else if (selection == "Cloth")
{
listBox4.DataSource = _clothmats2;
}
else if (selection == "Metal")
{
listBox4.DataSource = _metalmats2;
}
secondaryMatTypeIndex = selection;
}
private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
{
string selection = primaryMatTypeIndex;
string sName = listBox3.SelectedValue.ToString();
if (primaryMatTypeIndex == "Wood")
{
string file = "wood.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Woods/Wood"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_thk = node["Thickness"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat1_ID = Convert.ToInt32(xml_id);
mat1_Name = xml_name;
mat1_Weight = Convert.ToInt32(xml_weight);
mat1_Thickness = Convert.ToInt32(xml_thk);
mat1_Density = Convert.ToInt32(xml_den);
mat1_Purity = Convert.ToInt32(xml_pur);
mat1_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
labelMat1Thickness.Text = xml_thk;
labelMat1Density.Text = xml_den;
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
else if (primaryMatTypeIndex == "Bone")
{
string file = "bone.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Bones/Bone"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_thk = node["Thickness"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat1_ID = Convert.ToInt32(xml_id);
mat1_Name = xml_name;
mat1_Weight = Convert.ToInt32(xml_weight);
mat1_Thickness = Convert.ToInt32(xml_thk);
mat1_Density = Convert.ToInt32(xml_den);
mat1_Purity = Convert.ToInt32(xml_pur);
mat1_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
labelMat1Thickness.Text = xml_thk;
labelMat1Density.Text = xml_den;
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
else if (primaryMatTypeIndex == "Cloth")
{
string file = "cloth.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Cloths/Cloth"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_ela = node["Elasticity"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat1_ID = Convert.ToInt32(xml_id);
mat1_Name = xml_name;
mat1_Weight = Convert.ToInt32(xml_weight);
mat1_Integrity = Convert.ToInt32(xml_int);
mat1_Elasticity = Convert.ToInt32(xml_ela);
mat1_Purity = Convert.ToInt32(xml_pur);
mat1_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
//Add Integrity and Elasticity
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
else if (primaryMatTypeIndex == "Leather")
{
string file = "leather.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Leathers/Leather"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_ela = node["Elasticity"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat1_ID = Convert.ToInt32(xml_id);
mat1_Name = xml_name;
mat1_Weight = Convert.ToInt32(xml_weight);
mat1_Integrity = Convert.ToInt32(xml_int);
mat1_Elasticity = Convert.ToInt32(xml_ela);
mat1_Purity = Convert.ToInt32(xml_pur);
mat1_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
//Add Integrity and Elasticity
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
else if (primaryMatTypeIndex == "Metal")
{
string file = "metal.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Metals/Metal"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_mal = node["Malleability"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat1_ID = Convert.ToInt32(xml_id);
mat1_Name = xml_name;
mat1_Weight = Convert.ToInt32(xml_weight);
//add Malleability
mat1_Integrity = Convert.ToInt32(xml_int);
mat1_Density = Convert.ToInt32(xml_den);
mat1_Purity = Convert.ToInt32(xml_pur);
mat1_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
//Add Malleability
labelMat1Density.Text = xml_den;
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
}
private void listBox4_SelectedIndexChanged(object sender, EventArgs e)
{
string selection = secondaryMatTypeIndex;
string sName = listBox4.SelectedValue.ToString();
if (secondaryMatTypeIndex == "Wood")
{
string file = "wood.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Woods/Wood"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_thk = node["Thickness"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat2_ID = Convert.ToInt32(xml_id);
mat2_Name = xml_name;
mat2_Weight = Convert.ToInt32(xml_weight);
mat2_Thickness = Convert.ToInt32(xml_thk);
mat2_Density = Convert.ToInt32(xml_den);
mat2_Purity = Convert.ToInt32(xml_pur);
mat2_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat2ID.Text = xml_id;
labelMat2Name.Text = xml_name;
labelMat2Weight.Text = xml_weight;
labelMat2Thickness.Text = xml_thk;
labelMat2Density.Text = xml_den;
labelMat2Purity.Text = xml_pur;
labelMat2Age.Text = xml_age;
}
}
}
else if (secondaryMatTypeIndex == "Bone")
{
string file = "bone.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Bones/Bone"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_thk = node["Thickness"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat2_ID = Convert.ToInt32(xml_id);
mat2_Name = xml_name;
mat2_Weight = Convert.ToInt32(xml_weight);
mat2_Thickness = Convert.ToInt32(xml_thk);
mat2_Density = Convert.ToInt32(xml_den);
mat2_Purity = Convert.ToInt32(xml_pur);
mat2_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat1ID.Text = xml_id;
labelMat1Name.Text = xml_name;
labelMat1Weight.Text = xml_weight;
labelMat1Thickness.Text = xml_thk;
labelMat1Density.Text = xml_den;
labelMat1Purity.Text = xml_pur;
labelMat1Age.Text = xml_age;
}
}
}
else if (secondaryMatTypeIndex == "Cloth")
{
string file = "cloth.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Cloths/Cloth"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_ela = node["Elasticity"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat2_ID = Convert.ToInt32(xml_id);
mat2_Name = xml_name;
mat2_Weight = Convert.ToInt32(xml_weight);
mat2_Integrity = Convert.ToInt32(xml_int);
mat2_Elasticity = Convert.ToInt32(xml_ela);
mat2_Purity = Convert.ToInt32(xml_pur);
mat2_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat2ID.Text = xml_id;
labelMat2Name.Text = xml_name;
labelMat2Weight.Text = xml_weight;
//Add Integrity and Elasticity
labelMat2Purity.Text = xml_pur;
labelMat2Age.Text = xml_age;
}
}
}
else if (secondaryMatTypeIndex == "Leather")
{
string file = "leather.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Leathers/Leather"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_ela = node["Elasticity"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat2_ID = Convert.ToInt32(xml_id);
mat2_Name = xml_name;
mat2_Weight = Convert.ToInt32(xml_weight);
mat2_Integrity = Convert.ToInt32(xml_int);
mat2_Elasticity = Convert.ToInt32(xml_ela);
mat2_Purity = Convert.ToInt32(xml_pur);
mat2_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat2ID.Text = xml_id;
labelMat2Name.Text = xml_name;
labelMat2Weight.Text = xml_weight;
//Add Integrity and Elasticity
labelMat2Purity.Text = xml_pur;
labelMat2Age.Text = xml_age;
}
}
}
else if (secondaryMatTypeIndex == "Metal")
{
string file = "metal.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Metals/Metal"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["Name"].InnerText;
string xml_weight = node["Weight"].InnerText;
string xml_int = node["Integrity"].InnerText;
string xml_mal = node["Malleability"].InnerText;
string xml_den = node["Density"].InnerText;
string xml_pur = node["Purity"].InnerText;
string xml_age = node["Age"].InnerText;
mat2_ID = Convert.ToInt32(xml_id);
mat2_Name = xml_name;
mat2_Weight = Convert.ToInt32(xml_weight);
//add Malleability
mat2_Integrity = Convert.ToInt32(xml_int);
mat2_Density = Convert.ToInt32(xml_den);
mat2_Purity = Convert.ToInt32(xml_pur);
mat2_Age = Convert.ToInt32(xml_age);
if (xml_name == sName)
{
labelMat2ID.Text = xml_id;
labelMat2Name.Text = xml_name;
labelMat2Weight.Text = xml_weight;
//Add Malleability
labelMat2Density.Text = xml_den;
labelMat2Purity.Text = xml_pur;
labelMat2Age.Text = xml_age;
}
}
}
}
private void listBox5_SelectedIndexChanged(object sender, EventArgs e)
{
string selection = listBox5.SelectedValue.ToString();
string file = "catalyst.xml";
XmlDocument doc = new XmlDocument(); //* create an xml document object.
doc.Load(file); //* load the XML document from the specified file.
foreach (XmlNode node in doc.SelectNodes("Catalysts/Catalyst"))
{
string xml_id = node["ID"].InnerText;
string xml_name = node["CatalystName"].InnerText;
string xml_type = node["CatalystType"].InnerText;
string xml_awe = node["AtomicWeight"].InnerText;
string xml_vis = node["Viscosity"].InnerText;
string xml_melt = node["MeltingTemperature"].InnerText;
string xml_freeze = node["FreezingTemperature"].InnerText;
string xml_mol = node["MolecularBondType"].InnerText;
string xml_half = node["HalfLife"].InnerText;
cat_ID = Convert.ToInt32(xml_id);
cat_Name = xml_name;
cat_AWeight = Convert.ToInt32(xml_awe);
cat_Viscosity = Convert.ToInt32(xml_vis);
cat_Melt = Convert.ToInt32(xml_melt);
cat_Freeze = Convert.ToInt32(xml_freeze);
cat_Type = xml_type;
cat_Mole = xml_mol;
cat_Half = xml_half;
if (xml_name == selection)
{
labelCatID.Text = xml_id;
labelCatName.Text = xml_name;
labelCatAtomicWeight.Text = xml_awe;
labelCatViscosity.Text = xml_vis;
labelCatMeltingTemperature.Text = xml_melt;
labelCatFreezingTemperature.Text = xml_freeze;
labelCatType.Text = xml_type;
labelCatBondType.Text = xml_mol;
labelCatHalfLife.Text = xml_half;
}
}
}
private void label21_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
DetermineType();
CalculateSpeed();
CalculateDamage();
CalculateDurability();
}
private void DetermineType()
{
labelItemType.Text = globalItemType;
}
/*
* mat1_Weight;
mat1_Thickness;
mat1_Density;
mat1_Purity;
mat1_Age;
mat1_Integrity;
mat1_Elasticity;
mat2_Weight;
mat2_Thickness;
mat2_Density;
mat2_Purity;
mat2_Age;
mat2_Integrity;
mat2_Elasticity;
cat_AWeight;
cat_Viscosity;
cat_Melt;
cat_Freeze;
cat_Type;
cat_Mole;
cat_Half;
* */
private void CalculateDamage()
{
int baseValue = 100 / globalItemSpeed;
int damage = baseValue + (cat_Melt + cat_Freeze);
labelItemDamage.Text = Convert.ToString(damage);
}
private void CalculateSpeed()
{
int itemWeight = mat1_Weight + mat2_Weight;
if (cat_Mole == "Single")
{
int speed = itemWeight + 1;
string speed_final = Convert.ToString(speed);
labelItemSpeed.Text = speed_final;
globalItemSpeed = speed;
}
else if (cat_Mole == "Double")
{
int speed = itemWeight + 2;
string speed_final = Convert.ToString(speed);
labelItemSpeed.Text = speed_final;
globalItemSpeed = speed;
}
}
private void CalculateDurability()
{
int baseAge = mat1_Age + mat2_Age/2;
int age = baseAge / (((mat1_Purity + mat2_Purity) / 2)/((mat1_Integrity + mat2_Integrity)/2));
labelItemDurability.Text = Convert.ToString(age);
}
}
}