Changeset 57
- Timestamp:
- 06/27/05 21:38:59 (4 years ago)
- Files:
-
- trunk/MacFaceFloat/MacFaceApp.cs (modified) (7 diffs)
- trunk/MacFaceLibrary/MemoryUsage.cs (modified) (3 diffs)
- trunk/MacFaceLibrary/MemoryUsageCounter.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/MacFaceFloat/MacFaceApp.cs
r56 r57 44 44 private int memHistoryCount; 45 45 46 private bool doExit; 47 46 48 [STAThread] 47 49 public static void Main(string[] args) … … 119 121 public void StartApplication() 120 122 { 123 doExit = false; 124 121 125 // ���^�[���ǂݍ��� 122 126 bool result = false; … … 154 158 155 159 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 160 Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding); 156 161 Application.Run(this); 157 162 } … … 399 404 400 405 g.SmoothingMode = SmoothingMode.None; 406 Brush availableBrush = new SolidBrush(Color.FromArgb(180, 100, 100, 255)); 407 Brush kernelBrush = new SolidBrush(Color.FromArgb(180, 255, 0, 0)); 401 408 Brush commitedBrush = new SolidBrush(Color.FromArgb(180, 255, 145, 0)); 402 Brush uncommitedBrush = new SolidBrush(Color.FromArgb(180, 180, 200, 255));403 Brush availableBrush = new SolidBrush(Color.FromArgb(180, 100, 100, 255));404 Brush spaceBrush = new SolidBrush(Color.FromArgb(1 80, 240, 230, 255));409 Brush systemCacheBrush = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); 410 // Brush spaceBrush = new SolidBrush(Color.FromArgb(180, 240, 230, 255)); 411 Brush spaceBrush = new SolidBrush(Color.FromArgb(100, 100, 100, 255)); 405 412 406 413 int pos = memHistoryHead - 1; … … 410 417 MemoryUsage usage = memHistory[pos]; 411 418 412 int x, y, w, h; 413 414 x = 300 - i * 5 - 5; 415 w = 5; 416 417 h = (int)(usage.Available * rate); 418 y = 100 - h; 419 g.FillRectangle(availableBrush, x, y, w, h); 419 int x = 300 - i * 5 - 5; 420 int y = 100; 421 int w = 5; 422 int h = 0; 423 424 int kernelTotal = usage.KernelNonPaged + usage.KernelPaged + usage.DriverTotal + usage.SystemCodeTotal; 425 h = (int)((kernelTotal) * rate); 426 y -= h; 427 g.FillRectangle(kernelBrush, x, y, w, h); 428 429 h = (int)(usage.SystemCache * rate); 430 y -= h; 431 g.FillRectangle(systemCacheBrush, x, y, w, h); 420 432 421 433 h = (int)(usage.Committed * rate); … … 423 435 g.FillRectangle(commitedBrush, x, y, w, h); 424 436 425 if (y > 100 - border) 426 { 427 h = y - (100 - border); 428 y = 100 - border; 429 g.FillRectangle(uncommitedBrush, x, y, w, h); 430 } 437 h = (int)(usage.Available * rate); 438 y -= h; 439 g.FillRectangle(availableBrush, x, y, w, h); 431 440 432 441 h = y; 433 442 y = 0; 434 443 g.FillRectangle(spaceBrush, x, y, w, h); 444 435 445 436 446 x = 300 - i * 5 - 5; … … 457 467 private void patternWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) 458 468 { 459 if (! System.Environment.HasShutdownStarted)469 if (!doExit) 460 470 { 461 471 e.Cancel = true; 462 472 } 473 } 474 475 private void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e) 476 { 477 doExit = true; 478 updateTimer.Stop(); 479 patternWindow.Close(); 480 statusWindow.Close(); 481 ExitThread(); 463 482 } 464 483 } trunk/MacFaceLibrary/MemoryUsage.cs
r25 r57 15 15 private int pagein; 16 16 private int pageout; 17 private int systemCache; 18 private int kernelPaged; 19 private int kernelNonPaged; 20 private int driverTotal; 21 private int systemCodeTotal; 17 22 18 public MemoryUsage(int available, int committed, int pagein, int pageout) 23 public MemoryUsage(int available, int committed, int pagein, int pageout, 24 int systemCache, int kernelPaged, int kernelNonPaged, int driverTotal, int systemCodeTotal) 19 25 { 20 26 this.available = available; … … 22 28 this.pagein = pagein; 23 29 this.pageout = pageout; 30 this.systemCache = systemCache; 31 this.kernelPaged = kernelPaged; 32 this.kernelNonPaged = kernelNonPaged; 33 this.driverTotal = driverTotal; 34 this.systemCodeTotal = systemCodeTotal; 24 35 } 25 36 … … 43 54 get { return pageout; } 44 55 } 56 57 public int SystemCache 58 { 59 get { return systemCache; } 60 } 61 62 public int KernelPaged 63 { 64 get { return kernelPaged; } 65 } 66 67 public int KernelNonPaged 68 { 69 get { return kernelNonPaged; } 70 } 71 72 public int DriverTotal 73 { 74 get { return driverTotal; } 75 } 76 77 public int SystemCodeTotal 78 { 79 get { return systemCodeTotal; } 80 } 45 81 } 46 82 } trunk/MacFaceLibrary/MemoryUsageCounter.cs
r53 r57 19 19 private PerformanceCounter pageoutCounter; 20 20 private PerformanceCounter pageinCounter; 21 private PerformanceCounter systemCacheCounter; 22 private PerformanceCounter kernelPagedCounter; 23 private PerformanceCounter kernelNonPagedCounter; 24 private PerformanceCounter driverTotalCounter; 25 private PerformanceCounter systemCodeTotalCounter; 21 26 22 27 static MemoryUsageCounter() … … 51 56 pageinCounter.CategoryName = "Memory"; 52 57 pageinCounter.CounterName = "Pages Input/sec"; 58 59 systemCacheCounter = new PerformanceCounter(); 60 systemCacheCounter.CategoryName = "Memory"; 61 systemCacheCounter.CounterName = "Cache Bytes"; 62 63 kernelPagedCounter = new PerformanceCounter(); 64 kernelPagedCounter.CategoryName = "Memory"; 65 kernelPagedCounter.CounterName = "Pool Paged Bytes"; 66 67 kernelNonPagedCounter = new PerformanceCounter(); 68 kernelNonPagedCounter.CategoryName = "Memory"; 69 kernelNonPagedCounter.CounterName = "Pool Nonpaged Bytes"; 70 71 driverTotalCounter = new PerformanceCounter(); 72 driverTotalCounter.CategoryName = "Memory"; 73 driverTotalCounter.CounterName = "System Driver Total Bytes"; 74 75 systemCodeTotalCounter = new PerformanceCounter(); 76 systemCodeTotalCounter.CategoryName = "Memory"; 77 systemCodeTotalCounter.CounterName = "System Code Total Bytes"; 53 78 } 54 79 55 80 public MemoryUsage CurrentUsage() 56 81 { 57 int available = (int)availableCounter.NextValue(); 58 int committed = (int)committedCounter.NextValue(); 59 int pagein = (int)pageinCounter.NextValue(); 60 int pageout = (int)pageoutCounter.NextValue(); 82 int available = (int)availableCounter.NextValue(); 83 int committed = (int)committedCounter.NextValue(); 84 int pagein = (int)pageinCounter.NextValue(); 85 int pageout = (int)pageoutCounter.NextValue(); 86 int systemCache = (int)systemCacheCounter.NextValue(); 87 int kernelPaged = (int)kernelPagedCounter.NextValue(); 88 int kernelNonPaged = (int)kernelNonPagedCounter.NextValue(); 89 int driverTotal = (int)driverTotalCounter.NextValue(); 90 int systemCodeTotal = (int)systemCodeTotalCounter.NextValue(); 61 91 62 return new MemoryUsage(available, committed, pagein, pageout); 92 return new MemoryUsage(available, committed, pagein, pageout, 93 systemCache, kernelPaged, kernelNonPaged, driverTotal, systemCodeTotal); 63 94 } 64 95
