public void OpenSendOnClick() { if (ty_ip.text != "" && ty_port.text == "" && ty_order.text == "") { PJLinkConnection c = new PJLinkConnection(ty_ip.text); PowerCommand pc = new PowerCommand(Power.ON); c.sendCommandAsync(pc, OpenProjection); } else if (ty_ip.text != "" && ty_port.text != "" && ty_order.text == "") { PJLinkConnection c = new PJLinkConnection(ty_ip.text, int.Parse(ty_port.text)); PowerCommand pc = new PowerCommand(Power.ON); c.sendCommandAsync(pc, OpenProjection); } else if (ty_ip.text != "" && ty_port.text == "" && ty_order.text != "") { PJLinkConnection c = new PJLinkConnection(ty_ip.text, ty_order.text); PowerCommand pc = new PowerCommand(Power.ON); c.sendCommandAsync(pc, OpenProjection); } else if (ty_ip.text != "" && ty_port.text == "" && ty_order.text == "") { PJLinkConnection c = new PJLinkConnection(ty_ip.text, int.Parse(ty_port.text), ty_order.text); PowerCommand pc = new PowerCommand(Power.ON); c.sendCommandAsync(pc, OpenProjection); } }
public void Open() { while (FacilityControl.Instance.sceneDatas[scene_num].projections.Count == 0) { scene_num++; } if ((type == ProjectionType.ONE && current_scene == scene_num) || type == ProjectionType.ALL) { PJLinkConnection c = new PJLinkConnection(FacilityControl.Instance.sceneDatas[scene_num].projections[projections_num].ip); PowerCommand pc = new PowerCommand(power); c.sendCommandAsync(pc, OpenProjection); } else { } }
public static void Run() { var simpleSoundBar = SimpleSoundBar.Singleton; var powerCommand = new PowerCommand(simpleSoundBar); var muteCommand = new MuteCommand(simpleSoundBar); var increaseVolumeCommand = new IncreaseVolumeCommand(simpleSoundBar); var decreaseVolumeCommand = new DecreaseVolumeCommand(simpleSoundBar); var controller = new SimpleSoundBarController(powerCommand, muteCommand, increaseVolumeCommand, decreaseVolumeCommand); controller.Mute(); // should result in message "Turn power on first." controller.Power(); controller.IncreaseVolume(); controller.IncreaseVolume(); controller.Mute(); controller.Mute(); controller.DecreaseVolume(); controller.Power(); }
private void btnAdd_Click(object sender, EventArgs e) { int indexLamp = lbLamps.SelectedIndex; int indexAction = lbActions.SelectedIndex; if (indexLamp > -1 && indexAction > -1) { Lamp l = (Lamp)lbLamps.Items[indexLamp]; Object o = lbActions.Items[indexAction]; if (o is Power) { PowerCommand pc = new PowerCommand(l, Convert.ToBoolean(o)); cal.AddAnimation(pc); } else if (o is Color) { AnimationCommand ac = new AnimationCommand(l, (Color)o); cal.AddAnimation(ac); } } }
/// <summary> /// Handles commands for the Denon published to MQTT. /// </summary> /// <param name="e">Event args.</param> protected override async void Mqtt_MqttMsgPublishReceived(MqttApplicationMessageReceivedEventArgs e) { var message = e.ApplicationMessage.ConvertPayloadToString(); _log.LogInformation("MQTT message received for topic " + e.ApplicationMessage.Topic + ": " + message); var commandType = e.ApplicationMessage.Topic.Replace(TopicRoot + "/controls/", string.Empty).Replace("/set", string.Empty); Command command = null; if (commandType == "power") { command = new PowerCommand { Value = message } } ; if (commandType == "volume") { command = new VolumeCommand { Value = message } } ; if (commandType == "mute") { command = new MuteCommand { Value = message } } ; if (commandType == "input") { command = new InputCommand { Value = message } } ; if (commandType == "surroundMode") { command = new SurroundModeCommand { Value = message } } ; if (commandType == "tunerFrequency") { command = new TunerFrequencyCommand { Value = message } } ; if (commandType == "tunerMode") { command = new TunerModeCommand { Value = message } } ; if (commandType.StartsWith("zone")) { if (int.TryParse(commandType.Substring(4, 1), out int zoneId)) { if (commandType == $"zone{zoneId}Power") { command = new ZonePowerCommand { Value = message, ZoneId = zoneId } } ; if (commandType == $"zone{zoneId}Volume") { command = new ZoneVolumeCommand { Value = message, ZoneId = zoneId } } ; if (commandType == $"zone{zoneId}Mute") { command = new ZoneMuteCommand { Value = message, ZoneId = zoneId } } ; if (commandType == $"zone{zoneId}Input") { command = new ZoneInputCommand { Value = message, ZoneId = zoneId } } ; } } if (command != null) { await _client.SendCommandAsync(command) .ConfigureAwait(false); } }