示例#1
0
        public static void ReorderRules(List <string> rule_name_order)
        {
            StructCollection.Profile updated_profile = GetActiveProfile();
            updated_profile.rule_names = rule_name_order;
            int profile_index = profiles.FindIndex(x => x.profile_name == updated_profile.profile_name);

            if (profile_index < 0)
            {
                profiles.Add(updated_profile);
            }
            else
            {
                profiles[profile_index] = updated_profile;
            }
        }
示例#2
0
        public static void AddRuleToProfile(StructCollection.Rule rule, string profile_name)
        {
            EnsureFileLoaded();
            int profile_index = profiles.FindIndex(x => x.profile_name == profile_name);

            if (profile_index < 0)
            {
                return;
            }
            StructCollection.Profile updated_profile = profiles[profile_index];
            updated_profile.rule_names.Insert(0, rule.rule_name);
            profiles[profile_index] = updated_profile;
            if (profile_name != "Default")
            {
                AddRuleToProfile(rule, "Default");
            }
        }
示例#3
0
 public static StructCollection.Profile GetProfile(string profile_name)
 {
     EnsureFileLoaded();
     StructCollection.Profile profile = profiles.Find(x => x.profile_name == profile_name);
     return(profile ?? new StructCollection.Profile(profile_name, new List <string>()));
 }
示例#4
0
        private static void LoadXMLFile(string file)
        {
            rules          = new List <StructCollection.Rule>();
            profiles       = new List <StructCollection.Profile>();
            active_profile = "Default";

            if (!File.Exists(file))
            {
                return;
            }
            XmlReader xml = XmlReader.Create(new FileStream(file, FileMode.Open), new XmlReaderSettings()
            {
                CloseInput = true
            });

            try {
                while (xml != null)
                {
                    if (xml.IsStartElement())
                    {
                        if (xml.Name == "rules")
                        {
                            xml.Read();
                            while (true)
                            {
                                if (xml.IsStartElement())
                                {
                                    if (xml.Name == "rule")
                                    {
                                        StructCollection.Rule rule = new StructCollection.Rule("", new StructCollection.ResultCollection(), -1, -1, new List <StructCollection.Mod>(), new List <StructCollection.Die>(), Color.LightGray);
                                        rule.LoadXML(ref xml);
                                        rules.Add(rule);
                                        continue;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                if (!xml.Read())
                                {
                                    break;
                                }
                            }
                            continue;
                        }
                        else if (xml.Name == "profiles")
                        {
                            active_profile = xml["active_profile"];
                            xml.Read();
                            while (true)
                            {
                                if (xml.IsStartElement())
                                {
                                    if (xml.Name == "profile")
                                    {
                                        StructCollection.Profile new_profile = new StructCollection.Profile();
                                        new_profile.LoadXML(ref xml);
                                        profiles.Add(new_profile);
                                        continue;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                if (!xml.Read())
                                {
                                    break;
                                }
                            }
                            continue;
                        }
                    }
                    if (!xml.Read())
                    {
                        break;
                    }
                }
            }
            catch {
                xml.Close();
                return;
            }
            xml.Close();
        }
示例#5
0
 public ImportRules(StructCollection.Profile profile)
 {
     InitializeComponent();
     this.profile = profile;
 }