Ejemplo n.º 1
0
        void createPanels()
        {
            mainPanel.Controls.Clear();
            int margin    = 2;
            int capHeight = SystemInformation.MenuHeight + SystemInformation.BorderSize.Width;
            int w         = mainPanel.ClientSize.Width - 32; //subtract the scrollbar on right
            int h         = mainPanel.ClientSize.Height - capHeight;
            int wP        = w - (2 * margin);;
            int hP        = SystemInformation.MenuHeight / 2;//32; 16;// h / (panels.Length + 1 + margin);//need 32 panels with margin

            VMusage.procVMinfo [] vmInfoA = vmInfos.ToArray();

            //use bar 0 for total
            int total = 0;

            panels[0]             = new memorybar2();
            panels[0].BackColor   = myGreen;
            panels[0].ForeColor   = Color.Red;
            panels[0].BorderStyle = BorderStyle.FixedSingle;
            panels[0].Bounds      = new Rectangle(margin, (margin + hP) * 0, wP, hP);

            //vmInfo is for slot 1 to 32
            int idx = 0;

            for (int i = 1; i < panels.Length; i++)
            {
                panels[i]             = new memorybar2();
                panels[i].BackColor   = myGreen;// System.Drawing.Color.LightGreen;
                panels[i].ForeColor   = Color.Red;
                panels[i].BorderStyle = BorderStyle.FixedSingle;
                panels[i].Bounds      = new Rectangle(margin, (margin + hP) * i, wP, hP);
                idx             = i - 1;
                panels[i].Text  = vmInfoA[idx].slot.ToString() + ":" + vmInfoA[idx].name;
                panels[i].Value = vmInfoA[idx].memusage;
                total          += (int)vmInfoA[idx].memusage;
                this.mainPanel.Controls.Add(panels[i]);
            }

            //the max for all slot panels is 32MB, but bar 0 shows the total values
            //and the max val (493000000) can exceed the panels width (ie 444)
            int maxWidth    = (int)memorystatus.MemoryInfo.getTotalPhys() / 1000000;
            int scaleFactor = 0;

            while (maxWidth > panels[0].Width)
            {  //we need to scale this down or we get 0 result
                //System.Diagnostics.Debugger.Break();
                maxWidth = (int)((float)(maxWidth / 10f));
                scaleFactor++;
            }

            panels[0].Maximum = maxWidth;
            if (scaleFactor > 0)
            {
                panels[0].Value = (int)(memorystatus.MemoryInfo.getAvailPhys() / (scaleFactor * 10));
            }
            else
            {
                panels[0].Value = (int)(memorystatus.MemoryInfo.getAvailPhys());
            }
            panels[0].Text = "total";
            this.mainPanel.Controls.Add(panels[0]);
        }
Ejemplo n.º 2
0
        void createPanels()
        {
            mainPanel.Controls.Clear();
            int margin = 2;
            int capHeight = SystemInformation.MenuHeight + SystemInformation.BorderSize.Width;
            int w = mainPanel.ClientSize.Width - 32;  //subtract the scrollbar on right
            int h = mainPanel.ClientSize.Height - capHeight;
            int wP = w - (2 * margin); ;
            int hP = SystemInformation.MenuHeight / 2;//32; 16;// h / (panels.Length + 1 + margin);//need 32 panels with margin
            VMusage.procVMinfo [] vmInfoA = vmInfos.ToArray();

            //use bar 0 for total
            int total = 0;
            panels[0] = new memorybar2();
            panels[0].BackColor = myGreen;
            panels[0].ForeColor = Color.Red;
            panels[0].BorderStyle = BorderStyle.FixedSingle;
            panels[0].Bounds = new Rectangle (margin, (margin + hP) * 0, wP, hP);

            //vmInfo is for slot 1 to 32
            int idx = 0;
            for (int i = 1; i < panels.Length; i++)
            {
                panels[i] = new memorybar2();
                panels[i].BackColor = myGreen;// System.Drawing.Color.LightGreen;
                panels[i].ForeColor = Color.Red;
                panels[i].BorderStyle = BorderStyle.FixedSingle;
                panels[i].Bounds = new Rectangle (margin, (margin + hP) * i, wP, hP);
                idx = i - 1;
                panels[i].Text = vmInfoA[idx].slot.ToString() + ":" + vmInfoA[idx].name;
                panels[i].Value = vmInfoA[idx].memusage;
                total += (int)vmInfoA[idx].memusage;
                this.mainPanel.Controls.Add(panels[i]);
            }

            //the max for all slot panels is 32MB, but bar 0 shows the total values
            //and the max val (493000000) can exceed the panels width (ie 444)
            int maxWidth = (int)memorystatus.MemoryInfo.getTotalPhys() / 1000000;
            int scaleFactor = 0;
            while (maxWidth > panels[0].Width)
            {  //we need to scale this down or we get 0 result
                //System.Diagnostics.Debugger.Break();
                maxWidth = (int)((float)(maxWidth / 10f));
                scaleFactor++;
            }

            panels[0].Maximum = maxWidth;
            if(scaleFactor>0)
                panels[0].Value = (int)(memorystatus.MemoryInfo.getAvailPhys()/(scaleFactor*10));
            else
                panels[0].Value = (int)(memorystatus.MemoryInfo.getAvailPhys());
            panels[0].Text = "total";
            this.mainPanel.Controls.Add(panels[0]);
        }