예제 #1
0
 /// <summary>
 /// Config を読み込んでホットキーをセット
 /// </summary>
 private void SetHotkeyFromConfig()
 {
     ConfigManager.Config Config = ConfigManager.Load();
     if (Config.WinHotkey.KeyCode != Keys.None && Config.WinHotkey != null)
     {
         WinHotkey             = new HotKey(Config.WinHotkey.ModKey, Config.WinHotkey.KeyCode);
         WinHotkey.HotKeyPush += new EventHandler(WinButton_Click);
     }
     if (Config.LoseHotkey.KeyCode != Keys.None && Config.LoseHotkey != null)
     {
         LoseHotkey             = new HotKey(Config.LoseHotkey.ModKey, Config.LoseHotkey.KeyCode);
         LoseHotkey.HotKeyPush += new EventHandler(LoseButton_Click);
     }
     if (Config.DrawHotkey.KeyCode != Keys.None && Config.DrawHotkey != null)
     {
         DrawHotkey             = new HotKey(Config.DrawHotkey.ModKey, Config.DrawHotkey.KeyCode);
         DrawHotkey.HotKeyPush += new EventHandler(DrawButton_Click);
     }
 }
예제 #2
0
        /// <summary>
        /// OK ボタンをクリックした
        /// </summary>
        private void OKButton_Click(object sender, EventArgs e)
        {
            // ショートカットキーの正常確認
            if (!ValidateHotkeys())
            {
                LanguageManager.Language Language;

                // 設定に応じた言語オブジェクトを取得
                if (Properties.Settings.Default.Language == "Automatic")
                {
                    // OS の言語を取得
                    string OSLanguage = System.Globalization.CultureInfo.CurrentCulture.Name;
                    Language = LanguageManager.Get(OSLanguage);
                }
                else
                {
                    Language = LanguageManager.Get(Properties.Settings.Default.Language);
                }

                string WarningMesage = Language.InvalidHotkeyWarningMessage;
                string WarningTitle  = Language.InvalidHotkeyWarningTitle;

                DialogResult result = MessageBox.Show
                                      (
                    WarningMesage,
                    WarningTitle,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2
                                      );

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            // スコアボードの表示位置を文字列化
            string ScoreBoardPosition = ScoreBoardPositionRadio_Top.Checked ? "top" : "bottom";

            // ロゴ画像を選択した場合はアプリケーションフォルダ内に複製
            string Extension = Path.GetExtension(LogoPictureBox.ImageLocation);

            if (LogoPictureBox.ImageLocation != LogoFileNameWithoutExtension + Extension && LogoPictureBox.ImageLocation != null && LogoPictureBox.ImageLocation != string.Empty)
            {
                if (!Directory.Exists(Path.GetDirectoryName(LogoFileNameWithoutExtension)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(LogoFileNameWithoutExtension));
                }
                File.Copy(LogoPictureBox.ImageLocation, LogoFileNameWithoutExtension + Extension, true);
                LogoPictureBox.ImageLocation = LogoFileNameWithoutExtension + Extension;
            }

            // ホットキーのデータを作成
            KeysConverter kc = new KeysConverter();

            ConfigManager.HotkeyData WinHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(WinHotkeyCombobox.Text))
            {
                WinHotkey.KeyCode = (Keys)kc.ConvertFromString(WinHotkeyCombobox.Text);
            }
            if (WinHotkeyModCheckbox_Ctrl.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (WinHotkeyModCheckbox_Alt.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (WinHotkeyModCheckbox_Shift.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            ConfigManager.HotkeyData LoseHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(LoseHotkeyCombobox.Text))
            {
                LoseHotkey.KeyCode = (Keys)kc.ConvertFromString(LoseHotkeyCombobox.Text);
            }
            if (LoseHotkeyModCheckbox_Ctrl.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (LoseHotkeyModCheckbox_Alt.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (LoseHotkeyModCheckbox_Shift.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            ConfigManager.HotkeyData DrawHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(DrawHotkeyCombobox.Text))
            {
                DrawHotkey.KeyCode = (Keys)kc.ConvertFromString(DrawHotkeyCombobox.Text);
            }
            if (DrawHotkeyModCheckbox_Ctrl.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (DrawHotkeyModCheckbox_Alt.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (DrawHotkeyModCheckbox_Shift.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            // Config を作成
            ConfigManager.Config Config = new ConfigManager.Config
                                          (
                NameTextBox.Text,
                LogoPictureBox.ImageLocation,
                MainColorBox.BackColor,
                SubColorBox.BackColor,
                FontColorBox.BackColor,
                VolumeTrackbar.Value,
                ScoreBoardSizeTrackbar.Value,
                ScoreBoardPosition,
                WinHotkey,
                LoseHotkey,
                DrawHotkey,
                EnableProductionCheckbox.Checked
                                          );

            // 保存
            ConfigManager.Save(Config);

            // フォームを閉じる
            this.Close();
        }
예제 #3
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            // 最大化を無効に
            this.MaximizeBox = false;

            // コンフィグを読み込んで値をセット
            ConfigManager.Config Config = ConfigManager.Load();
            NameTextBox.Text             = Config.Name;
            LogoPictureBox.ImageLocation = Config.LogoImageFilePath;
            MainColorBox.BackColor       = ColorTranslator.FromHtml(Config.MainColorHtml);
            SubColorBox.BackColor        = ColorTranslator.FromHtml(Config.SubColorHtml);
            FontColorBox.BackColor       = ColorTranslator.FromHtml(Config.FontColorHtml);
            VolumeTrackbar.Value         = Config.SoundVolume;
            ScoreBoardSizeTrackbar.Value = Config.ScoreBoardSize;
            if (Config.ScoreBoardPosition == "top")
            {
                ScoreBoardPositionRadio_Top.Checked = true;
            }
            else
            {
                ScoreBoardPositionRadio_Bottom.Checked = true;
            }
            EnableProductionCheckbox.Checked = Config.EnableProduction;
            SetEnabledRegardingProductionControls(EnableProductionCheckbox.Checked);

            KeysConverter kc = new KeysConverter();

            if (Config.WinHotkey.KeyCode != Keys.None)
            {
                WinHotkeyCombobox.Text = kc.ConvertToString(Config.WinHotkey.KeyCode);
            }
            if (Config.WinHotkey.ModKey.HasFlag(MOD_KEY.CONTROL))
            {
                WinHotkeyModCheckbox_Ctrl.Checked = true;
            }
            if (Config.WinHotkey.ModKey.HasFlag(MOD_KEY.ALT))
            {
                WinHotkeyModCheckbox_Alt.Checked = true;
            }
            if (Config.WinHotkey.ModKey.HasFlag(MOD_KEY.SHIFT))
            {
                WinHotkeyModCheckbox_Shift.Checked = true;
            }
            if (Config.LoseHotkey.KeyCode != Keys.None)
            {
                LoseHotkeyCombobox.Text = kc.ConvertToString(Config.LoseHotkey.KeyCode);
            }
            if (Config.LoseHotkey.ModKey.HasFlag(MOD_KEY.CONTROL))
            {
                LoseHotkeyModCheckbox_Ctrl.Checked = true;
            }
            if (Config.LoseHotkey.ModKey.HasFlag(MOD_KEY.ALT))
            {
                LoseHotkeyModCheckbox_Alt.Checked = true;
            }
            if (Config.LoseHotkey.ModKey.HasFlag(MOD_KEY.SHIFT))
            {
                LoseHotkeyModCheckbox_Shift.Checked = true;
            }
            if (Config.DrawHotkey.KeyCode != Keys.None)
            {
                DrawHotkeyCombobox.Text = kc.ConvertToString(Config.DrawHotkey.KeyCode);
            }
            if (Config.DrawHotkey.ModKey.HasFlag(MOD_KEY.CONTROL))
            {
                DrawHotkeyModCheckbox_Ctrl.Checked = true;
            }
            if (Config.DrawHotkey.ModKey.HasFlag(MOD_KEY.ALT))
            {
                DrawHotkeyModCheckbox_Alt.Checked = true;
            }
            if (Config.DrawHotkey.ModKey.HasFlag(MOD_KEY.SHIFT))
            {
                DrawHotkeyModCheckbox_Shift.Checked = true;
            }

            // 言語をセット
            SetLanguage();
        }
예제 #4
0
        /// <summary>
        /// OK ボタンをクリックした
        /// </summary>
        private void OKButton_Click(object sender, EventArgs e)
        {
            // ショートカットキーの正常確認
            if (!ValidateHotkeys())
            {
                DialogResult result = MessageBox.Show
                                      (
                    "F12 キーは単体で設定しても動作しないことがあります。\r\nCtrl, Shift, Alt のいずれかと併せてご使用ください。\n\n警告を無視してこのまま続行しますか?",
                    "警告",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2
                                      );

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            // スコアボードの表示位置を文字列化
            string ScoreBoardPosition = ScoreBoardPositionRadio_Top.Checked ? "top" : "bottom";

            // ロゴ画像を選択した場合はアプリケーションフォルダ内に複製
            string Extension = Path.GetExtension(LogoPictureBox.ImageLocation);

            if (LogoPictureBox.ImageLocation != LogoFileNameWithoutExtension + Extension && LogoPictureBox.ImageLocation != null && LogoPictureBox.ImageLocation != string.Empty)
            {
                if (!Directory.Exists(Path.GetDirectoryName(LogoFileNameWithoutExtension)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(LogoFileNameWithoutExtension));
                }
                File.Copy(LogoPictureBox.ImageLocation, LogoFileNameWithoutExtension + Extension, true);
                LogoPictureBox.ImageLocation = LogoFileNameWithoutExtension + Extension;
            }

            // ホットキーのデータを作成
            KeysConverter kc = new KeysConverter();

            ConfigManager.HotkeyData WinHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(WinHotkeyCombobox.Text))
            {
                WinHotkey.KeyCode = (Keys)kc.ConvertFromString(WinHotkeyCombobox.Text);
            }
            if (WinHotkeyModCheckbox_Ctrl.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (WinHotkeyModCheckbox_Alt.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (WinHotkeyModCheckbox_Shift.Checked)
            {
                WinHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            ConfigManager.HotkeyData LoseHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(LoseHotkeyCombobox.Text))
            {
                LoseHotkey.KeyCode = (Keys)kc.ConvertFromString(LoseHotkeyCombobox.Text);
            }
            if (LoseHotkeyModCheckbox_Ctrl.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (LoseHotkeyModCheckbox_Alt.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (LoseHotkeyModCheckbox_Shift.Checked)
            {
                LoseHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            ConfigManager.HotkeyData DrawHotkey = new ConfigManager.HotkeyData();
            if (!string.IsNullOrEmpty(DrawHotkeyCombobox.Text))
            {
                DrawHotkey.KeyCode = (Keys)kc.ConvertFromString(DrawHotkeyCombobox.Text);
            }
            if (DrawHotkeyModCheckbox_Ctrl.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.CONTROL;
            }
            if (DrawHotkeyModCheckbox_Alt.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.ALT;
            }
            if (DrawHotkeyModCheckbox_Shift.Checked)
            {
                DrawHotkey.ModKey |= MOD_KEY.SHIFT;
            }

            // Config を作成
            ConfigManager.Config Config = new ConfigManager.Config
                                          (
                NameTextBox.Text,
                LogoPictureBox.ImageLocation,
                MainColorBox.BackColor,
                SubColorBox.BackColor,
                FontColorBox.BackColor,
                VolumeTrackbar.Value,
                ScoreBoardSizeTrackbar.Value,
                ScoreBoardPosition,
                WinHotkey,
                LoseHotkey,
                DrawHotkey
                                          );

            // 保存
            ConfigManager.Save(Config);

            // フォームを閉じる
            this.Close();
        }