using System.Windows; using System.Windows.Controls; using GameLauncher.Models; using GameLauncher.Engines.Unity; namespace GameLauncher { /// /// PlayerPrefsキー追加ダイアログ /// public partial class AddKeyDialog : Window { public string KeyName { get; private set; } = string.Empty; public PlayerPrefsType KeyType { get; private set; } = PlayerPrefsType.Int; public string KeyValue { get; private set; } = string.Empty; public AddKeyDialog() { this.InitializeComponent(); this.txtKeyName.Focus(); } private void btnOk_Click(object sender, RoutedEventArgs e) { var keyName = this.txtKeyName.Text.Trim(); if (string.IsNullOrWhiteSpace(keyName)) { MessageBox.Show("キー名を入力してください。", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Warning); return; } this.KeyName = keyName; var selectedTag = (this.cmbKeyType.SelectedItem as ComboBoxItem)?.Tag?.ToString(); this.KeyType = selectedTag switch { "Float" => PlayerPrefsType.Float, "String" => PlayerPrefsType.String, _ => PlayerPrefsType.Int }; this.KeyValue = this.txtKeyValue.Text; this.DialogResult = true; this.Close(); } private void btnCancel_Click(object sender, RoutedEventArgs e) { this.DialogResult = false; this.Close(); } } }