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