private void Tick() { _cpuLoad.Enqueue(_systemStatusService.GetCpuLoad()); _memoryPercentage.Enqueue((int)(100 - _systemStatusService.GetFreeMemoryMBytes() * 100 / _systemStatusService.GetTotalMemoryMBytes())); var stats = _systemStatusService.GetNetworkStats(); var sent = stats.Sent; var recv = stats.Received; double mbpsSentSpeed = 8 * (sent - _prevSent) / (1024.0 * 1024); double mbpsReceivedSpeed = 8 * (recv - _prevRecv) / (1024.0 * 1024); var bitmap = LayoutContext.CreateBitmap(); if (_prevSent != 0 || _prevRecv != 0) { DefaultDrawingAlgs.DrawTexts(bitmap, GlobalContext.Options.Theme.FontFamily, $"{mbpsReceivedSpeed:F2}\n{mbpsSentSpeed:F2}", "", "888888", GlobalContext.Options.Theme.ForegroundColor); } _prevSent = sent; _prevRecv = recv; DrawLine(_cpuLoad, bitmap, GlobalContext.Options.Theme.ForegroundColor); DrawLine(_memoryPercentage, bitmap, Color.Aquamarine); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
internal static BitmapEx DrawTexts(string l1, string l2, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); var textFontFamily = layoutContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawTexts(bitmap, textFontFamily, l1, l2, "DDD", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private static BitmapEx Draw(WeatherStationData weatherInfo, LayoutContext layoutContext) { var indoorDevice = weatherInfo.Devices.First(); var temperature = WeatherHelpers.TempToStr(indoorDevice.Temperature.Value); var co2 = indoorDevice.Co2Measure.Value.ToString(); var bitmap = layoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawTexts(bitmap, layoutContext.Options.Theme.FontFamily, co2, temperature, "+88", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
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); }