Changeset 61
- Timestamp:
- Sep 9, 2005, 2:13:57 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MacFaceApp.cs
r60 r61 29 29 30 30 private System.Windows.Forms.Timer updateTimer; 31 private CPUUsageCounter cpuCounter;32 private MemoryUsageCounter memoryCounter;33 31 34 32 private StatusWindow statusWindow; … … 36 34 private Bitmap memoryGraph; 37 35 38 private CPUUsage[] cpuHistory; 39 private int cpuHistoryHead; 40 private int cpuHistoryCount; 41 42 private MemoryUsage[] memHistory; 43 private int memHistoryHead; 44 private int memHistoryCount; 36 private CPUStatistics cpuStats; 37 private MemoryStatistics memStats; 45 38 46 39 [STAThread] … … 56 49 config.Load(); 57 50 58 cpuHistory = new CPUUsage[61]; 59 cpuHistoryCount = 0; 60 cpuHistoryHead = 0; 61 62 memHistory = new MemoryUsage[61]; 63 memHistoryCount = 0; 64 memHistoryHead = 0; 65 66 cpuCounter = new CPUUsageCounter(); 67 memoryCounter = new MemoryUsageCounter(); 51 cpuStats = new CPUStatistics(61); 52 memStats = new MemoryStatistics(61); 68 53 69 54 updateTimer = new System.Windows.Forms.Timer(); … … 204 189 public void CountProcessorUsage(object sender, EventArgs e) 205 190 { 206 CPUUsage cpuUsage = cpuCounter.CurrentUsage(); 207 MemoryUsage memUsage = memoryCounter.CurrentUsage(); 208 209 cpuHistory[cpuHistoryHead++] = cpuUsage; 210 if (cpuHistoryHead >= cpuHistory.Length) cpuHistoryHead = 0; 211 if (cpuHistoryCount < cpuHistory.Length) cpuHistoryCount++; 212 213 memHistory[memHistoryHead++] = memUsage; 214 if (memHistoryHead >= memHistory.Length) memHistoryHead = 0; 215 if (memHistoryCount < memHistory.Length) memHistoryCount++; 216 191 cpuStats.Update(); 192 CPUUsage cpuUsage = cpuStats.Latest; 193 194 memStats.Update(); 195 MemoryUsage memUsage = memStats.Latest; 196 217 197 if (patternWindow != null) 218 198 { … … 220 200 221 201 int pattern = cpuUsage.Active / 10; 222 int avilable = (int) MemoryUsageCounter.TotalVisibleMemorySize * 1024 - memUsage.Committed;202 int avilable = (int)memStats.TotalVisibleMemorySize * 1024 - memUsage.Committed; 223 203 if (avilable < (10 * 1024 *1024)) 224 204 { … … 360 340 g.DrawLine(Pens.Gray, 0, 50, 300, 50); 361 341 362 if (cpuHistoryCount >= 2) 363 { 364 Point[] userGraph = new Point[cpuHistoryCount+2]; 365 Point[] sysGraph = new Point[cpuHistoryCount+2]; 366 367 userGraph[cpuHistoryCount+0].X = 300 - (cpuHistoryCount-1) * 5; 368 userGraph[cpuHistoryCount+0].Y = 100 - 0; 369 userGraph[cpuHistoryCount+1].X = 300 - 0 * 5; 370 userGraph[cpuHistoryCount+1].Y = 100 - 0; 371 372 sysGraph[cpuHistoryCount+0].X = 300 - (cpuHistoryCount-1) * 5; 373 sysGraph[cpuHistoryCount+0].Y = 100 - 0; 374 sysGraph[cpuHistoryCount+1].X = 300 - 0 * 5; 375 sysGraph[cpuHistoryCount+1].Y = 100 - 0; 376 377 int pos = cpuHistoryHead - 1; 378 for (int i = 0; i < cpuHistoryCount; i++) 342 int count = cpuStats.Count; 343 344 if (count >= 2) 345 { 346 Point[] userGraph = new Point[count+2]; 347 Point[] sysGraph = new Point[count+2]; 348 349 userGraph[count+0].X = 300 - (count-1) * 5; 350 userGraph[count+0].Y = 100 - 0; 351 userGraph[count+1].X = 300 - 0 * 5; 352 userGraph[count+1].Y = 100 - 0; 353 354 sysGraph[count+0].X = 300 - (count-1) * 5; 355 sysGraph[count+0].Y = 100 - 0; 356 sysGraph[count+1].X = 300 - 0 * 5; 357 sysGraph[count+1].Y = 100 - 0; 358 359 for (int i = 0; i < count; i++) 379 360 { 380 if (pos < 0) pos = cpuHistory.Length - 1; 381 CPUUsage usage = cpuHistory[pos]; 361 CPUUsage usage = cpuStats[i]; 382 362 userGraph[i].X = sysGraph[i].X = 300 - i * 5; 383 363 userGraph[i].Y = 100 - usage.Active; 384 364 sysGraph[i].Y = 100 - usage.System; 385 pos--;386 365 } 387 366 … … 398 377 Graphics g = Graphics.FromImage(memoryGraph); 399 378 400 int totalMemory = (int) MemoryUsageCounter.TotalVisibleMemorySize * 1024;401 double rate = 100.0 / MemoryUsageCounter.CommitLimit;379 int totalMemory = (int)memStats.TotalVisibleMemorySize * 1024; 380 double rate = 100.0 / memStats.CommitLimit; 402 381 int border = (int)(totalMemory * rate); 403 382 … … 417 396 Brush spaceBrush = new SolidBrush(Color.FromArgb(100, 100, 100, 255)); 418 397 419 int pos = memHistoryHead - 1;420 for (int i = 0; i < memHistoryCount; i++) 421 {422 if (pos < 0) pos = memHistory.Length - 1;423 MemoryUsage usage = mem History[pos];398 int count = memStats.Count; 399 400 for (int i = 0; i < count; i++) 401 { 402 MemoryUsage usage = memStats[i]; 424 403 425 404 int x = 300 - i * 5 - 5; … … 461 440 y = 100 - h; 462 441 g.FillRectangle(Brushes.Black, x, y, w, h); 463 464 pos--;465 442 } 466 443 Pen borderPen = new Pen(Color.Blue); -
trunk/MacFaceLibrary/MacFaceLibrary.csproj
r27 r61 100 100 /> 101 101 <File 102 RelPath = "CPU Usage.cs"102 RelPath = "CPUStatistics.cs" 103 103 SubType = "Code" 104 104 BuildAction = "Compile" 105 105 /> 106 106 <File 107 RelPath = "CPUUsage Counter.cs"107 RelPath = "CPUUsage.cs" 108 108 SubType = "Code" 109 109 BuildAction = "Compile" … … 120 120 /> 121 121 <File 122 RelPath = "Memory Usage.cs"122 RelPath = "MemoryStatistics.cs" 123 123 SubType = "Code" 124 124 BuildAction = "Compile" 125 125 /> 126 126 <File 127 RelPath = "MemoryUsage Counter.cs"127 RelPath = "MemoryUsage.cs" 128 128 SubType = "Code" 129 129 BuildAction = "Compile"
Note: See TracChangeset
for help on using the changeset viewer.