diff --git a/House-Dashboard/Graphics/Esp.cs b/House-Dashboard/Graphics/Esp.cs new file mode 100644 index 0000000..510ced4 --- /dev/null +++ b/House-Dashboard/Graphics/Esp.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using BlubbFish.Utils.IoT.Connector; +using System.Windows.Media; + +namespace BlubbFish.House.Dashboard.Graphics +{ + class Esp : AGraphics + { + public Esp(Dictionary settings, ABackend data, UIElement window) : base(settings, data, window) { + } + + public override Grid Draw() { + Grid outergrid = this.CreateOuterGrid(); + outergrid.Children.Add(this.CreateTempGrid()); + outergrid.Children.Add(this.CreateHumiGrid()); + outergrid.Children.Add(this.CreatePresGrid()); + outergrid.Children.Add(this.CreateLumiGrid()); + return outergrid; + } + + private Grid CreateLumiGrid() { + // + // + // + // + // + // + // + // + Grid grid = new Grid() { + Margin = new Thickness(5) + }; + grid.SetValue(Grid.RowProperty, 1); + grid.SetValue(Grid.ColumnProperty, 1); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.Children.Add(new Image() { + Source = Helper.BitmapToImageSource(Properties.Resources.esp_luminence), + Height = 30 + }); + TextBlock temp = new TextBlock() { + Text = "2000" + }; + temp.SetValue(Grid.ColumnProperty, 1); + grid.Children.Add(temp); + return grid; + } + + private Grid CreatePresGrid() { + // + // + // + // + // + // + // + // + Grid grid = new Grid() { + Margin = new Thickness(5) + }; + grid.SetValue(Grid.RowProperty, 1); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.Children.Add(new Image() { + Source = Helper.BitmapToImageSource(Properties.Resources.esp_pressure), + Height = 30 + }); + TextBlock temp = new TextBlock() { + Text = "1000" + }; + temp.SetValue(Grid.ColumnProperty, 1); + grid.Children.Add(temp); + return grid; + } + + private Grid CreateHumiGrid() { + // + // + // + // + // + // + // + // + Grid grid = new Grid() { + Margin = new Thickness(5) + }; + grid.SetValue(Grid.ColumnProperty, 1); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.Children.Add(new Image() { + Source = Helper.BitmapToImageSource(Properties.Resources.esp_humidity), + Height = 30 + }); + TextBlock temp = new TextBlock() { + Text = "30%" + }; + temp.SetValue(Grid.ColumnProperty, 1); + grid.Children.Add(temp); + return grid; + } + + private Grid CreateTempGrid() { + // + // + // + // + // + // + // + // + Grid grid = new Grid() { + Margin = new Thickness(5) + }; + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.ColumnDefinitions.Add(new ColumnDefinition()); + grid.Children.Add(new Image() { + Source = Helper.BitmapToImageSource(Properties.Resources.esp_thermometer), + Height = 30 + }); + TextBlock temp = new TextBlock() { + Text = "20°C" + }; + temp.SetValue(Grid.ColumnProperty, 1); + grid.Children.Add(temp); + return grid; + } + + private Grid CreateOuterGrid() { + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + Thickness thickness = new Thickness(); + if (this.settings.ContainsKey("x") && Int32.TryParse(this.settings["x"], out Int32 x)) { + thickness.Left = x; + } + if (this.settings.ContainsKey("y") && Int32.TryParse(this.settings["y"], out Int32 y)) { + thickness.Top = y; + } + Double rotate = 0; + if (this.settings.ContainsKey("rotate") && Double.TryParse(this.settings["rotate"], out rotate)) { } + Grid outergrid = new Grid() { + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top, + Margin = thickness, + RenderTransform = new RotateTransform(rotate), + Background = new SolidColorBrush(Color.FromArgb(204, 255, 255, 255)) + }; + outergrid.RowDefinitions.Add(new RowDefinition()); + outergrid.RowDefinitions.Add(new RowDefinition()); + outergrid.ColumnDefinitions.Add(new ColumnDefinition()); + outergrid.ColumnDefinitions.Add(new ColumnDefinition()); + return outergrid; + } + } +} \ No newline at end of file diff --git a/House-Dashboard/Graphics/Heater.cs b/House-Dashboard/Graphics/Heater.cs index 17b8972..a108256 100644 --- a/House-Dashboard/Graphics/Heater.cs +++ b/House-Dashboard/Graphics/Heater.cs @@ -15,6 +15,8 @@ namespace BlubbFish.House.Dashboard.Graphics { class Heater : AGraphics { private readonly TextBlock targetTemp; private readonly Dictionary targetTemps = new Dictionary(); + private readonly TextBox popup_targettemp; + private readonly ComboBox popup_modes; private readonly TextBlock mode; private readonly TextBlock now; private readonly String topic; @@ -36,6 +38,11 @@ namespace BlubbFish.House.Dashboard.Graphics { this.now = new TextBlock { Text = "0 °C" }; + this.popup_targettemp = new TextBox { + Text = "20" + }; + this.popup_modes = new ComboBox(); + if(this.settings.ContainsKey("topic")) { this.topic = this.settings["topic"]; this.data.MessageIncomming += this.Data_MessageIncomming; @@ -78,6 +85,15 @@ namespace BlubbFish.House.Dashboard.Graphics { } this.now.Dispatcher.BeginInvoke((Action)(() => { this.mode.Text = text; + ComboBoxItem s = new ComboBoxItem(); + foreach (KeyValuePair item in this.modes) { + ComboBoxItem c = new ComboBoxItem { Content = item.Value, Tag = item.Key }; + this.popup_modes.Items.Add(c); + if(jmode == item.Key) { + s = c; + } + } + this.popup_modes.SelectedItem = s; })); this.WriteTargetTemp(); } @@ -109,6 +125,7 @@ namespace BlubbFish.House.Dashboard.Graphics { if (this.targetTemps.ContainsKey(this.activemode)) { this.now.Dispatcher.BeginInvoke((Action)(() => { this.targetTemp.Text = this.targetTemps[this.activemode] + " °C"; + this.popup_targettemp.Text = this.targetTemps[this.activemode].ToString(); })); } } @@ -265,14 +282,11 @@ namespace BlubbFish.House.Dashboard.Graphics { Margin = new Thickness(0, 0, 10, 0) }); // - TextBox t1 = new TextBox { - Width = 30, - Text = "20", - HorizontalAlignment = HorizontalAlignment.Right, - HorizontalContentAlignment = HorizontalAlignment.Right - }; - t1.SetValue(Grid.ColumnProperty, 1); - innergrid1.Children.Add(t1); + this.popup_targettemp.Width = 30; + this.popup_targettemp.HorizontalAlignment = HorizontalAlignment.Right; + this.popup_targettemp.HorizontalContentAlignment = HorizontalAlignment.Right; + this.popup_targettemp.SetValue(Grid.ColumnProperty, 1); + innergrid1.Children.Add(this.popup_targettemp); // TextBlock tb1 = new TextBlock { Text = "°C" @@ -299,16 +313,11 @@ namespace BlubbFish.House.Dashboard.Graphics { Margin = new Thickness(0, 0, 10, 0) }); // - ComboBox cb1 = new ComboBox { - Width = 50 - }; - cb1.SetValue(Grid.ColumnProperty, 1); + this.popup_modes.Width = 50; + this.popup_modes.SetValue(Grid.ColumnProperty, 1); // - cb1.Items.Add(new ComboBoxItem { - Content = "Heating" - }); // - innergrid2.Children.Add(cb1); + innergrid2.Children.Add(this.popup_modes); // outergrid.Children.Add(innergrid2); // @@ -326,17 +335,19 @@ namespace BlubbFish.House.Dashboard.Graphics { //