Changeset 49
- Timestamp:
- 03/24/05 22:36:47 (4 years ago)
- Files:
-
- trunk/MacFaceFloat/MacFaceApp.cs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
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(); … … 86 104 // �p�^�[���E�C���h�E 87 105 this.patternWindow = new PatternWindow(); 106 107 // �X�e�[�^�X�E�C���h�E 108 statusWindow = new Form(); 109 statusWindow.ClientSize = new System.Drawing.Size(300, 211); 110 statusWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 111 statusWindow.ControlBox = false; 112 statusWindow.Icon = new Icon(asm.GetManifestResourceStream("MacFace.FloatApp.App.ico")); 113 statusWindow.Text = "Status"; 114 statusWindow.Paint +=new PaintEventHandler(statusWindow_Paint); 88 115 } 89 116 … … 105 132 } 106 133 } 134 135 statusWindow.Show(); 107 136 108 137 patternWindow.Location = config.Location; … … 211 240 MemoryUsage memUsage = memoryCounter.CurrentUsage(); 212 241 242 cpuHistory[cpuHistoryHead++] = cpuUsage; 243 if (cpuHistoryHead >= cpuHistory.Length) cpuHistoryHead = 0; 244 if (cpuHistoryCount < cpuHistory.Length) cpuHistoryCount++; 245 246 memHistory[memHistoryHead++] = memUsage; 247 if (memHistoryHead >= memHistory.Length) memHistoryHead = 0; 248 if (memHistoryCount < memHistory.Length) memHistoryCount++; 249 213 250 int pattern = cpuUsage.Active / 10; 214 251 … … 230 267 231 268 patternWindow.UpdatePattern(suite, pattern, markers); 269 270 statusWindow.Refresh(); 232 271 } 233 272 … … 271 310 patternWindow.Refresh(); 272 311 } 312 313 private void statusWindow_Paint(object sender, PaintEventArgs e) 314 { 315 Graphics g = e.Graphics; 316 g.SmoothingMode = SmoothingMode.AntiAlias; 317 318 g.FillRectangle(new SolidBrush(Color.White), 0, 0, 300, 100); 319 for (int y = 0; y < 100; y += 10) 320 { 321 g.DrawLine(Pens.FloralWhite, 0, y, 300, y); 322 } 323 324 g.FillRectangle(new SolidBrush(Color.White), 0, 110, 300, 100); 325 for (int y = 110; y < 210; y += 10) 326 { 327 g.DrawLine(Pens.FloralWhite, 0, y, 300, y); 328 } 329 330 331 if (cpuHistoryCount >= 2) 332 { 333 Point[] userGraph = new Point[cpuHistoryCount]; 334 Point[] sysGraph = new Point[cpuHistoryCount]; 335 336 int pos = cpuHistoryHead - 1; 337 for (int i = 0; i < cpuHistoryCount; i++) 338 { 339 if (pos < 0) pos = cpuHistory.Length - 1; 340 CPUUsage usage = cpuHistory[pos]; 341 userGraph[i].X = sysGraph[i].X = 300 - i * 5; 342 userGraph[i].Y = 100 - usage.Active; 343 sysGraph[i].Y = 100 - usage.System; 344 //Console.WriteLine("" + pos + ": " + points[i]); 345 pos--; 346 } 347 348 g.DrawLines(Pens.Red, sysGraph); 349 g.DrawLines(Pens.Blue, userGraph); 350 } 351 352 double rate = 70.0 / (MemoryUsageCounter.TotalVisibleMemorySize * 1024); 353 354 int posu = memHistoryHead - 1; 355 for (int i = 0; i < memHistoryCount; i++) 356 { 357 if (posu < 0) posu = memHistory.Length - 1; 358 MemoryUsage usage = memHistory[posu]; 359 360 int x, y, w, h; 361 362 x = 300 - i * 5; 363 w = 5; 364 h = (int)(usage.Committed * rate); 365 y = 210 - h; 366 g.FillRectangle(Brushes.Blue, x, y, w, h); 367 368 x = 300 - i * 5; 369 w = 2; 370 h = (int)(usage.Pagein); 371 y = 210 - h; 372 g.FillRectangle(Brushes.LightGray, x, y, w, h); 373 374 x = 303 - i * 5; 375 w = 2; 376 h = (int)(usage.Pageout); 377 y = 210 - h; 378 g.FillRectangle(Brushes.Black, x, y, w, h); 379 380 posu--; 381 } 382 g.DrawLine(Pens.Red, 0, 210-70, 300, 210-70); 383 } 273 384 } 274 385 }
