Example #1
0
        private void UpdateSelectedKit()
        {
            KitItem kitItem = GetSelectedKitItem();

            if (kitItem != null)
            {
                try
                {
                    comboBoxID.SelectedValue = kitItem.Id;
                }
                catch { }
                tbAmount.Value = kitItem.Amount;
            }
        }
Example #2
0
        private void ApplySelectedKitItem()
        {
            KitItem kitItem = GetSelectedKitItem();

            if (kitItem != null)
            {
                kitItem.Id = comboBoxID.SelectedValue as String;
                try
                {
                    kitItem.Amount = (int)tbAmount.Value;
                }
                catch
                {
                    kitItem.Amount = 1;
                }
                RefreshSelectedKit();
            }
        }
Example #3
0
        //public static Kit GetKitFromName(String file, String filter)
        //{
        //    try
        //    {
        //        Kit kit = new Kit();
        //        XmlDocument doc = new XmlDocument();
        //        doc.Load(file);
        //        XmlNode root = doc["root"];
        //        XmlNode kits = root["kits"];
        //        foreach (XmlNode n in kits)
        //        {
        //            int level = 0;
        //            string name = null;
        //            bool fixedGroup = false;
        //            try
        //            {
        //                name = n.Attributes["name"].Value;
        //            }
        //            catch{ }
        //            try
        //            {
        //                string value = n.Attributes["level"].Value;
        //                level = Convert.ToInt32(value);
        //            }
        //            catch { }
        //            try
        //            {
        //                fixedGroup = Convert.ToBoolean(n.Attributes["fixedgroup"].Value);
        //            }
        //            catch { }
        //            if (String.IsNullOrEmpty(name) || filter != name)
        //                continue;
        //            kit.Name = name;
        //            kit.Level = level;
        //            kit.FixedGroup = fixedGroup;
        //            foreach (XmlNode i in n)
        //            {
        //                string id = null;
        //                int amount = 1;
        //                try
        //                {
        //                    id = i.Attributes["id"].Value;
        //                }
        //                catch
        //                {
        //                    continue;
        //                }
        //                try
        //                {
        //                    amount = int.Parse(i.Attributes["amount"].Value);
        //                }
        //                catch
        //                {
        //                }
        //                KitItem item = new KitItem(id, amount);
        //                kit.Items.Add(item);
        //            }
        //            return kit;
        //        }
        //        return null;
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}
        public static List<Kit> GetKitlist(String file)
        {
            List<Kit> kitlist = new List<Kit>();
            try
            {

                XmlDocument doc = new XmlDocument();
                doc.Load(file);

                XmlNode root = doc["root"];
                XmlNode kits = root["kits"];

                foreach (XmlNode n in kits)
                {
                    int level = 0;
                    string name = null;
                    bool fixedGroup = false;
                    try
                    {
                        name = n.Attributes["name"].Value;
                    }
                    catch { }
                    try
                    {
                        string value = n.Attributes["level"].Value;
                        level = int.Parse(value);
                    }
                    catch { }
                    try
                    {
                        fixedGroup = Convert.ToBoolean(n.Attributes["fixedgroup"].Value);
                    }
                    catch { }

                    Kit kit = new Kit();

                    kit.Name = name;
                    kit.Level = level;
                    kit.FixedGroup = fixedGroup;

                    foreach (XmlNode i in n)
                    {
                        string id = null;
                        int amount = 1;
                        try
                        {
                            id = i.Attributes["id"].Value;
                        }
                        catch
                        {
                            continue;
                        }
                        try
                        {
                            amount = int.Parse(i.Attributes["amount"].Value);
                        }
                        catch
                        {

                        }

                        KitItem item = new KitItem(id, amount);
                        kit.Items.Add(item);
                    }
                    kitlist.Add(kit);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return kitlist;
        }
Example #4
0
        //public static Kit GetKitFromName(String file, String filter)
        //{
        //    try
        //    {
        //        Kit kit = new Kit();

        //        XmlDocument doc = new XmlDocument();
        //        doc.Load(file);

        //        XmlNode root = doc["root"];
        //        XmlNode kits = root["kits"];

        //        foreach (XmlNode n in kits)
        //        {
        //            int level = 0;
        //            string name = null;
        //            bool fixedGroup = false;
        //            try
        //            {
        //                name = n.Attributes["name"].Value;
        //            }
        //            catch{ }
        //            try
        //            {
        //                string value = n.Attributes["level"].Value;
        //                level = Convert.ToInt32(value);
        //            }
        //            catch { }

        //            try
        //            {
        //                fixedGroup = Convert.ToBoolean(n.Attributes["fixedgroup"].Value);
        //            }
        //            catch { }

        //            if (String.IsNullOrEmpty(name) || filter != name)
        //                continue;

        //            kit.Name = name;
        //            kit.Level = level;
        //            kit.FixedGroup = fixedGroup;

        //            foreach (XmlNode i in n)
        //            {
        //                string id = null;
        //                int amount = 1;
        //                try
        //                {
        //                    id = i.Attributes["id"].Value;
        //                }
        //                catch
        //                {
        //                    continue;
        //                }
        //                try
        //                {
        //                    amount = int.Parse(i.Attributes["amount"].Value);
        //                }
        //                catch
        //                {

        //                }

        //                KitItem item = new KitItem(id, amount);
        //                kit.Items.Add(item);
        //            }
        //            return kit;
        //        }
        //        return null;
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}

        public static List <Kit> GetKitlist(String file)
        {
            List <Kit> kitlist = new List <Kit>();

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(file);

                XmlNode root = doc["root"];
                XmlNode kits = root["kits"];

                foreach (XmlNode n in kits)
                {
                    int    level      = 0;
                    string name       = null;
                    bool   fixedGroup = false;
                    try
                    {
                        name = n.Attributes["name"].Value;
                    }
                    catch { }
                    try
                    {
                        string value = n.Attributes["level"].Value;
                        level = int.Parse(value);
                    }
                    catch { }
                    try
                    {
                        fixedGroup = Convert.ToBoolean(n.Attributes["fixedgroup"].Value);
                    }
                    catch { }

                    Kit kit = new Kit();

                    kit.Name       = name;
                    kit.Level      = level;
                    kit.FixedGroup = fixedGroup;

                    foreach (XmlNode i in n)
                    {
                        string id     = null;
                        int    amount = 1;
                        try
                        {
                            id = i.Attributes["id"].Value;
                        }
                        catch
                        {
                            continue;
                        }
                        try
                        {
                            amount = int.Parse(i.Attributes["amount"].Value);
                        }
                        catch
                        {
                        }

                        KitItem item = new KitItem(id, amount);
                        kit.Items.Add(item);
                    }
                    kitlist.Add(kit);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(kitlist);
        }