Changeset 52
- Timestamp:
- Mar 31, 2005, 9:22:21 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MacFaceApp.cs
r51 r52 33 33 34 34 private Form statusWindow; 35 private Bitmap cpuGraph; 36 private Bitmap memoryGraph; 35 37 36 38 private CPUUsage[] cpuHistory; … … 106 108 this.patternWindow = new PatternWindow(); 107 109 108 // Xe[^XEChE 110 // Xe[^XEChE 111 cpuGraph = new Bitmap(5*60, 100); 112 memoryGraph = new Bitmap(5*60, 100); 113 109 114 statusWindow = new Form(); 110 115 statusWindow.ClientSize = new System.Drawing.Size(310, 215); … … 134 139 } 135 140 141 drawCPUGraph(); 142 drawMemoryGraph(); 136 143 statusWindow.Show(); 137 144 … … 270 277 patternWindow.UpdatePattern(suite, pattern, markers); 271 278 279 drawCPUGraph(); 280 drawMemoryGraph(); 272 281 statusWindow.Invalidate(); 273 282 } … … 317 326 { 318 327 Graphics g = e.Graphics; 328 329 g.DrawImage(cpuGraph, 5,5); 330 g.DrawRectangle(Pens.Black, 4, 4, 301, 101); 331 332 g.DrawImage(memoryGraph, 5,110); 333 g.DrawRectangle(Pens.Black, 4, 109, 301, 101); 334 } 335 336 private void drawCPUGraph() 337 { 338 Graphics g = Graphics.FromImage(cpuGraph); 339 319 340 g.SmoothingMode = SmoothingMode.AntiAlias; 320 341 321 g.FillRectangle(new SolidBrush(Color.White), 5, 5, 300, 100);342 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100); 322 343 Pen pen = new Pen(Color.FromArgb(220, 220, 220), 1F); 323 for (int y = 5; y < 105; y += 10) 324 { 325 g.DrawLine(pen, 5, y, 305, y); 326 } 327 g.DrawLine(Pens.Gray, 5, 55, 305, 55); 328 329 g.DrawRectangle(Pens.Black, 4, 4, 301, 101); 330 331 g.FillRectangle(new SolidBrush(Color.White), 5, 110, 300, 100); 332 for (int y = 210; y > 110; y -= 7) 333 { 334 g.DrawLine(pen, 5, y, 305, y); 335 } 336 g.DrawLine(Pens.Gray, 5, 210-5*7, 305, 210-5*7); 337 g.DrawRectangle(Pens.Black, 4, 109, 301, 101); 338 344 for (int y = 0; y < 100; y += 10) 345 { 346 g.DrawLine(pen, 0, y, 300, y); 347 } 348 g.DrawLine(Pens.Gray, 0, 50, 300, 50); 339 349 340 350 if (cpuHistoryCount >= 2) … … 343 353 Point[] sysGraph = new Point[cpuHistoryCount+2]; 344 354 345 userGraph[cpuHistoryCount+0].X = 30 5 - cpuHistoryCount* 5;346 userGraph[cpuHistoryCount+0].Y = 10 5- 0;347 userGraph[cpuHistoryCount+1].X = 30 5- 0 * 5;348 userGraph[cpuHistoryCount+1].Y = 10 5- 0;349 350 sysGraph[cpuHistoryCount+0].X = 30 5 - cpuHistoryCount* 5;351 sysGraph[cpuHistoryCount+0].Y = 10 5- 0;352 sysGraph[cpuHistoryCount+1].X = 30 5- 0 * 5;353 sysGraph[cpuHistoryCount+1].Y = 10 5- 0;355 userGraph[cpuHistoryCount+0].X = 300 - (cpuHistoryCount-1) * 5; 356 userGraph[cpuHistoryCount+0].Y = 100 - 0; 357 userGraph[cpuHistoryCount+1].X = 300 - 0 * 5; 358 userGraph[cpuHistoryCount+1].Y = 100 - 0; 359 360 sysGraph[cpuHistoryCount+0].X = 300 - (cpuHistoryCount-1) * 5; 361 sysGraph[cpuHistoryCount+0].Y = 100 - 0; 362 sysGraph[cpuHistoryCount+1].X = 300 - 0 * 5; 363 sysGraph[cpuHistoryCount+1].Y = 100 - 0; 354 364 355 365 int pos = cpuHistoryHead - 1; … … 358 368 if (pos < 0) pos = cpuHistory.Length - 1; 359 369 CPUUsage usage = cpuHistory[pos]; 360 userGraph[i].X = sysGraph[i].X = 30 5- i * 5;361 userGraph[i].Y = 10 5- usage.Active;362 sysGraph[i].Y = 10 5- usage.System;370 userGraph[i].X = sysGraph[i].X = 300 - i * 5; 371 userGraph[i].Y = 100 - usage.Active; 372 sysGraph[i].Y = 100 - usage.System; 363 373 pos--; 364 374 } … … 368 378 g.FillPolygon(new SolidBrush(Color.FromArgb(50, 255, 0, 0)), sysGraph); 369 379 } 380 381 g.Dispose(); 382 } 383 384 private void drawMemoryGraph() 385 { 386 Graphics g = Graphics.FromImage(memoryGraph); 387 388 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100); 389 Pen pen = new Pen(Color.FromArgb(220, 220, 220), 1F); 390 for (int y = 100; y > 0; y -= 7) 391 { 392 g.DrawLine(pen, 0, y, 300, y); 393 } 394 g.DrawLine(Pens.Gray, 0, 100-5*7, 300, 100-5*7); 370 395 371 396 int totalMemory = (int)MemoryUsageCounter.TotalVisibleMemorySize * 1024; … … 376 401 Brush uncommitedBrush = new SolidBrush(Color.FromArgb(180, 180, 200, 255)); 377 402 Brush availableBrush = new SolidBrush(Color.FromArgb(180, 100, 100, 255)); 378 379 int posu = memHistoryHead - 1; 403 Brush spaceBrush = new SolidBrush(Color.FromArgb(180, 255, 255, 100)); 404 405 int pos = memHistoryHead - 1; 380 406 for (int i = 0; i < memHistoryCount; i++) 381 407 { 382 if (pos u < 0) posu= memHistory.Length - 1;383 MemoryUsage usage = memHistory[pos u];408 if (pos < 0) pos = memHistory.Length - 1; 409 MemoryUsage usage = memHistory[pos]; 384 410 385 411 int x, y, w, h; 386 412 387 x = 30 5- i * 5 - 5;413 x = 300 - i * 5 - 5; 388 414 w = 5; 389 415 416 h = 30; 417 y = 0; 418 g.FillRectangle(spaceBrush, x, y, w, h); 419 390 420 h = (int)(usage.Committed * rate); 391 y = 210 - h;421 y = 100 - h; 392 422 g.FillRectangle(commitedBrush, x, y, w, h); 393 423 394 if (h < 100)395 { 396 h = 100 - h;397 y = 110;424 if (h < 70) 425 { 426 h = 70 - h; 427 y = 30; 398 428 g.FillRectangle(uncommitedBrush, x, y, w, h); 399 429 } 400 430 401 431 h = (int)(usage.Available * rate); 402 y = 210-70;432 y = 100-70; 403 433 g.FillRectangle(availableBrush, x, y, w, h); 404 434 405 x = 30 5- i * 5 - 5;435 x = 300 - i * 5 - 5; 406 436 w = 2; 407 437 h = (int)(usage.Pagein); 408 y = 210 - h;438 y = 100 - h; 409 439 g.FillRectangle(Brushes.LightGray, x, y, w, h); 410 440 411 x = 30 8- i * 5 - 5;441 x = 303 - i * 5 - 5; 412 442 w = 2; 413 443 h = (int)(usage.Pageout); 414 y = 210 - h;444 y = 100 - h; 415 445 g.FillRectangle(Brushes.Black, x, y, w, h); 416 446 417 posu--; 418 } 419 g.DrawLine(Pens.Black, 5, 210-70, 305, 210-70); 447 pos--; 448 } 449 g.DrawLine(Pens.Black, 0, 100-70, 300, 100-70); 450 451 g.Dispose(); 420 452 } 421 453 }
Note: See TracChangeset
for help on using the changeset viewer.