public ColorFromImageViewModel() { _imagesource = GDIManager.CreateImageSourceFromImage(Properties.Resources.rgbcolor); _selectedColor = new System.Windows.Media.Color() { R = 255, G = 255, B = 255 }; }
static LightImageLibrary() { _images = new Dictionary <string, Dictionary <string, ImageSource> >(); _images.Add("Default", new Dictionary <string, ImageSource>() { { "on", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_on) }, { "off", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_off) }, { "unr", GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_unr) }, }); }
static LightImageLibrary() { _images = new Dictionary <string, Dictionary <bool, ImageSource> >(); _images.Add("DefaultHUE", new Dictionary <bool, ImageSource>() { { true, GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_on) }, { false, GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLight_off) }, }); _images.Add("DefaultLIFX", new Dictionary <bool, ImageSource>() { { true, GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLIFX_on) }, { false, GDIManager.CreateImageSourceFromImage(Properties.Resources.DefaultLIFX_off) }, }); LoadLightsImages(); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject obj = serializer.Deserialize <JObject>(reader); Rule newRule = new Rule(); if (obj["created"] != null) { newRule.created = obj["created"].Value <string>(); } if (obj["lasttriggered"] != null) { newRule.lasttriggered = obj["lasttriggered"].Value <string>(); } if (obj["owner"] != null) { newRule.owner = obj["owner"].Value <string>(); } if (obj["status"] != null) { newRule.status = obj["status"].Value <string>(); } if (obj["name"] != null) { newRule.name = obj["name"].Value <string>(); } if (obj["timestriggered"] != null) { newRule.timestriggered = obj["timestriggered"].Value <int>(); } if (obj["actions"] != null) { newRule.actions = obj["actions"].ToObject <RuleActionCollection>(); } if (obj["conditions"] != null) { newRule.conditions = obj["conditions"].ToObject <RuleConditionCollection>(); } newRule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.rules); return(newRule); }
/// <summary> /// Toggle the state of an object on and off (Light or group) /// </summary> /// <param name="bridge">Bridge to get the information from.</param> /// <param name="obj">Object to toggle.</param> /// <param name="tt">Transition Time (Optional)</param> /// <param name="dimvalue">Value for the dim (Optional)</param> /// <param name="state">New state at toggle (Optional)</param> /// <returns>The new image of the object.</returns> public async Task <ImageSource> ToggleObjectOnOffStateAsyncTask(IHueObject obj, ushort?tt = null, byte?dimvalue = null, IBaseProperties state = null) { ImageSource hr = null; if (obj is Light) { Light bresult = await GetObjectAsync <Light>(obj.Id); if (bresult == null) { return(null); } Light currentState = bresult; if (currentState.state.reachable == false && currentState.manufacturername != "OSRAM") { hr = GetImageForLight(LightImageState.Unr, currentState.modelid, currentState.config.archetype); } else { if (currentState.state.@on == true) { log.Debug("Toggling light state : OFF"); bool bsetlightstate = await SetStateAsyncTask(new State { @on = false, transitiontime = tt }, obj.Id); if (bsetlightstate) { hr = GetImageForLight(LightImageState.Off, currentState.modelid, currentState.config.archetype); } } else { log.Debug("Toggling light state : ON"); State newstate; if (WinHueSettings.settings.SlidersBehavior == 0) { newstate = new State() { on = true, transitiontime = tt };; if (!WinHueSettings.settings.UseLastBriState && bresult.state.bri != null) { newstate.bri = dimvalue ?? WinHueSettings.settings.DefaultBriLight; } } else { newstate = state as State ?? new State(); newstate.on = true; newstate.transitiontime = tt; } bool bsetlightstate = await SetStateAsyncTask(newstate, obj.Id); if (bsetlightstate) { hr = GetImageForLight(LightImageState.On, currentState.modelid, currentState.config.archetype); } } } } else { Group bresult = await GetObjectAsync <Group>(obj.Id); if (bresult == null) { return(null); } Group currentstate = bresult; if (currentstate.action.@on == true) { log.Debug("Toggling group state : ON"); bool bsetgroupstate = await SetStateAsyncTask(new Action { @on = false, transitiontime = tt }, obj.Id); if (bsetgroupstate) { hr = GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOff_Large); } } else { log.Debug("Toggling group state : OFF"); Action newaction; if (WinHueSettings.settings.SlidersBehavior == 0) { newaction = new Action() { on = true, transitiontime = tt }; if (!WinHueSettings.settings.UseLastBriState) { newaction.bri = dimvalue ?? WinHueSettings.settings.DefaultBriGroup; } } else { newaction = state as Action ?? new Action(); newaction.on = true; newaction.transitiontime = tt; } bool bsetgroupstate = await SetStateAsyncTask(newaction, obj.Id); if (bsetgroupstate) { hr = GDIManager.CreateImageSourceFromImage(Properties.Resources.HueGroupOn_Large); } } } return(hr); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { serializer.DateParseHandling = DateParseHandling.None; serializer.DateFormatHandling = DateFormatHandling.IsoDateFormat; serializer.DateFormatString = "yyyy-MM-dd"; reader.DateFormatString = "yyyy-MM-dd"; reader.DateParseHandling = DateParseHandling.None; JObject obj = serializer.Deserialize <JObject>(reader); Schedule newSchedule = new Schedule(); if (obj["name"] != null) { newSchedule.name = obj["name"].Value <string>(); } if (obj["created"] != null) { newSchedule.created = obj["created"].Value <string>(); } if (obj["autodelete"] != null) { newSchedule.autodelete = obj["autodelete"].Value <bool>(); } if (obj["description"] != null) { newSchedule.description = obj["description"].Value <string>(); } if (obj["localtime"] != null) { newSchedule.localtime = obj["localtime"].Value <string>(); if (newSchedule.localtime.Contains(" ")) { newSchedule.localtime = newSchedule.localtime.Replace(" ", "T"); // Bypass a stupid function of JSON.Net that parses dates } } else { if (obj["time"] != null) { newSchedule.localtime = obj["time"]?.Value <string>(); } } if (obj["recycle"] != null) { newSchedule.recycle = obj["recycle"].Value <bool>(); } if (obj["starttime"] != null) { newSchedule.starttime = obj["starttime"].Value <string>(); } if (obj["status"] != null) { newSchedule.status = obj["status"].Value <string>(); } if (obj["command"] == null) { return(newSchedule); } newSchedule.command = new Command(); if (obj["command"]["address"] != null) { newSchedule.command.address = obj["command"]["address"].ToObject <HueAddress>(); } if (obj["command"]["body"] != null) { newSchedule.command.body = JsonConvert.SerializeObject(obj["command"]["body"]); } if (obj["command"]["method"] != null) { newSchedule.command.method = obj["command"]["method"].Value <string>(); } if (newSchedule.localtime == null) { return(newSchedule); } if (newSchedule.localtime.Contains("PT")) { newSchedule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.timer_clock); } else if (newSchedule.localtime.Contains("W")) { newSchedule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.stock_alarm); } else if (newSchedule.localtime.Contains("T")) { newSchedule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.SchedulesLarge); } else { newSchedule.Image = GDIManager.CreateImageSourceFromImage(Properties.Resources.schedules); } return(newSchedule); }