Changeset 58
- Timestamp:
- 06/28/05 23:17:00 (4 years ago)
- Files:
-
- trunk/MacFaceFloat/MacFaceApp.cs (modified) (11 diffs)
- trunk/MacFaceFloat/StatusWindow.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
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 } … … 81 87 // �R���e�L�X�g���j���[ 82 88 ContextMenu contextMenu = new System.Windows.Forms.ContextMenu(); 83 MenuItem menuItemPatternSelect = new System.Windows.Forms.MenuItem(); 89 MenuItem menuItemShowPatternWindow = new System.Windows.Forms.MenuItem(); 90 MenuItem menuItemShowStatusWindow = new System.Windows.Forms.MenuItem(); 84 91 MenuItem menuItemConfigure = new System.Windows.Forms.MenuItem(); 85 92 MenuItem menuItemExit = new System.Windows.Forms.MenuItem(); 86 93 87 menuItemPatternSelect.Text = "���^�[���̑I��)"; 88 menuItemPatternSelect.Click += new System.EventHandler(menuItemPatternSelect_Click); 94 menuItemShowPatternWindow.Text = "�p�^�[���E�C���h�E���(&P)"; 95 menuItemShowPatternWindow.Click +=new EventHandler(menuItemShowPatternWindow_Click); 96 97 menuItemShowStatusWindow.Text = "�X�e�[�^�X�E�C���h�E���(&S)"; 98 menuItemShowStatusWindow.Click +=new EventHandler(menuItemShowStatusWindow_Click); 89 99 90 100 menuItemConfigure.Text = "MacFace �̐ݒ�C)..."; … … 96 106 97 107 contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 98 menuItem PatternSelect, menuItemConfigure, new MenuItem("-"), menuItemExit});108 menuItemShowPatternWindow, menuItemShowStatusWindow, new MenuItem("-"), menuItemConfigure, new MenuItem("-"), menuItemExit}); 99 109 100 110 // �ʒm�A�C�R�� … … 105 115 this.notifyIcon.Visible = true; 106 116 this.notifyIcon.ContextMenu = contextMenu; 107 108 // �p�^�[���E�C���h�E109 this.patternWindow = new PatternWindow();110 this.patternWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing);111 112 // �X�e�[�^�X�E�C���h�E113 cpuGraph = new Bitmap(5*60, 100);114 memoryGraph = new Bitmap(5*60, 100);115 statusWindow = new StatusWindow();116 statusWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing);117 statusWindow.cpuGraphPicBox.Image = cpuGraph;118 statusWindow.memoryGraphPicBox.Image = memoryGraph;119 117 } 120 118 … … 139 137 } 140 138 141 drawCPUGraph(); 142 drawMemoryGraph(); 143 FormBorderStyle orgStyle = statusWindow.FormBorderStyle; 144 statusWindow.FormBorderStyle = FormBorderStyle.Sizable; 145 statusWindow.StartPosition = FormStartPosition.Manual; 146 statusWindow.Location = config.StatusWindowLocation; 147 statusWindow.FormBorderStyle = orgStyle; 148 statusWindow.Show(); 149 150 patternWindow.Location = config.Location; 151 patternWindow.Opacity = (float)config.Opacity / 100; 152 patternWindow.PatternSize = (float)config.PatternSize / 100; 153 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 154 patternWindow.Refresh(); 155 156 patternWindow.Show(); 139 openPatternWindow(); 140 openStatusWindow(); 157 141 updateTimer.Start(); 158 142 159 143 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 160 Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);161 144 Application.Run(this); 162 145 } … … 166 149 notifyIcon.Visible = false; 167 150 168 // �ۑ�169 config.Location = patternWindow.Location;170 config.StatusWindowLocation = statusWindow.Location;171 151 config.Save(); 172 152 } … … 236 216 } 237 217 238 // ���^�[�������ւ����͍X�V��߂Ă��� 239 if (updateTimer != null) updateTimer.Stop(); 240 241 patternWindow.FaceDef = newFaceDef; 242 patternWindow.Refresh(); 243 244 notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title; 245 246 // �X�V�ĊJ 247 if (updateTimer != null) updateTimer.Start(); 218 if (patternWindow != null) 219 { 220 // ���^�[�������ւ����͍X�V��߂Ă��� 221 if (updateTimer != null) updateTimer.Stop(); 222 223 patternWindow.FaceDef = newFaceDef; 224 patternWindow.Refresh(); 225 226 notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title; 227 228 // �X�V�ĊJ 229 if (updateTimer != null) updateTimer.Start(); 230 } 248 231 249 232 return true; … … 263 246 if (memHistoryCount < memHistory.Length) memHistoryCount++; 264 247 265 int pattern = cpuUsage.Active / 10; 266 267 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal; 268 269 int avilable = (int)MemoryUsageCounter.TotalVisibleMemorySize * 1024 - memUsage.Committed; 270 if (avilable < (10 * 1024 *1024)) 271 { 272 suite = FaceDef.PatternSuite.MemoryInsufficient; 273 } 274 else if (memUsage.Available < (30 * 1024 *1024)) 275 { 276 suite = FaceDef.PatternSuite.MemoryDecline; 277 } 278 279 int markers = FaceDef.MarkerNone; 280 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn; 281 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut; 282 283 patternWindow.UpdatePattern(suite, pattern, markers); 284 248 if (patternWindow != null) 249 { 250 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal; 251 252 int pattern = cpuUsage.Active / 10; 253 int avilable = (int)MemoryUsageCounter.TotalVisibleMemorySize * 1024 - memUsage.Committed; 254 if (avilable < (10 * 1024 *1024)) 255 { 256 suite = FaceDef.PatternSuite.MemoryInsufficient; 257 } 258 else if (memUsage.Available < (30 * 1024 *1024)) 259 { 260 suite = FaceDef.PatternSuite.MemoryDecline; 261 } 262 263 int markers = FaceDef.MarkerNone; 264 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn; 265 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut; 266 267 patternWindow.UpdatePattern(suite, pattern, markers); 268 } 269 270 if (statusWindow != null) 271 { 272 drawCPUGraph(); 273 drawMemoryGraph(); 274 statusWindow.cpuGraphPicBox.Invalidate(); 275 statusWindow.memoryGraphPicBox.Invalidate(); 276 } 277 } 278 279 public void openPatternWindow() 280 { 281 // �p�^�[���E�C���h�E 282 patternWindow = new PatternWindow(); 283 patternWindow.Closed += new EventHandler(patternWindow_Closed); 284 patternWindow.Move +=new EventHandler(patternWindow_Move); 285 286 LoadFaceDefine(config.FaceDefPath); 287 288 patternWindow.Location = config.Location; 289 patternWindow.Opacity = (float)config.Opacity / 100; 290 patternWindow.PatternSize = (float)config.PatternSize / 100; 291 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 292 patternWindow.Refresh(); 293 294 patternWindow.Show(); 295 } 296 297 public void openStatusWindow() 298 { 299 statusWindow = new StatusWindow(); 300 statusWindow.Closed += new EventHandler(statusWindow_Closed); 301 statusWindow.Move +=new EventHandler(statusWindow_Move); 302 303 FormBorderStyle orgStyle = statusWindow.FormBorderStyle; 304 statusWindow.FormBorderStyle = FormBorderStyle.Sizable; 305 statusWindow.StartPosition = FormStartPosition.Manual; 306 statusWindow.Location = config.StatusWindowLocation; 307 statusWindow.FormBorderStyle = orgStyle; 308 309 cpuGraph = new Bitmap(5*60, 100); 310 memoryGraph = new Bitmap(5*60, 100); 311 statusWindow.cpuGraphPicBox.Image = cpuGraph; 312 statusWindow.memoryGraphPicBox.Image = memoryGraph; 285 313 drawCPUGraph(); 286 314 drawMemoryGraph(); 287 statusWindow.cpuGraphPicBox.Invalidate(); 288 statusWindow. memoryGraphPicBox.Invalidate();315 316 statusWindow.Show(); 289 317 } 290 318 … … 300 328 { 301 329 updateTimer.Stop(); 302 patternWindow.Close(); 330 331 if (patternWindow != null) 332 { 333 patternWindow.Close(); 334 } 335 336 if (statusWindow != null) 337 { 338 statusWindow.Close(); 339 } 340 303 341 ExitThread(); 304 342 } … … 322 360 } 323 361 } 324 325 patternWindow.Opacity = (float)config.Opacity / 100; 326 patternWindow.PatternSize = (float)config.PatternSize / 100; 327 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 328 patternWindow.Refresh(); 362 363 if (patternWindow != null) 364 { 365 patternWindow.Opacity = (float)config.Opacity / 100; 366 patternWindow.PatternSize = (float)config.PatternSize / 100; 367 patternWindow.TransparentMouseMessage = config.TransparentMouseMessage; 368 patternWindow.Refresh(); 369 } 329 370 } 330 371 … … 465 506 } 466 507 467 private void patternWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) 468 { 469 if (!doExit) 470 { 471 e.Cancel = true; 472 } 473 } 474 475 private void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e) 476 { 477 doExit = true; 478 updateTimer.Stop(); 479 patternWindow.Close(); 480 statusWindow.Close(); 481 ExitThread(); 508 private void patternWindow_Closed(object sender, EventArgs e) 509 { 510 patternWindow.Dispose(); 511 patternWindow = null; 512 } 513 514 private void statusWindow_Closed(object sender, EventArgs e) 515 { 516 cpuGraph.Dispose(); 517 cpuGraph = null; 518 memoryGraph.Dispose(); 519 memoryGraph = null; 520 statusWindow.Dispose(); 521 statusWindow = null; 522 } 523 524 private void menuItemShowPatternWindow_Click(object sender, EventArgs e) 525 { 526 if (patternWindow == null) 527 { 528 openPatternWindow(); 529 } 530 } 531 532 private void menuItemShowStatusWindow_Click(object sender, EventArgs e) 533 { 534 if (statusWindow == null) 535 { 536 openStatusWindow(); 537 } 538 } 539 540 private void patternWindow_Move(object sender, EventArgs e) 541 { 542 config.Location = patternWindow.Location; 543 } 544 545 private void statusWindow_Move(object sender, EventArgs e) 546 { 547 config.StatusWindowLocation = statusWindow.Location; 482 548 } 483 549 } trunk/MacFaceFloat/StatusWindow.cs
r55 r58 79 79 this.AutoScaleBaseSize = new System.Drawing.Size(5, 12); 80 80 this.ClientSize = new System.Drawing.Size(314, 232); 81 this.ControlBox = false;82 81 this.Controls.Add(this.cpuGraphPicBox); 83 82 this.Controls.Add(this.memoryGraphPicBox);
