Changeset 38


Ignore:
Timestamp:
Feb 25, 2005, 3:31:02 AM (19 years ago)
Author:
altba\rryu
Message:

アプリケーションクラス作成に向けてのコード整理その2。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MacFaceFloat/MainForm.cs

    r35 r38  
    4040                private int curMarkers;
    4141
     42                [STAThread]
     43                public static void Main(string[] args)
     44                {
     45                        MainForm form = new MainForm();
     46                        form.StartApplication();
     47                }
     48
    4249                // ƒRƒ“ƒXƒgƒ‰ƒNƒ^
    4350                public MainForm()
     
    5966
    6067                        _updateTimer = new System.Windows.Forms.Timer();
     68                        _updateTimer.Tick += new EventHandler(this.CountProcessorUsage);
    6169                        _updateTimer.Enabled = false;
    6270                        _updateTimer.Interval = 1000;
    63                         _updateTimer.Tick += new EventHandler(this.CountProcessorUsage);
    64                         _updateTimer.Stop();
    6571                }
    6672
     
    117123                        this.Text = "MacFace For Windows";
    118124                        this.TopMost = true;
    119                         this.Load += new EventHandler(MainForm_Load);
    120                         this.Closing += new CancelEventHandler(MainForm_Closing);
    121                 }
    122                        
    123 
    124                 [STAThread]
    125                 public static void Main(string[] args)
    126                 {
    127                         Application.Run(new MainForm());
    128                 }
    129                
     125                }
     126
     127                public void StartApplication()
     128                {
     129                        // Ý’è
     130                        _config = Configuration.GetInstance();
     131                        _config.Load();
     132
     133
     134                        // Šçƒpƒ^[ƒ““ǂݍž‚Ý
     135                        bool result = false;
     136                        if (Directory.Exists(_config.FaceDefPath))
     137                        {
     138                                result = LoadFaceDefine(_config.FaceDefPath);
     139                        }
     140
     141                        if (!result)
     142                        {
     143                                if (!SelectFaceDefine(Application.StartupPath))
     144                                {
     145                                        Application.Exit();
     146                                        return;
     147                                }
     148                        }
     149
     150                        Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
     151
     152                        this.Location = _config.Location;
     153                        ApplyConfiguration();
     154
     155                        _updateTimer.Start();
     156                        Application.Run(this);
     157                }
     158
     159                void Application_ApplicationExit(object sender, EventArgs e)
     160                {
     161                        notifyIcon.Visible = false;
     162
     163                        // •Û‘¶
     164                        _config.Opacity = (int)(this.Opacity * 100);
     165                        _config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface"));
     166                        _config.Location = this.Location;
     167                        _config.TransparentMouseMessage = this.TransparentMouseMessage;
     168
     169                        _config.Save();
     170                }
    130171
    131172                /*
     
    232273                }
    233274
     275                private void ApplyConfiguration()
     276                {
     277                        this.Opacity = (float)_config.Opacity / 100;
     278                        this.PatternSize = (float)_config.PatternSize / 100;
     279                        this.TransparentMouseMessage = _config.TransparentMouseMessage;
     280
     281                        RefreshPattern();
     282                }
     283
    234284                public float PatternSize
    235285                {
     
    262312                        this.Update();
    263313                }
    264 
    265                 //
    266                 // ‹N“®
    267                 //
    268                 public void MainForm_Load(object sender, System.EventArgs e)
    269                 {
    270                         // Ý’è
    271                         _config = Configuration.GetInstance();
    272                         _config.Load();
    273 
    274 
    275                         // Šçƒpƒ^[ƒ““ǂݍž‚Ý
    276                         bool result = false;
    277                         if (Directory.Exists(_config.FaceDefPath))
    278                         {
    279                                 result = LoadFaceDefine(_config.FaceDefPath);
    280                                 ApplyConfiguration();
    281                                 _updateTimer.Start();
    282                         }
    283 
    284                         if (!result)
    285                         {
    286                                 if (!SelectFaceDefine(Application.StartupPath))
    287                                 {
    288                                         Application.Exit();
    289                                         return;
    290                                 }
    291 
    292                         }
    293                 }
    294 
    295                 //
    296                 // I—¹
    297                 //
    298                 private void MainForm_Closing(object sender, CancelEventArgs e)
    299                 {
    300                         notifyIcon.Visible = false;
    301 
    302                         // •Û‘¶
    303                         _config.Opacity = (int) (this.Opacity * 100);
    304                         _config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface"));
    305                         _config.Location = this.Location;
    306                         _config.TransparentMouseMessage = this.TransparentMouseMessage;
    307 
    308                         _config.Save();
    309                 }
    310 
    311314
    312315                /*
     
    333336                        }
    334337                }
    335 
    336                 private void ApplyConfiguration()
    337                 {
    338                         this.Opacity = (float)_config.Opacity / 100;
    339                         this.PatternSize = (float)_config.PatternSize / 100;
    340                         this.Location = _config.Location;
    341                         this.TransparentMouseMessage = _config.TransparentMouseMessage;
    342 
    343                         RefreshPattern();
    344                 }
    345338        }
    346339}
Note: See TracChangeset for help on using the changeset viewer.