public void drawChart(process[] p) { Application.EnableVisualStyles(); Form win = new Form() { Text = "os", MaximizeBox = false, MinimizeBox = false, StartPosition = FormStartPosition.CenterScreen, FormBorderStyle = FormBorderStyle.FixedDialog, Width = 900, Height = 300 }; win.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => { int x, y, avg = 0; for (int i = 0; i < p.Length; i++) { avg += p[i].waitTime; y = 20; x = 50 + (i == 0 ? 0 : ((int)(800 * ((float)p[i].waitTime / (float)(p[p.Length - 1].time + p[p.Length - 1].waitTime))))); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(i * 50 % 250, i * 80 % 250, i * 100 % 250)), Rectangle.Round(new Rectangle(x, y, (int)(800 * ((float)p[i].time / (float)(p[p.Length - 1].time + p[p.Length - 1].waitTime))), 50))); e.Graphics.DrawString("pid:" + p[i].pid, new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point), Brushes.White, x + 6, y + 15, StringFormat.GenericDefault); } e.Graphics.DrawString("average wait time: " + (float)avg / (float)p.Length, new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point), Brushes.Black, 350, 215, StringFormat.GenericDefault); }); DataGridView table = new DataGridView() { ColumnCount = 5, ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single, CellBorderStyle = DataGridViewCellBorderStyle.Single, RowHeadersVisible = false }; table.SetBounds(50, 100, 800, 100); table.Columns[0].Name = "pid"; table.Columns[1].Name = "name/tag"; table.Columns[2].Name = "burst time"; table.Columns[3].Name = "wait time"; table.Columns[4].Name = "priority"; for (int i = 0; i < table.ColumnCount; i++) { table.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } for (int i = 0; i < p.Length; i++) { table.Rows.Add(new string[] { p[i].pid + "", "" + p[i].tag, "" + p[i].time, "" + p[i].waitTime, (p[i].priority >= 0 ? ("" + p[i].priority) : ("n/a")) }); } win.Controls.Add(table); Application.Run(win); }