public bool DeleteThingWrapper(OWLOSThingWrapper ThingWrapper) { foreach (OWLOSConnection connection in ThingWrapper.Thing.config.connections) { connection.enable = false; } config.ThingsConfig.Remove(ThingWrapper.Thing.config); OWLOSThingWrappers.Remove(ThingWrapper); OnDeleteThingWrapper?.Invoke(ThingWrapper, new EventArgs()); return(true); }
public OWLOSThingWrapper CreateThingWrapper() { OWLOSThingConfig _OWLOSThingConfig = CreateThingConnection(); OWLOSThingWrapper ThingWrapper = new OWLOSThingWrapper(this) { Thing = new OWLOSThing(_OWLOSThingConfig) }; OWLOSThingWrappers.Add(ThingWrapper); NewThing(new OWLOSThingWrapperEventArgs(ThingWrapper)); return(ThingWrapper); }
public void Load() { if (File.Exists("config.json")) { string JSONConfig = File.ReadAllText("config.json"); config = JsonConvert.DeserializeObject <ThingsManagerConfig>(JSONConfig); } else //reset config { CreateThingConnection(); } //Save each time before development - add new fields to JSON Save(); foreach (OWLOSThingConfig _OWLOSThingConfig in config.ThingsConfig) { OWLOSThingWrapper ThingWrapper = new OWLOSThingWrapper(this) { Thing = new OWLOSThing(_OWLOSThingConfig) }; OWLOSThingWrappers.Add(ThingWrapper); NewThing(new OWLOSThingWrapperEventArgs(ThingWrapper)); } }
public OWLOSThingWrapperEventArgs(OWLOSThingWrapper ThingWrapper) { this.ThingWrapper = ThingWrapper; }