Changeset 58


Ignore:
Timestamp:
Jun 28, 2005, 11:17:00 PM (19 years ago)
Author:
rryu
Message:

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

Location:
trunk/MacFaceFloat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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                }
     
    8288[
    8389                        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();
    8592                        MenuItem menuItemConfigure = new System.Windows.Forms.MenuItem();
    8693                        MenuItem menuItemExit = new System.Windows.Forms.MenuItem();
    8794
    88                         menuItemPatternSelect.Text = "Šçƒpƒ^[ƒ“‚Ì‘I‘ð(&S)";
    89                         menuItemPatternSelect.Click += new System.EventHandler(menuItemPatternSelect_Click);
     95                        menuItemShowPatternWindow.Text = "ƒpƒ^[ƒ“ƒEƒCƒ“ƒhƒE‚ðŠJ‚­(&P)";
     96                        menuItemShowPatternWindow.Click +=new EventHandler(menuItemShowPatternWindow_Click);
     97
     98                        menuItemShowStatusWindow.Text = "ƒXƒe[ƒ^ƒXƒEƒCƒ“ƒhƒE‚ðŠJ‚­(&S)";
     99                        menuItemShowStatusWindow.Click +=new EventHandler(menuItemShowStatusWindow_Click);
    90100
    91101                        menuItemConfigure.Text = "MacFace ‚̐ݒè(&C)...";
     
    97107
    98108                        contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
    99                                         menuItemPatternSelect, menuItemConfigure, new MenuItem("-"), menuItemExit});
     109                                        menuItemShowPatternWindow, menuItemShowStatusWindow, new MenuItem("-"), menuItemConfigure, new MenuItem("-"), menuItemExit});
    100110
    101111                        // ’Ê’mƒAƒCƒRƒ“
     
    106116                        this.notifyIcon.Visible = true;
    107117                        this.notifyIcon.ContextMenu = contextMenu;
    108 
    109                         // ƒpƒ^[ƒ“ƒEƒCƒ“ƒhƒE
    110                         this.patternWindow = new PatternWindow();
    111                         this.patternWindow.Closing += new System.ComponentModel.CancelEventHandler(patternWindow_Closing);
    112 
    113                         // ƒXƒe[ƒ^ƒXƒEƒCƒ“ƒhƒE
    114                         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;
    120118                }
    121119
     
    140138                        }
    141139
    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();
    158142                        updateTimer.Start();
    159143
    160144                        Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
    161                         Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);
    162145                        Application.Run(this);
    163146                }
     
    167150                        notifyIcon.Visible = false;
    168151
    169                         // •Û‘¶
    170                         config.Location = patternWindow.Location;
    171                         config.StatusWindowLocation = statusWindow.Location;
    172152                        config.Save();
    173153                }
     
    238218                        }
    239219
    240                         // Šçƒpƒ^[ƒ“·‚µ‘Ö‚¦’†‚͍XV‚ðŽ~‚ß‚Ä‚¨‚­
    241                         if (updateTimer != null) updateTimer.Stop();
    242 
    243                         patternWindow.FaceDef = newFaceDef;
    244                         patternWindow.Refresh();
    245 
    246                         notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title;
    247 
    248                         // XVÄŠJ
    249                         if (updateTimer != null) updateTimer.Start();
     220                        if (patternWindow != null)
     221                        {
     222                                // Šçƒpƒ^[ƒ“·‚µ‘Ö‚¦’†‚͍XV‚ðŽ~‚ß‚Ä‚¨‚­
     223                                if (updateTimer != null) updateTimer.Stop();
     224
     225                                patternWindow.FaceDef = newFaceDef;
     226                                patternWindow.Refresh();
     227
     228                                notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title;
     229
     230                                // XVÄŠJ
     231                                if (updateTimer != null) updateTimer.Start();
     232                        }
    250233
    251234                        return true;
     
    265248                        if (memHistoryCount < memHistory.Length) memHistoryCount++;
    266249
    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ƒ^[ƒ“ƒEƒCƒ“ƒhƒE
     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;
    287315                        drawCPUGraph();
    288316                        drawMemoryGraph();
    289                         statusWindow.cpuGraphPicBox.Invalidate();
    290                         statusWindow.memoryGraphPicBox.Invalidate();
     317
     318                        statusWindow.Show();
    291319                }
    292320
     
    303331                {
    304332                        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
    306344                        ExitThread();
    307345                }
     
    325363                                }
    326364                        }
    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                        }
    332373                }
    333374
     
    468509                }
    469510
    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;
    485551                }
    486552        }
  • trunk/MacFaceFloat/StatusWindow.cs

    r55 r58  
    8080                        this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
    8181                        this.ClientSize = new System.Drawing.Size(314, 232);
    82                         this.ControlBox = false;
    8382                        this.Controls.Add(this.cpuGraphPicBox);
    8483                        this.Controls.Add(this.memoryGraphPicBox);
Note: See TracChangeset for help on using the changeset viewer.