Beispiel #1
0
        public void DrawCpuUsage(object sender, PerformanceCounterEventArgs e)
        {
            cpuIcon?.Icon?.Dispose();

            Bitmap     cpuBitmap   = new Bitmap(16, 16);
            Graphics   cpuGraphics = Graphics.FromImage(cpuBitmap);
            SolidBrush brush       = new SolidBrush(Color.White);

            string cpuVal = $"{e.CPUValue:##}";

            cpuGraphics.Clear(Color.Transparent);

            //cpuGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //cpuGraphics.CompositingQuality = CompositingQuality.HighQuality;
            //cpuGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            cpuGraphics.DrawImageUnscaled(cpuBitmap, 0, 0);

            cpuGraphics.DrawString(cpuVal,
                                   new Font("Trebuchet MS", 8.8f, FontStyle.Regular, GraphicsUnit.Pixel),
                                   brush,
                                   new RectangleF(0, 3, 16, 13));

            cpuGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            cpuIcon.Icon = Icon.FromHandle(cpuBitmap.GetHicon());

            cpuBitmap?.Dispose();
            cpuGraphics?.Dispose();
            brush?.Dispose();
        }
        public void DrawDiskUsage(object sender, PerformanceCounterEventArgs performanceCounterEventArgs)
        {
            diskReadTotalIcon?.Icon?.Dispose();

            Bitmap     diskBitmap   = new Bitmap(16, 16);
            Graphics   diskGraphics = Graphics.FromImage(diskBitmap);
            SolidBrush brush        = new SolidBrush(Color.White);

            string sDiskUsage = $"{performanceCounterEventArgs.DISKValue:#:##}";

            diskGraphics.Clear(Color.Transparent);

            //diskGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //diskGraphics.CompositingQuality = CompositingQuality.HighQuality;
            //diskGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            diskGraphics.DrawImageUnscaled(diskBitmap, 0, 0);

            diskGraphics.DrawString(sDiskUsage,
                                    new Font("Trebuchet MS", 8.8f, FontStyle.Regular, GraphicsUnit.Pixel),
                                    brush,
                                    new RectangleF(0, 3, 16, 13));

            diskGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            diskReadTotalIcon.Icon         = Icon.FromHandle(diskBitmap.GetHicon());

            diskBitmap?.Dispose();
            diskGraphics?.Dispose();
            brush?.Dispose();
Beispiel #3
0
 private void PerformanceCounterEventHandler(object sender, PerformanceCounterEventArgs performanceCounterEventArgs)
 {
     DrawRamUsage(performanceCounterEventArgs.RAMValue);
     DrawAvailableRam(performanceCounterEventArgs.RAMValue);
 }