public ChangeIllumination(string roomId) { this.roomId = roomId; List <Room> rooms = Logic.GetUserRooms(); Room room = rooms.FirstOrDefault(r => r.Id == roomId); List <PickerValue> lightIntensityValues = new List <PickerValue>(); for (int i = 0; i <= 100; i += 5) { lightIntensityValues.Add(new PickerValue() { NumberValue = i, StringValue = i.ToString() + "%" }); } List <PickerValue> isLightValues = new List <PickerValue>(); isLightValues.Add(new PickerValue() { NumberValue = 0, StringValue = "Off" }); isLightValues.Add(new PickerValue() { NumberValue = 1, StringValue = "On" }); List <HowOften> howOftens = Logic.GetHowOftens(); DateTime minimumDate = DateTime.Now; InitializeComponent(); IsLight.ItemsSource = isLightValues; IsLight.SelectedItem = isLightValues.FirstOrDefault(l => l.NumberValue == Convert.ToInt32(room.currentIsLight)); LightIntensity.ItemsSource = lightIntensityValues; LightIntensity.SelectedItem = lightIntensityValues.FirstOrDefault(l => l.NumberValue == room.currentLightIntensity); IsRepeatable.ItemsSource = howOftens; IsRepeatable.SelectedItem = howOftens.FirstOrDefault(ho => ho.Id == 1); }
public ChangeClimat(string roomId) { this.roomId = roomId; List <Room> rooms = Logic.GetUserRooms(); Room room = rooms.FirstOrDefault(r => r.Id == roomId); List <PickerValue> temperatureValues = new List <PickerValue>(); for (int i = 15; i <= 35; i++) { temperatureValues.Add(new PickerValue() { NumberValue = i, StringValue = i.ToString() + "°C" }); } List <PickerValue> airHumidityValues = new List <PickerValue>(); for (int i = 10; i <= 65; i += 1) { airHumidityValues.Add(new PickerValue() { NumberValue = i, StringValue = i.ToString() + "%" }); } List <HowOften> howOftens = Logic.GetHowOftens(); DateTime minimumDate = DateTime.Now; InitializeComponent(); Temperature.ItemsSource = temperatureValues; Temperature.SelectedItem = temperatureValues.FirstOrDefault(t => t.NumberValue == room.currentTemperature); AirHumidity.ItemsSource = airHumidityValues; AirHumidity.SelectedItem = airHumidityValues.FirstOrDefault(a => a.NumberValue == room.CurrentAirHumidity); IsRepeatable.ItemsSource = howOftens; IsRepeatable.SelectedItem = howOftens.FirstOrDefault(ho => ho.Id == 1); }
public RoomsDetail() { InitializeComponent(); List <Room> rooms = Logic.GetUserRooms(); List <StackLayout> roomsCards = new List <StackLayout>(); foreach (var room in rooms) { var frame = new Frame() { BorderColor = Color.White, CornerRadius = 10, HasShadow = true, Margin = new Thickness(0, 4, 0, 4), HeightRequest = 250 }; var image = new Image() { Source = "test.jpg", Aspect = Aspect.Fill }; var grid = new Grid(); var roomCard = new StackLayout(); roomCard.Children.Add(new Label() { Text = room.Name, FontAttributes = FontAttributes.Bold, FontSize = 29, FontFamily = "Raleway-Bold.ttf#Raleway", TextColor = Color.White, Margin = new Thickness(20, 10, 0, 2) }); roomCard.Children.Add(new Label() { Text = "Current Temperature: " + room.currentTemperature + "°C", FontSize = 18, FontFamily = "Raleway-Medium.ttf#Raleway", TextColor = Color.White, Margin = new Thickness(20, 2) }); roomCard.Children.Add(new Label() { Text = "Current Air Humidity: " + room.CurrentAirHumidity + "%", FontSize = 18, FontFamily = "Raleway-Medium.ttf#Raleway", TextColor = Color.White, Margin = new Thickness(20, 2) }); var light = new Label() { FontSize = 18, FontFamily = "Raleway-Medium.ttf#Raleway", TextColor = Color.White, Margin = new Thickness(20, 2) }; if (room.currentIsLight) { light.Text = "Light is on"; } else { light.Text = "Light is off"; } roomCard.Children.Add(light); roomCard.Children.Add(new Label() { Text = "Current Light Intensity: " + room.currentLightIntensity + "%", FontSize = 18, FontFamily = "Raleway-Medium.ttf#Raleway", TextColor = Color.White, Margin = new Thickness(20, 2) }); var changeClimatButton = new Button() { Text = "Change climat", AutomationId = room.Id, WidthRequest = 135, Margin = new Thickness(20, 4, 0, 0), TextColor = Color.Black, FontFamily = "Raleway-Bold.ttf#Raleway" }; changeClimatButton.Clicked += ChangeClimat; var changeLightButton = new Button() { Text = "Change illumination", AutomationId = room.Id, WidthRequest = 135, Margin = new Thickness(7, 4, 0, 0), TextColor = Color.Black, FontFamily = "Raleway-Bold.ttf#Raleway" }; changeLightButton.Clicked += ChangeLight; roomCard.Children.Add(new StackLayout() { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { changeClimatButton, changeLightButton } }); grid.Children.Add(image); grid.Children.Add(roomCard); frame.Content = grid; Body.Children.Add(frame); } }