Changeset 58
- Timestamp:
- Jun 28, 2005, 11:17:00 PM (19 years ago)
- Location:
- trunk/MacFaceFloat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MacFaceApp.cs
r57 r58 74 74 updateTimer.Tick += new EventHandler(this.CountProcessorUsage); 75 75 76 patternWindow = null; 77 78 cpuGraph = null; 79 memoryGraph = null; 80 statusWindow = null; 81 76 82 InitializeComponent(); 77 83 } … … 82 88 [ 83 89 ContextMenu contextMenu = new System.Windows.Forms.ContextMenu(); 84 MenuItem menuItemPatternSelect = new System.Windows.Forms.MenuItem(); 90 MenuItem menuItemShowPatternWindow = new System.Windows.Forms.MenuItem(); 91 MenuItem menuItemShowStatusWindow = new System.Windows.Forms.MenuItem(); 85 92 MenuItem menuItemConfigure = new System.Windows.Forms.MenuItem(); 86 93 MenuItem menuItemExit = new System.Windows.Forms.MenuItem(); 87 94 88 menuItemPatternSelect.Text = "çp^[ÌIð(&S)"; 89 menuItemPatternSelect.Click += new System.EventHandler(menuItemPatternSelect_Click); 95 menuItemShowPatternWindow.Text = "p^[EChEðJ(&P)"; 96 menuItemShowPatternWindow.Click +=new EventHandler(menuItemShowPatternWindow_Click); 97 98 menuItemShowStatusWindow.Text = "Xe[^XEChEðJ(&S)"; 99 menuItemShowStatusWindow.Click +=new EventHandler(menuItemShowStatusWindow_Click); 90 100 91 101 menuItemConfigure.Text = "MacFace ÌÝè(&C)..."; … … 97 107 98 108 contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 99 menuItem PatternSelect, menuItemConfigure, new MenuItem("-"), menuItemExit});109 menuItemShowPatternWindow, menuItemShowStatusWindow, new MenuItem("-"), menuItemConfigure, new MenuItem("-"), menuItemExit}); 100 110 101 111 // ÊmACR … … 106 116 this.notifyIcon.Visible = true; 107 117 this.notifyIcon.ContextMenu = contextMenu; 108 109 // p^[EChE110 this.patternWindow = new PatternWindow();111 this.patternWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing);112 113 // Xe[^XEChE114 cpuGraph = new Bitmap(5*60, 100);115 memoryGraph = new Bitmap(5*60, 100);116 statusWindow = new StatusWindow();117 statusWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing);118 statusWindow.cpuGraphPicBox.Image = cpuGraph;119 statusWindow.memoryGraphPicBox.Image = memoryGraph;120 118 } 121 119 … … 140 138 } 141 139 142 drawCPUGraph(); 143 drawMemoryGraph(); 144 FormBorderStyle orgStyle = statusWindow.FormBorderStyle; 145 statusWindow.FormBorderStyle = FormBorderStyle.Sizable; 146 statusWindow.StartPosition = FormStartPosition.Manual; 147 statusWindow.Location = config.StatusWindowLocation; 148 statusWindow.FormBorderStyle = orgStyle; 149 statusWindow.Show(); 150 151 patternWindow.Location = config.Location; 152 patternWindow.Opacity = (float)config.Opacity / 100; 153 patternWindow.PatternSize = (float)config.PatternSize / 100; 154 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 155 patternWindow.Refresh(); 156 157 patternWindow.Show(); 140 openPatternWindow(); 141 openStatusWindow(); 158 142 updateTimer.Start(); 159 143 160 144 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 161 Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);162 145 Application.Run(this); 163 146 } … … 167 150 notifyIcon.Visible = false; 168 151 169 // Û¶170 config.Location = patternWindow.Location;171 config.StatusWindowLocation = statusWindow.Location;172 152 config.Save(); 173 153 } … … 238 218 } 239 219 240 // çp^[·µÖ¦ÍXVð~ßĨ 241 if (updateTimer != null) updateTimer.Stop(); 242 243 patternWindow.FaceDef = newFaceDef; 244 patternWindow.Refresh(); 245 246 notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title; 247 248 // XVÄJ 249 if (updateTimer != null) updateTimer.Start(); 220 if (patternWindow != null) 221 { 222 // çp^[·µÖ¦ÍXVð~ßĨ 223 if (updateTimer != null) updateTimer.Stop(); 224 225 patternWindow.FaceDef = newFaceDef; 226 patternWindow.Refresh(); 227 228 notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title; 229 230 // XVÄJ 231 if (updateTimer != null) updateTimer.Start(); 232 } 250 233 251 234 return true; … … 265 248 if (memHistoryCount < memHistory.Length) memHistoryCount++; 266 249 267 int pattern = cpuUsage.Active / 10; 268 269 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal; 270 271 int avilable = (int)MemoryUsageCounter.TotalVisibleMemorySize * 1024 - memUsage.Committed; 272 if (avilable < (10 * 1024 *1024)) 273 { 274 suite = FaceDef.PatternSuite.MemoryInsufficient; 275 } 276 else if (memUsage.Available < (30 * 1024 *1024)) 277 { 278 suite = FaceDef.PatternSuite.MemoryDecline; 279 } 280 281 int markers = FaceDef.MarkerNone; 282 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn; 283 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut; 284 285 patternWindow.UpdatePattern(suite, pattern, markers); 286 250 if (patternWindow != null) 251 { 252 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal; 253 254 int pattern = cpuUsage.Active / 10; 255 int avilable = (int)MemoryUsageCounter.TotalVisibleMemorySize * 1024 - memUsage.Committed; 256 if (avilable < (10 * 1024 *1024)) 257 { 258 suite = FaceDef.PatternSuite.MemoryInsufficient; 259 } 260 else if (memUsage.Available < (30 * 1024 *1024)) 261 { 262 suite = FaceDef.PatternSuite.MemoryDecline; 263 } 264 265 int markers = FaceDef.MarkerNone; 266 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn; 267 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut; 268 269 patternWindow.UpdatePattern(suite, pattern, markers); 270 } 271 272 if (statusWindow != null) 273 { 274 drawCPUGraph(); 275 drawMemoryGraph(); 276 statusWindow.cpuGraphPicBox.Invalidate(); 277 statusWindow.memoryGraphPicBox.Invalidate(); 278 } 279 } 280 281 public void openPatternWindow() 282 { 283 // p^[EChE 284 patternWindow = new PatternWindow(); 285 patternWindow.Closed += new EventHandler(patternWindow_Closed); 286 patternWindow.Move +=new EventHandler(patternWindow_Move); 287 288 LoadFaceDefine(config.FaceDefPath); 289 290 patternWindow.Location = config.Location; 291 patternWindow.Opacity = (float)config.Opacity / 100; 292 patternWindow.PatternSize = (float)config.PatternSize / 100; 293 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 294 patternWindow.Refresh(); 295 296 patternWindow.Show(); 297 } 298 299 public void openStatusWindow() 300 { 301 statusWindow = new StatusWindow(); 302 statusWindow.Closed += new EventHandler(statusWindow_Closed); 303 statusWindow.Move +=new EventHandler(statusWindow_Move); 304 305 FormBorderStyle orgStyle = statusWindow.FormBorderStyle; 306 statusWindow.FormBorderStyle = FormBorderStyle.Sizable; 307 statusWindow.StartPosition = FormStartPosition.Manual; 308 statusWindow.Location = config.StatusWindowLocation; 309 statusWindow.FormBorderStyle = orgStyle; 310 311 cpuGraph = new Bitmap(5*60, 100); 312 memoryGraph = new Bitmap(5*60, 100); 313 statusWindow.cpuGraphPicBox.Image = cpuGraph; 314 statusWindow.memoryGraphPicBox.Image = memoryGraph; 287 315 drawCPUGraph(); 288 316 drawMemoryGraph(); 289 statusWindow.cpuGraphPicBox.Invalidate(); 290 statusWindow. memoryGraphPicBox.Invalidate();317 318 statusWindow.Show(); 291 319 } 292 320 … … 303 331 { 304 332 updateTimer.Stop(); 305 patternWindow.Close(); 333 334 if (patternWindow != null) 335 { 336 patternWindow.Close(); 337 } 338 339 if (statusWindow != null) 340 { 341 statusWindow.Close(); 342 } 343 306 344 ExitThread(); 307 345 } … … 325 363 } 326 364 } 327 328 patternWindow.Opacity = (float)config.Opacity / 100; 329 patternWindow.PatternSize = (float)config.PatternSize / 100; 330 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 331 patternWindow.Refresh(); 365 366 if (patternWindow != null) 367 { 368 patternWindow.Opacity = (float)config.Opacity / 100; 369 patternWindow.PatternSize = (float)config.PatternSize / 100; 370 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 371 patternWindow.Refresh(); 372 } 332 373 } 333 374 … … 468 509 } 469 510 470 private void patternWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) 471 { 472 if (!doExit) 473 { 474 e.Cancel = true; 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(); 511 private void patternWindow_Closed(object sender, EventArgs e) 512 { 513 patternWindow.Dispose(); 514 patternWindow = null; 515 } 516 517 private void statusWindow_Closed(object sender, EventArgs e) 518 { 519 cpuGraph.Dispose(); 520 cpuGraph = null; 521 memoryGraph.Dispose(); 522 memoryGraph = null; 523 statusWindow.Dispose(); 524 statusWindow = null; 525 } 526 527 private void menuItemShowPatternWindow_Click(object sender, EventArgs e) 528 { 529 if (patternWindow == null) 530 { 531 openPatternWindow(); 532 } 533 } 534 535 private void menuItemShowStatusWindow_Click(object sender, EventArgs e) 536 { 537 if (statusWindow == null) 538 { 539 openStatusWindow(); 540 } 541 } 542 543 private void patternWindow_Move(object sender, EventArgs e) 544 { 545 config.Location = patternWindow.Location; 546 } 547 548 private void statusWindow_Move(object sender, EventArgs e) 549 { 550 config.StatusWindowLocation = statusWindow.Location; 485 551 } 486 552 } -
trunk/MacFaceFloat/StatusWindow.cs
r55 r58 80 80 this.AutoScaleBaseSize = new System.Drawing.Size(5, 12); 81 81 this.ClientSize = new System.Drawing.Size(314, 232); 82 this.ControlBox = false;83 82 this.Controls.Add(this.cpuGraphPicBox); 84 83 this.Controls.Add(this.memoryGraphPicBox);
Note: See TracChangeset
for help on using the changeset viewer.