public override void InstallTelegramHandlers(telegram.Service telegram) { onkyoMenu = new Menu(title: "Onkyo", afterMenuText: () => $"{receiver.currentSong.index}. {receiver.currentSong.title} ({receiver.currentSong.album} by {receiver.currentSong.artist})"); Menu power = new Menu(title: "Power", parent: onkyoMenu); power.Add(new Menu(title: "On", callback: () => Power = true)); power.Add(new Menu(title: "Off", callback: () => Power = false)); onkyoMenu.Add(new Menu(title: "Next", callback: () => receiver.Next())); onkyoMenu.Add(new Menu(title: "Previous", callback: () => receiver.Prev())); Menu inputMenu = new Menu(title: "Input", parent: onkyoMenu, afterMenuText: () => receiver.Input); foreach (var i in receiver.getInputs()) { new Menu(title: i, parent: inputMenu, callback: () => { Input = i; }); } Menu volumeMenu = new Menu(title: "Volume", parent: onkyoMenu, afterMenuText: () => "Current volume: " + receiver.Volume); new Menu(title: "Down", parent: volumeMenu, callback: () => { return("Current volume: " + --receiver.Volume); }); new Menu(title: "Up", parent: volumeMenu, callback: () => { return("Current volume: " + ++receiver.Volume); }); new Menu(title: "Down 5", parent: volumeMenu, callback: () => { receiver.Volume -= 5; return("Current volume: " + (receiver.Volume - 5)); }); new Menu(title: "Up 5", parent: volumeMenu, callback: () => { receiver.Volume += 5; return("Current volume: " + (receiver.Volume + 5)); }); new Menu(title: "Down 10", parent: volumeMenu, callback: () => { receiver.Volume -= 10; return("Current volume: " + (receiver.Volume - 10)); }); new Menu(title: "Up 10", parent: volumeMenu, callback: () => { receiver.Volume += 10; return("Current volume: " + (receiver.Volume + 10)); }); telegram.AddRootMenu(onkyoMenu); }
public override void InstallTelegramHandlers(telegram.Service telegram) { this.telegram = telegram; projectorMenu = new telegram.Menu(title: "Projector", afterMenuText: () => projector.Status.ToString()); projectorMenu.Add(new telegram.Menu(title: "On", callback: () => projector.Status = PowerStatus.poweron)); projectorMenu.Add(new telegram.Menu(title: "Off", callback: () => projector.Status = PowerStatus.standby)); telegram.AddRootMenu(projectorMenu); }
public override void InstallTelegramHandlers(telegram.Service telegram) { kodiMenu = new Menu(title: "Kodi"); kodiMenu.Add(new Menu(title: "Left", callback: async() => await CallRpc("Input.Left"))); kodiMenu.Add(new Menu(title: "Right", callback: async() => await CallRpc("Input.Right"))); kodiMenu.Add(new Menu(title: "Up", callback: async() => await CallRpc("Input.Up"))); kodiMenu.Add(new Menu(title: "Down", callback: async() => await CallRpc("Input.Down"))); kodiMenu.Add(new Menu(title: "Select", callback: async() => await CallRpc("Input.Select"))); kodiMenu.Add(new Menu(title: "Return", callback: async() => await CallRpc("Input.Back"))); telegram.AddRootMenu(kodiMenu); }
public override void InstallTelegramHandlers(telegram.Service telegram) {//TODO: softcode this this.telegram = telegram; var projectorMenu = new Menu(title: "Projector"); new Menu("Projector screen up", async() => await mqtt.Publish("livingroom/RF/7", "up"), projectorMenu); new Menu("Projector screen down", async() => await mqtt.Publish("livingroom/RF/7", "down"), projectorMenu); new Menu("Projector screen stop", async() => await mqtt.Publish("livingroom/RF/7", "stop"), projectorMenu); telegram.AddRootMenu(projectorMenu); string timeSpan = "day"; int timeOffset = 0; string value = "temperature"; List <datamodel.Node> nodes = new List <datamodel.Node>(); sensorDataMenu = new Menu(title: "Sensordata", afterMenuText: showSensorData(timeSpan, timeOffset, value, nodes)); { var timespanMenu = new Menu(title: "Timespan: day", parent: sensorDataMenu); Func <string, Func <Reply> > timespanCallback = (newSpan) => { return(() => { timeSpan = newSpan; timespanMenu.Title = "Timespan: " + newSpan; var reply = showSensorData(timeSpan, timeOffset, value, nodes)(); reply.returnAfterClick = true; return reply; }); }; new Menu(title: "Day", parent: timespanMenu, callback: timespanCallback("day")); new Menu(title: "Week", parent: timespanMenu, callback: timespanCallback("week")); new Menu(title: "Month", parent: timespanMenu, callback: timespanCallback("month")); new Menu(title: "Year", parent: timespanMenu, callback: timespanCallback("year")); } { var timeOffsetMenu = new Menu(title: "Time offset: 0", parent: sensorDataMenu); Func <int, Func <Reply> > timeOffsetCallback = (offset) => { return(() => { timeOffset += offset; if (timeOffset < 0) { timeOffset = 0; } timeOffsetMenu.Title = "Time offset: " + timeOffset; var reply = showSensorData(timeSpan, timeOffset, value, nodes)(); reply.returnAfterClick = true; return reply; }); }; new Menu(title: "1 day back", parent: timeOffsetMenu, callback: timeOffsetCallback(1)); new Menu(title: "1 day forward", parent: timeOffsetMenu, callback: timeOffsetCallback(-1)); new Menu(title: "1 week back", parent: timeOffsetMenu, callback: timeOffsetCallback(7)); new Menu(title: "1 week forward", parent: timeOffsetMenu, callback: timeOffsetCallback(-7)); } { var valueMenu = new Menu(title: "Value: temperature", parent: sensorDataMenu); Func <string, Func <Reply> > valueCallback = (newValue) => { return(() => { value = newValue; valueMenu.Title = "Value: " + newValue; var reply = showSensorData(timeSpan, timeOffset, value, nodes)(); reply.returnAfterClick = true; return reply; }); }; new Menu(title: "Temperature", parent: valueMenu, callback: valueCallback("temperature")); new Menu(title: "Humidity", parent: valueMenu, callback: valueCallback("humidity")); new Menu(title: "Power usage", parent: valueMenu, callback: valueCallback("power usage")); new Menu(title: "Gas usage", parent: valueMenu, callback: valueCallback("gas usage")); } { Menu nodeMenu = null; Func <datamodel.Node, Func <Reply> > nodeCallback = (node) => { return(() => { if (nodes.Contains(node)) { nodes.Remove(node); } else { nodes.Add(node); } foreach (var m in nodeMenu.SubMenus) { if (m.Title.StartsWith(node.name + ": ")) { m.Title = node.name + ": " + (nodes.Contains(node) ? "on" : "off"); } } nodeMenu.Title = "Nodes: " + nodes.Aggregate("", (n, next) => n + ", " + next.name); var reply = showSensorData(timeSpan, timeOffset, value, nodes)(); return reply; }); }; nodeMenu = new Menu(title: "Nodes: ...", parent: sensorDataMenu, () => { nodeMenu.Clear(); IQueryable <datamodel.Node> dbNodes; if (value == "temperature" || value == "humidity") { dbNodes = db.nodes.Where(n => n.sensors.Any(s => s.type == 1 || s.type == 2)); } else if (value == "power" || value == "gas") { return("No nodes needed!"); } else { return("No nodes found!"); } foreach (var n in dbNodes) { new Menu(title: n.name + ": " + (nodes.Contains(n) ? "on" : "off"), parent: nodeMenu, callback: nodeCallback(n)); } return("Select nodes"); }); } telegram.AddRootMenu(sensorDataMenu); }