/// <summary> /// The Command functions. /// </summary> private void DoHomeComingOnCommand() { var time = DateTime.Now; foreach (var element in TcpSettings.TcpFS20DeviceList) { if (element.Value.HomeComing == true) { if (time.Hour >= 19) { _tcpClient.SendTcpCommand(element.Value.Address, element.Value.Fs20.Fs20Address, nameof(TcpSettings.TcpFS20CommandList.ON)); } } } foreach (var element in TcpSettings.TcpLedDeviceList) { if (element.HomeComing == true) { _tcpClient.SendTcpCommand(element.Address, element.Led.HomeComing.Red, element.Led.HomeComing.Green, element.Led.HomeComing.Blue); } } foreach (var element in NanoLeafSettings.NanoLeafDevices) { if (element.HomeComing == true) { _nanoLeafClient.SwitchNanoLeaf(true, element); } } }
public TcpLedControl(ITCPClient tcpClient) { //_Num = Num; _tcpClient = tcpClient; InitializeComponent(); Label header = new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; Picker picker = new Picker { Title = "Color", VerticalOptions = LayoutOptions.CenterAndExpand }; StackLayout switches = new StackLayout { Orientation = StackOrientation.Horizontal }; int count = 0; foreach (var element in TcpSettings.TcpLedDeviceList) { var newLabel = new Label { Text = element.Name }; var newSwitch = new LedSwitch { index = count }; newSwitch.Toggled += HandlerSwitchToggeled; switches.Children.Add(newLabel); switches.Children.Add(newSwitch); count++; } foreach (string colorName in nameToColor.Keys) { picker.Items.Add(colorName); } // Create BoxView for displaying picked Color BoxView boxView = new BoxView { WidthRequest = 150, HeightRequest = 150, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; picker.SelectedIndexChanged += (sender, args) => { if (picker.SelectedIndex == -1) { boxView.Color = Color.Default; } else { string colorName = picker.Items[picker.SelectedIndex]; boxView.Color = nameToColor[colorName]; foreach (var element in TcpSettings.TcpLedDeviceList) { if (element.aktive == true) { _tcpClient.SendTcpCommand(element.Address, boxView.Color.R * 255, boxView.Color.G * 255, boxView.Color.B * 255); } } } }; GridTcp.Children.AddVertical(header); GridTcp.Children.AddVertical(picker); GridTcp.Children.AddVertical(boxView); GridTcp.Children.AddVertical(switches); //// Build the page. //this.Content = new StackLayout //{ // Children = // { // header, // picker, // boxView, // switches // } //}; }