Пример #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog bleh = new OpenFileDialog();

            string path = Directory.GetCurrentDirectory().ToString() + "\\Archers\\";//".";//"./Archers";

            bleh.InitialDirectory = path;
            bleh.ShowDialog();

            cArcher tmpArcher = new cArcher();

            if (bleh.FileName != "")
            {
                tmpArcher = tmpArcher.GetArcher(bleh.FileName);

                //MessageBox.Show(tmpArcher.Name + " is a " + tmpArcher.Gender + " who is " + tmpArcher.Handiness + " who was born " + tmpArcher.DoB);
                //tmpArcher = tmpArcher.GetArcher(path);
                comboBoxBows.Text         = tmpArcher.CompoundBow;
                txtUsrName.Text           = tmpArcher.Name;
                txtUsrDrawLength.Text     = tmpArcher.DrawLength;
                txtUsrDrawWeight.Text     = tmpArcher.DrawWeight;
                dateTimePickerUsrAge.Text = tmpArcher.DoB;
                comboBoxUsrGender.Text    = tmpArcher.Gender;
                comboBoxHandiness.Text    = tmpArcher.Handiness;
                txtUsrHeight.Text         = tmpArcher.Height;
                txtUsrWeight.Text         = tmpArcher.Weight;
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Calculate();

            cArcher  tmpArcher = new cArcher();
            DateTime DoB       = dateTimePickerUsrAge.Value;

            tmpArcher.Name        = txtUsrName.Text;
            tmpArcher.Handiness   = comboBoxHandiness.Text;
            tmpArcher.DrawWeight  = txtUsrDrawWeight.Text;
            tmpArcher.DrawLength  = txtUsrDrawLength.Text;
            tmpArcher.CompoundBow = comboBoxBows.Text;
            tmpArcher.Weight      = txtUsrWeight.Text;
            tmpArcher.Height      = txtUsrHeight.Text;
            tmpArcher.DoB         = Convert.ToString(DoB.ToShortDateString());
            tmpArcher.Gender      = comboBoxUsrGender.Text;

            if (tmpArcher.Name != "")
            {
                if (tmpArcher.SaveArcher(tmpArcher))
                {
                    MessageBox.Show(tmpArcher.Name + " has been saved.");
                }
                else
                {
                    MessageBox.Show("An Error has occured.");
                }
            }
            else
            {
                MessageBox.Show("Archer Name cannot be blank.");
                txtUsrName.Focus();
            }
        }
Пример #3
0
        /// <summary>
        /// Checks to see if the archer is properly configured
        /// </summary>
        /// <returns>True if all is good.</returns>
        private bool CheckArcher()
        {
            frmArcheryWorx tmpArchery = (frmArcheryWorx)this.MdiParent;

            MyArcher = tmpArchery.GetArcher();
            string path = Directory.GetCurrentDirectory().ToString() + "\\Archers\\" + MyArcher + ".xml";

            cArcher tmpArcher = new cArcher();

            //MessageBox.Show(path);
            if (path != "")
            {
                tmpArcher = tmpArcher.GetArcher(path);
                try
                {
                    MyDrawDistance = Convert.ToDouble(tmpArcher.DrawLength);
                    MyDrawWeight   = Convert.ToDouble(tmpArcher.DrawWeight);
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #4
0
        public cArcher GetArcher(string xmlUrl)
        {
            if (xmlUrl.Length < 15)
            {
                if (xmlUrl.Substring(xmlUrl.Length - 4) != ".xml")
                {
                    xmlUrl = xmlUrl + ".xml";
                }

                if (xmlUrl.Length < 9)
                {
                    //if (xmlUrl.Substring(0, 9) != "./Archers/")
                    xmlUrl = "./Archers/" + xmlUrl;
                }
                else
                {
                    if (xmlUrl.Substring(0, 9) != "./Archers/")
                    {
                        xmlUrl = "./Archers/" + xmlUrl;
                    }
                }
            }

            cArcher   tmpArcher = new cArcher();
            XDocument doc       = XDocument.Load(xmlUrl);

            var data = from item in doc.Descendants("Archer")
                       select new
            {
                Name       = item.Element("Name").Value,
                Handiness  = item.Element("Handiness").Value,
                DrawLength = item.Element("DrawLength").Value,
                DrawWeight = item.Element("DrawWeight").Value,
                Weight     = item.Element("Weight").Value,
                Height     = item.Element("Height").Value,
                Bow        = item.Element("CompoundBow").Value,
                DoB        = item.Element("DoB").Value,
                Gender     = item.Element("Gender").Value,
            };

            foreach (var p in data)
            {
                tmpArcher.Name        = p.Name;
                tmpArcher.Handiness   = p.Handiness;
                tmpArcher.DrawLength  = p.DrawLength;
                tmpArcher.DrawWeight  = p.DrawWeight;
                tmpArcher.Weight      = p.Weight;
                tmpArcher.Height      = p.Height;
                tmpArcher.CompoundBow = p.Bow;
                tmpArcher.DoB         = p.DoB;
                tmpArcher.Gender      = p.Gender;
            }

            return(tmpArcher);
        }
Пример #5
0
        public bool SaveArcher(cArcher tmpArcher)
        {
            XDocument doc = new XDocument(
                new XDeclaration("1.0", "utf-8", "yes"),
                new XComment("ArcheryWorx BETA V1"),
                new XElement("Archer",
                             new XElement("Name", tmpArcher.Name),
                             new XElement("Handiness", tmpArcher.Handiness),
                             new XElement("DrawLength", tmpArcher.DrawLength),
                             new XElement("DrawWeight", tmpArcher.DrawWeight),
                             new XElement("Weight", tmpArcher.Weight),
                             new XElement("Height", tmpArcher.Height),
                             new XElement("CompoundBow", tmpArcher.CompoundBow),
                             new XElement("DoB", tmpArcher.DoB),
                             new XElement("Gender", tmpArcher.Gender)));

            doc.Save("./Archers/" + tmpArcher.Name + ".xml");
            return(true);
        }
Пример #6
0
        private void CheckArcher()
        {
            frmArcheryWorx tmpArchery = (frmArcheryWorx)this.MdiParent;
            string         MyArcher   = tmpArchery.GetArcher();
            string         path       = Directory.GetCurrentDirectory().ToString() + "\\Archers\\" + MyArcher + ".xml";

            cArcher tmpArcher = new cArcher();

            //MessageBox.Show(path);
            if (path != "")
            {
                tmpArcher          = tmpArcher.GetArcher(path);
                lblName.Text       = tmpArcher.Name;
                lblDrawLength.Text = tmpArcher.DrawLength;
                lblDrawWeight.Text = tmpArcher.DrawWeight;
                lblDoB.Text        = tmpArcher.DoB;
                lblGender.Text     = tmpArcher.Gender;
                lblHandiness.Text  = tmpArcher.Handiness;
            }
        }
Пример #7
0
        private void BowSearch_Load(object sender, EventArgs e)
        {
            List <string> tmpList = new List <string>();

            cCompoundBowTools cBowTools = new cCompoundBowTools();

            tmpList = cBowTools.GetBows();
            //--------------------------------------------------------------------------------------------------------------------------------------------------
            for (int i = 0; i < tmpList.Count; i++)
            {
                listBoxSysBows.Items.Add(tmpList[i]);
            }
            //--------------------------------------------------------------------------------------------------------------------------------------------------

            listBoxSysBows.Items.Clear();
            for (int i = 0; i < tmpList.Count; i++)
            {
                listBoxSysBows.Items.Add(tmpList[i]);
            }

            lblCount.Text = tmpList.Count.ToString() + " Bows";

            frmArcheryWorx tmpArchery = (frmArcheryWorx)this.MdiParent;

            MyArcher = tmpArchery.GetArcher();
            string path = Directory.GetCurrentDirectory().ToString() + "\\Archers\\" + MyArcher + ".xml";

            cArcher tmpArcher = new cArcher();

            //MessageBox.Show(path);
            if (path != "")
            {
                tmpArcher      = tmpArcher.GetArcher(path);
                MyDrawDistance = Convert.ToDouble(tmpArcher.DrawLength);
                MyDrawWeight   = Convert.ToDouble(tmpArcher.DrawWeight);
            }
            txtUsrDrawLength.Text = MyDrawDistance.ToString();
            txtUsrDrawWeight.Text = MyDrawWeight.ToString();
        }