Changeset 58

Show
Ignore:
Timestamp:
06/28/05 23:17:00 (4 years ago)
Author:
rryu
Message:

かなり無理やりウインドウを閉じられるように変更した。

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MacFaceFloat/MacFaceApp.cs

    r57 r58  
    7474                        updateTimer.Tick += new EventHandler(this.CountProcessorUsage); 
    7575 
     76                        patternWindow = null; 
     77 
     78                        cpuGraph = null; 
     79                        memoryGraph = null; 
     80                        statusWindow = null; 
     81 
    7682                        InitializeComponent(); 
    7783                } 
     
    8187                        // �R���e�L�X�g���j���[ 
    8288                        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(); 
    8491                        MenuItem menuItemConfigure = new System.Windows.Forms.MenuItem(); 
    8592                        MenuItem menuItemExit = new System.Windows.Forms.MenuItem(); 
    8693 
    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); 
    8999 
    90100                        menuItemConfigure.Text = "MacFace �̐ݒ�C)..."; 
     
    96106 
    97107                        contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 
    98                                         menuItemPatternSelect, menuItemConfigure, new MenuItem("-"), menuItemExit}); 
     108                                        menuItemShowPatternWindow, menuItemShowStatusWindow, new MenuItem("-"), menuItemConfigure, new MenuItem("-"), menuItemExit}); 
    99109 
    100110                        // �ʒm�A�C�R�� 
     
    105115                        this.notifyIcon.Visible = true; 
    106116                        this.notifyIcon.ContextMenu = contextMenu; 
    107  
    108                         // �p�^�[���E�C���h�E 
    109                         this.patternWindow = new PatternWindow(); 
    110                         this.patternWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing); 
    111  
    112                         // �X�e�[�^�X�E�C���h�E 
    113                         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; 
    119117                } 
    120118 
     
    139137                        } 
    140138 
    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(); 
    157141                        updateTimer.Start(); 
    158142 
    159143                        Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 
    160                         Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding); 
    161144                        Application.Run(this); 
    162145                } 
     
    166149                        notifyIcon.Visible = false; 
    167150 
    168                         // �ۑ� 
    169                         config.Location = patternWindow.Location; 
    170                         config.StatusWindowLocation = statusWindow.Location; 
    171151                        config.Save(); 
    172152                } 
     
    236216                        } 
    237217 
    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                        } 
    248231 
    249232                        return true; 
     
    263246                        if (memHistoryCount < memHistory.Length) memHistoryCount++; 
    264247 
    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; 
    285313                        drawCPUGraph(); 
    286314                        drawMemoryGraph(); 
    287                         statusWindow.cpuGraphPicBox.Invalidate(); 
    288                         statusWindow.memoryGraphPicBox.Invalidate(); 
     315 
     316                        statusWindow.Show(); 
    289317                } 
    290318 
     
    300328                { 
    301329                        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 
    303341                        ExitThread(); 
    304342                } 
     
    322360                                } 
    323361                        } 
    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                        } 
    329370                } 
    330371 
     
    465506                } 
    466507 
    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; 
    482548                } 
    483549        } 
  • trunk/MacFaceFloat/StatusWindow.cs

    r55 r58  
    7979                        this.AutoScaleBaseSize = new System.Drawing.Size(5, 12); 
    8080                        this.ClientSize = new System.Drawing.Size(314, 232); 
    81                         this.ControlBox = false; 
    8281                        this.Controls.Add(this.cpuGraphPicBox); 
    8382                        this.Controls.Add(this.memoryGraphPicBox);