Exemplo n.º 1
0
        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) });
        }