Beispiel #1
0
        /// <summary>
        /// 初期化。
        /// </summary>
        public MainForm()
        {
            // Create log4net instance
            logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Initialize log4net
            log4net.Config.BasicConfigurator.Configure();

            // Create screenshot data folder path
            dataFolderPath = System.Windows.Forms.Application.StartupPath
                             + Path.DirectorySeparatorChar
                             + "data";

            databaseFilePath = dataFolderPath
                               + Path.DirectorySeparatorChar
                               + "bndr-score-recorder.db";

            settingFilePath = dataFolderPath
                              + Path.DirectorySeparatorChar
                              + "application-settings.json";

            // Read settings from file
            logger.Info("Read settings from file. setting file path = " + settingFilePath);
            setting = Setting.ParseFromFile(settingFilePath);

            if (setting == null)
            {
                logger.Info("Create new setting file.");
                MessageBox.Show("初期設定が必要です。");

                setting = new Setting();
                logger.Info("Initializing setting object complete.");

                using (ExePathSettingForm settingForm = new ExePathSettingForm(ref setting))
                {
                    if (settingForm.ShowDialog() == DialogResult.OK)
                    {
                        setting.defaultBndrOcrSetting = new BndrOcrSetting();
                        Setting.SaveToFile(setting, settingFilePath);
                        MessageBox.Show("設定を保存しました。");
                    }
                    else
                    {
                        MessageBox.Show("初期設定が実施されませんでした。終了します。");
                        Environment.Exit(EXIT_CODE_NORMAL);
                    }
                }
            }

            // Initialize component
            InitializeComponent();

            // Build music tree
            InitializeDataGridView();
            BuildMusicTreeView();
        }
Beispiel #2
0
 /// <summary>
 /// 環境設定を行うフォームを開く。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ExePathSettingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ExePathSettingForm settingForm = new ExePathSettingForm(ref setting))
     {
         if (settingForm.ShowDialog() == DialogResult.OK)
         {
             Setting.SaveToFile(setting, settingFilePath);
             MessageBox.Show("設定を保存しました。");
         }
     }
 }