Changeset 57
- Timestamp:
- Jun 27, 2005, 9:38:59 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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) … … 120 122 public void StartApplication() 121 123 { 124 doExit = false; 125 122 126 // çp^[ÇÝÝ 123 127 bool result = false; … … 155 159 156 160 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 161 Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding); 157 162 Application.Run(this); 158 163 } … … 402 407 403 408 g.SmoothingMode = SmoothingMode.None; 409 Brush availableBrush = new SolidBrush(Color.FromArgb(180, 100, 100, 255)); 410 Brush kernelBrush = new SolidBrush(Color.FromArgb(180, 255, 0, 0)); 404 411 Brush commitedBrush = new SolidBrush(Color.FromArgb(180, 255, 145, 0)); 405 Brush uncommitedBrush = new SolidBrush(Color.FromArgb(180, 180, 200, 255));406 Brush availableBrush = new SolidBrush(Color.FromArgb(180, 100, 100, 255));407 Brush spaceBrush = new SolidBrush(Color.FromArgb(1 80, 240, 230, 255));412 Brush systemCacheBrush = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); 413 // Brush spaceBrush = new SolidBrush(Color.FromArgb(180, 240, 230, 255)); 414 Brush spaceBrush = new SolidBrush(Color.FromArgb(100, 100, 100, 255)); 408 415 409 416 int pos = memHistoryHead - 1; … … 413 420 MemoryUsage usage = memHistory[pos]; 414 421 415 int x, y, w, h; 416 417 x = 300 - i * 5 - 5; 418 w = 5; 419 420 h = (int)(usage.Available * rate); 421 y = 100 - h; 422 g.FillRectangle(availableBrush, x, y, w, h); 422 int x = 300 - i * 5 - 5; 423 int y = 100; 424 int w = 5; 425 int h = 0; 426 427 int kernelTotal = usage.KernelNonPaged + usage.KernelPaged + usage.DriverTotal + usage.SystemCodeTotal; 428 h = (int)((kernelTotal) * rate); 429 y -= h; 430 g.FillRectangle(kernelBrush, x, y, w, h); 431 432 h = (int)(usage.SystemCache * rate); 433 y -= h; 434 g.FillRectangle(systemCacheBrush, x, y, w, h); 423 435 424 436 h = (int)(usage.Committed * rate); … … 426 438 g.FillRectangle(commitedBrush, x, y, w, h); 427 439 428 if (y > 100 - border) 429 { 430 h = y - (100 - border); 431 y = 100 - border; 432 g.FillRectangle(uncommitedBrush, x, y, w, h); 433 } 440 h = (int)(usage.Available * rate); 441 y -= h; 442 g.FillRectangle(availableBrush, x, y, w, h); 434 443 435 444 h = y; 436 445 y = 0; 437 446 g.FillRectangle(spaceBrush, x, y, w, h); 447 438 448 439 449 x = 300 - i * 5 - 5; … … 460 470 private void patternWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) 461 471 { 462 if (! System.Environment.HasShutdownStarted)472 if (!doExit) 463 473 { 464 474 e.Cancel = true; 465 475 } 476 } 477 478 private void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e) 479 { 480 doExit = true; 481 updateTimer.Stop(); 482 patternWindow.Close(); 483 statusWindow.Close(); 484 ExitThread(); 466 485 } 467 486 } -
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
Note: See TracChangeset
for help on using the changeset viewer.