public AutolootViewModel() { string constraintsFile = Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Data", "Properties.json"); if (!File.Exists(constraintsFile)) { return; } JsonSerializer serializer = new JsonSerializer(); using (StreamReader sr = new StreamReader(constraintsFile)) { using (JsonTextReader reader = new JsonTextReader(sr)) { PropertyEntry[] constraints = serializer.Deserialize <PropertyEntry[]>(reader); foreach (PropertyEntry constraint in constraints) { Constraints.AddSorted(constraint); } } } IncomingPacketHandlers.CorpseContainerDisplayEvent += OnCorpseContainerDisplayEvent; }
public EntityCollectionFilterControl() { InitializeComponent(); string constraintsFile = Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Data", "Properties.json"); if (!File.Exists(constraintsFile)) { return; } JsonSerializer serializer = new JsonSerializer(); using (StreamReader sr = new StreamReader(constraintsFile)) { using (JsonTextReader reader = new JsonTextReader(sr)) { PropertyEntry[] constraints = serializer.Deserialize <PropertyEntry[]>(reader); foreach (PropertyEntry constraint in constraints) { Constraints.AddSorted(constraint); } } } Items.Add(new EntityCollectionFilter { Constraint = Constraints.FirstOrDefault() }); }
public EntityCollectionFilterControl() { InitializeComponent(); string constraintsFile = Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Data", "Properties.json"); if (!File.Exists(constraintsFile)) { return; } JsonSerializer serializer = new JsonSerializer(); using (StreamReader sr = new StreamReader(constraintsFile)) { using (JsonTextReader reader = new JsonTextReader(sr)) { PropertyEntry[] constraints = serializer.Deserialize <PropertyEntry[]>(reader); foreach (PropertyEntry constraint in constraints) { Constraints.AddSorted(constraint); } } } if (File.Exists(_propertiesFileCustom)) { LoadCustomProperties(); } if (File.Exists(Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "EntityViewer.json"))) { try { serializer = new JsonSerializer(); using (JsonTextReader jtr = new JsonTextReader(new StreamReader( Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "EntityViewer.json")))) { EntityCollectionFilter[] entries = serializer.Deserialize <EntityCollectionFilter[]>(jtr); if (entries != null && entries.Length > 0) { ResetCommand?.Execute(null); Items.Clear(); foreach (EntityCollectionFilter entry in entries) { PropertyEntry constraint = Constraints.FirstOrDefault(c => c.Name == entry.Constraint.Name); if (constraint != null) { Items.Add(new EntityCollectionFilter { Constraint = constraint, Operator = entry.Operator, Value = entry.Value }); } } } } } catch (Exception e) { MessageBox.Show(e.Message, Strings.Error); } } else { Items.Add(new EntityCollectionFilter { Constraint = Constraints.FirstOrDefault() }); } }