Exemple #1
0
        private void DrawLine(Queue <int> queue, BitmapEx bitmap, Color color)
        {
            while (queue.Count > bitmap.Width)
            {
                queue.Dequeue();
            }

            if (queue.Count > 1)
            {
                var array = queue.ToArray();

                DefaultDrawingAlgs.DrawPlot(bitmap, color, array, 0, bitmap.Height, minValue: 0, maxValue: 100);
            }
        }
Exemple #2
0
        private async void ProcessDraw()
        {
            try
            {
                List <LayoutDrawElement> result = new List <LayoutDrawElement>(14);

                var weather = await _weatherStationService.GetHistorical();

                var values = weather.Union(new[] { await _weatherStationService.GetData() }).Select(m => _element.GetFunc(m)).ToArray();

                var currentValue = values.Last();
                var minValue     = values.Min();
                var maxValue     = values.Max();
                var avgValue     = values.Average();

                var color = _layoutContext.Options.Theme.ForegroundColor;

                result.Add(GetHeaderElement(0, 0, "Min", color));
                result.Add(GetHeaderElement(1, 0, "Avg", color));
                result.Add(GetHeaderElement(2, 0, "Max", color));
                result.Add(GetHeaderElement(3, 0, "Cur", color));

                result.Add(GetHeaderElement(0, 1, _element.TransformFunc(minValue), color));
                result.Add(GetHeaderElement(1, 1, _element.TransformFunc(avgValue), color));
                result.Add(GetHeaderElement(2, 1, _element.TransformFunc(maxValue), color));
                result.Add(GetHeaderElement(3, 1, _element.TransformFunc(currentValue), color));

                result.Add(GetHeaderElement(4, 1, _element.Suffix, color));

                var deviceWidth = _layoutContext.ButtonCount.Width;
                using (var bitmap = new BitmapEx(_layoutContext.IconSize.Width * deviceWidth, _layoutContext.IconSize.Height))
                {
                    bitmap.MakeTransparent();
                    DefaultDrawingAlgs.DrawPlot(bitmap, color, values, 0, bitmap.Height);
                    result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(deviceWidth, 1), 0, 2, _layoutContext));
                }

                DrawLayout?.Invoke(this, new DrawEventArgs(result.ToArray()));
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Exception during weather station layout drawing: {ex}");
            }
        }
Exemple #3
0
        private static BitmapEx DrawTexts(string l1, string l2, double[] values, LayoutContext layoutContext)
        {
            var bitmap = layoutContext.CreateBitmap();

            var textFontFamily = layoutContext.Options.Theme.FontFamily;

            DefaultDrawingAlgs.DrawTexts(bitmap, textFontFamily, l1 + Environment.NewLine + l2, "", "DDDD", layoutContext.Options.Theme.ForegroundColor);

            var startIndex = 0;

            if (values.Length > bitmap.Width)
            {
                startIndex = values.Length - bitmap.Width;
            }

            DefaultDrawingAlgs.DrawPlot(bitmap, layoutContext.Options.Theme.ForegroundColor, values, bitmap.Height / 2, bitmap.Height, startIndex);

            return(bitmap);
        }