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; } }
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"); } }
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>())); }
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(); }
public ImportRules(StructCollection.Profile profile) { InitializeComponent(); this.profile = profile; }