Exemplo n.º 1
0
        public void openStatusWindow()
        {
            statusWindow         = new StatusWindow(cpuStats, memStats);
            statusWindow.Closed += new EventHandler(statusWindow_Closed);
            statusWindow.Move   += new EventHandler(statusWindow_Move);

            statusWindow.StartPosition = FormStartPosition.Manual;
            statusWindow.Location      = config.StatusWindowLocation;

            statusWindow.UpdateGraph();
            statusWindow.Show();

            menuItemToggleStatusWindow.Text = MES_CLOSE_STATUS_WINDOW;
            config.ShowStatusWindow         = true;
        }
Exemplo n.º 2
0
        public void CountProcessorUsage(object sender, EventArgs e)
        {
            cpuStats.Update();
            CPUUsage cpuUsage = cpuStats.Latest;

            memStats.Update();
            MemoryUsage memUsage = memStats.Latest;

            pageio_count += memUsage.Pageout * (memUsage.Pagein + 1);
            //if (pageio_count > 0) pageio_count += memUsage.Pagein;
            pageio_count -= pageio_count / 50 + 1;
            if (pageio_count < 0)
            {
                pageio_count = 0;
            }

            int pattern = cpuUsage.Active / 10;

            pattern += memUsage.Pageout / 15;
            pattern += memUsage.Pagein / 30;
            if (pattern > 10)
            {
                pattern = 10;
            }

            FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal;

            UInt64 avilable = (UInt64)memStats.TotalVisibleMemorySize * 1024 - memUsage.Used;

            if (pageio_count > 100)
            {
                suite = FaceDef.PatternSuite.MemoryInsufficient;
            }
            else if (avilable < 0)
            {
                suite = FaceDef.PatternSuite.MemoryDecline;
            }

            int markers = FaceDef.MarkerNone;

            if (memUsage.Pagein > 0)
            {
                markers += FaceDef.MarkerPageIn;
            }
            if (memUsage.Pageout > 0)
            {
                markers += FaceDef.MarkerPageOut;
            }

            if (patternWindow != null)
            {
                patternWindow.UpdatePattern(suite, pattern, markers);
            }

            if (statusWindow != null)
            {
                statusWindow.UpdateGraph();
            }

            if (optimusMini.IsAlive && curFaceDef != null)
            {
                Bitmap   image = new Bitmap(96, 96);
                Graphics g     = Graphics.FromImage(image);
                g.FillRectangle(new SolidBrush(Color.White), 0, 0, image.Width, image.Height);
                curFaceDef.DrawPatternImage(g, suite, pattern, markers, 96F / 128F);
                g.Dispose();

                optimusMini.ShowPicture(1, image);
            }
        }