Files
GameLauncher/AddKeyDialog.xaml.cs
T

53 lines
1.6 KiB
C#

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