Changeset 49
- Timestamp:
- Mar 24, 2005, 10:36:47 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MacFaceApp.cs
r47 r49 10 10 using System.Windows.Forms; 11 11 using System.Drawing; 12 using System.Drawing.Drawing2D; 12 13 using System.Data; 13 14 using System.IO; … … 31 32 private MemoryUsageCounter memoryCounter; 32 33 34 private Form statusWindow; 35 36 private CPUUsage[] cpuHistory; 37 private int cpuHistoryHead; 38 private int cpuHistoryCount; 39 40 private MemoryUsage[] memHistory; 41 private int memHistoryHead; 42 private int memHistoryCount; 33 43 34 44 [STAThread] … … 43 53 config = Configuration.GetInstance(); 44 54 config.Load(); 55 56 cpuHistory = new CPUUsage[60]; 57 cpuHistoryCount = 0; 58 cpuHistoryHead = 0; 59 60 memHistory = new MemoryUsage[60]; 61 memHistoryCount = 0; 62 memHistoryHead = 0; 45 63 46 64 cpuCounter = new CPUUsageCounter(); … … 87 105 // p^[EChE 88 106 this.patternWindow = new PatternWindow(); 107 108 // Xe[^XEChE 109 statusWindow = new Form(); 110 statusWindow.ClientSize = new System.Drawing.Size(300, 211); 111 statusWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 112 statusWindow.ControlBox = false; 113 statusWindow.Icon = new Icon(asm.GetManifestResourceStream("MacFace.FloatApp.App.ico")); 114 statusWindow.Text = "Status"; 115 statusWindow.Paint +=new PaintEventHandler(statusWindow_Paint); 89 116 } 90 117 … … 106 133 } 107 134 } 135 136 statusWindow.Show(); 108 137 109 138 patternWindow.Location = config.Location; … … 213 242 MemoryUsage memUsage = memoryCounter.CurrentUsage(); 214 243 244 cpuHistory[cpuHistoryHead++] = cpuUsage; 245 if (cpuHistoryHead >= cpuHistory.Length) cpuHistoryHead = 0; 246 if (cpuHistoryCount < cpuHistory.Length) cpuHistoryCount++; 247 248 memHistory[memHistoryHead++] = memUsage; 249 if (memHistoryHead >= memHistory.Length) memHistoryHead = 0; 250 if (memHistoryCount < memHistory.Length) memHistoryCount++; 251 215 252 int pattern = cpuUsage.Active / 10; 216 253 … … 232 269 233 270 patternWindow.UpdatePattern(suite, pattern, markers); 271 272 statusWindow.Refresh(); 234 273 } 235 274 … … 274 313 patternWindow.Refresh(); 275 314 } 315 316 private void statusWindow_Paint(object sender, PaintEventArgs e) 317 { 318 Graphics g = e.Graphics; 319 g.SmoothingMode = SmoothingMode.AntiAlias; 320 321 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100); 322 for (int y = 0; y < 100; y += 10) 323 { 324 g.DrawLine(Pens.FloralWhite, 0, y, 300, y); 325 } 326 327 g.FillRectangle(new SolidBrush(Color.White), 0, 110, 300, 100); 328 for (int y = 110; y < 210; y += 10) 329 { 330 g.DrawLine(Pens.FloralWhite, 0, y, 300, y); 331 } 332 333 334 if (cpuHistoryCount >= 2) 335 { 336 Point[] userGraph = new Point[cpuHistoryCount]; 337 Point[] sysGraph = new Point[cpuHistoryCount]; 338 339 int pos = cpuHistoryHead - 1; 340 for (int i = 0; i < cpuHistoryCount; i++) 341 { 342 if (pos < 0) pos = cpuHistory.Length - 1; 343 CPUUsage usage = cpuHistory[pos]; 344 userGraph[i].X = sysGraph[i].X = 300 - i * 5; 345 userGraph[i].Y = 100 - usage.Active; 346 sysGraph[i].Y = 100 - usage.System; 347 //Console.WriteLine("" + pos + ": " + points[i]); 348 pos--; 349 } 350 351 g.DrawLines(Pens.Red, sysGraph); 352 g.DrawLines(Pens.Blue, userGraph); 353 } 354 355 double rate = 70.0 / (MemoryUsageCounter.TotalVisibleMemorySize * 1024); 356 357 int posu = memHistoryHead - 1; 358 for (int i = 0; i < memHistoryCount; i++) 359 { 360 if (posu < 0) posu = memHistory.Length - 1; 361 MemoryUsage usage = memHistory[posu]; 362 363 int x, y, w, h; 364 365 x = 300 - i * 5; 366 w = 5; 367 h = (int)(usage.Committed * rate); 368 y = 210 - h; 369 g.FillRectangle(Brushes.Blue, x, y, w, h); 370 371 x = 300 - i * 5; 372 w = 2; 373 h = (int)(usage.Pagein); 374 y = 210 - h; 375 g.FillRectangle(Brushes.LightGray, x, y, w, h); 376 377 x = 303 - i * 5; 378 w = 2; 379 h = (int)(usage.Pageout); 380 y = 210 - h; 381 g.FillRectangle(Brushes.Black, x, y, w, h); 382 383 posu--; 384 } 385 g.DrawLine(Pens.Red, 0, 210-70, 300, 210-70); 386 } 276 387 } 277 388 }
Note: See TracChangeset
for help on using the changeset viewer.