private void RefreshView()
        {
            labelTitle.Text  = module.Name;
            labelStatus.Text = module.GetStatusText();
            //
            var hsbParameter = module.GetProperty("Status.ColorHsb");

            if (hsbParameter != null)
            {
                string[] hsbValues = hsbParameter.Value.Split(',');
                double   h = 0, s = 0, v = 0;
                double.TryParse(hsbValues[0], System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out h);
                double.TryParse(hsbValues[1], System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out s);
                double.TryParse(hsbValues[2], System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out v);
                levelControlSlider.Level      = (s == 1 ? v / 2D : (1D - (s / 2D)));
                levelControlSlider.LevelColor = UiHelper.HsvToRgb(h, 1, 1);
            }
            module.GetImage((img) =>
            {
                UiHelper.SafeInvoke(pictureBoxIcon, () =>
                {
                    this.pictureBoxIcon.Image = UiHelper.ImageFromBytes(img);
                });
            });
        }
        public void UpdateStatistics()
        {
            Program.HomeGenie.ServiceCall("HomeAutomation.HomeGenie/Statistics/Parameter.StatsHour/Meter.Watts/", (data) =>
            {
                dynamic graph = JsonConvert.DeserializeObject(data);
                UiHelper.SafeInvoke(this.plot1, () => {
                    var myModel = new PlotModel();
                    // define an axis Date
                    var dateTimeAxis = new DateTimeAxis()
                    {
                        //Title = "Hour",
                        Position     = AxisPosition.Bottom,
                        IntervalType = DateTimeIntervalType.Hours,
                        MajorStep    = 0.12,
                        StringFormat = "HH:mm"
                    };

                    LinearAxis yAxis = new LinearAxis()
                    {
                        Position  = AxisPosition.Left,
                        MajorStep = 25
                    };

                    //dateTimeAxis.FontSize = 8D;
                    dateTimeAxis.AxislineColor      = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.ExtraGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.MajorGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.MinorGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TextColor          = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TicklineColor      = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TitleColor         = OxyColor.FromRgb(255, 255, 255);

                    myModel.DefaultFontSize     = 8D;
                    myModel.PlotAreaBorderColor = OxyColor.FromRgb(100, 100, 100);
                    myModel.TitleColor          = OxyColor.FromRgb(255, 255, 255);
                    myModel.TextColor           = OxyColor.FromRgb(255, 255, 255);

                    myModel.Axes.Add(dateTimeAxis);
                    myModel.Axes.Add(yAxis);

                    var linearSeries1 = new LineSeries();
                    //linearSeries1.Title = "Overall Avg";
                    linearSeries1.Selectable  = false;
                    linearSeries1.Smooth      = true;
                    linearSeries1.Color       = OxyColor.FromArgb(200, 100, 100, 255);
                    linearSeries1.ItemsSource = GetSerie(graph[1]);
                    myModel.Series.Add(linearSeries1);

                    var linearSeries2 = new LineSeries();
                    //linearSeries2.Title = "Today";
                    linearSeries2.Selectable  = false;
                    linearSeries2.Smooth      = true;
                    linearSeries2.Color       = OxyColor.FromArgb(200, 100, 255, 100);
                    linearSeries2.ItemsSource = GetSerie(graph[4]);
                    myModel.Series.Add(linearSeries2);

                    this.plot1.Model = myModel;
                });
            });
        }
 private void RefreshView()
 {
     labelTitle.Text          = module.Name;
     labelStatus.Text         = module.GetStatusText();
     levelControlSlider.Level = module.GetLevel();
     module.GetImage((img) =>
     {
         UiHelper.SafeInvoke(pictureBoxIcon, () => {
             this.pictureBoxIcon.Image = UiHelper.ImageFromBytes(img);
         });
     });
 }
Example #4
0
 public override void Refresh()
 {
     UiHelper.SafeInvoke(this, () => { RefreshView(); });
 }