Changeset 38

Show
Ignore:
Timestamp:
02/25/05 03:31:02 (4 years ago)
Author:
altba\rryu
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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                        // �ݒ�                  _config = Configuration.GetInstance(); 
     130                        _config.Load(); 
     131 
     132 
     133                        // ���^�[���ǂݍ��� 
     134                        bool result = false; 
     135                        if (Directory.Exists(_config.FaceDefPath)) 
     136                        { 
     137                                result = LoadFaceDefine(_config.FaceDefPath); 
     138                        } 
     139 
     140                        if (!result) 
     141                        { 
     142                                if (!SelectFaceDefine(Application.StartupPath)) 
     143                                { 
     144                                        Application.Exit(); 
     145                                        return; 
     146                                } 
     147                        } 
     148 
     149                        Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 
     150 
     151                        this.Location = _config.Location; 
     152                        ApplyConfiguration(); 
     153 
     154                        _updateTimer.Start(); 
     155                        Application.Run(this); 
     156                } 
     157 
     158                void Application_ApplicationExit(object sender, EventArgs e) 
     159                { 
     160                        notifyIcon.Visible = false; 
     161 
     162                        // �ۑ� 
     163                        _config.Opacity = (int)(this.Opacity * 100); 
     164                        _config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface")); 
     165                        _config.Location = this.Location; 
     166                        _config.TransparentMouseMessage = this.TransparentMouseMessage; 
     167 
     168                        _config.Save(); 
     169                } 
    130170 
    131171                /* 
     
    232272                } 
    233273 
     274                private void ApplyConfiguration() 
     275                { 
     276                        this.Opacity = (float)_config.Opacity / 100; 
     277                        this.PatternSize = (float)_config.PatternSize / 100; 
     278                        this.TransparentMouseMessage = _config.TransparentMouseMessage; 
     279 
     280                        RefreshPattern(); 
     281                } 
     282 
    234283                public float PatternSize 
    235284                { 
     
    263312                } 
    264313 
    265                 // 
    266                 // �N�� 
    267                 // 
    268                 public void MainForm_Load(object sender, System.EventArgs e) 
    269                 { 
    270                         // �ݒ�                  _config = Configuration.GetInstance(); 
    271                         _config.Load(); 
    272  
    273  
    274                         // ���^�[���ǂݍ��� 
    275                         bool result = false; 
    276                         if (Directory.Exists(_config.FaceDefPath)) 
    277                         { 
    278                                 result = LoadFaceDefine(_config.FaceDefPath); 
    279                                 ApplyConfiguration(); 
    280                                 _updateTimer.Start(); 
    281                         } 
    282  
    283                         if (!result) 
    284                         { 
    285                                 if (!SelectFaceDefine(Application.StartupPath)) 
    286                                 { 
    287                                         Application.Exit(); 
    288                                         return; 
    289                                 } 
    290  
    291                         } 
    292                 } 
    293  
    294                 //  
    295                 // �I�� 
    296                 // 
    297                 private void MainForm_Closing(object sender, CancelEventArgs e) 
    298                 { 
    299                         notifyIcon.Visible = false; 
    300  
    301                         // �ۑ� 
    302                         _config.Opacity = (int) (this.Opacity * 100); 
    303                         _config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface")); 
    304                         _config.Location = this.Location; 
    305                         _config.TransparentMouseMessage = this.TransparentMouseMessage; 
    306  
    307                         _config.Save(); 
    308                 } 
    309  
    310  
    311314                /* 
    312315                 * ���j���[�N���b�N�C�x���g 
     
    331334                        } 
    332335                } 
    333  
    334                 private void ApplyConfiguration() 
    335                 { 
    336                         this.Opacity = (float)_config.Opacity / 100; 
    337                         this.PatternSize = (float)_config.PatternSize / 100; 
    338                         this.Location = _config.Location; 
    339                         this.TransparentMouseMessage = _config.TransparentMouseMessage; 
    340  
    341                         RefreshPattern(); 
    342                 } 
    343336        } 
    344337}