public async void AddProfile()
{
if (_mainManager.DeviceManager.ActiveKeyboard == null)
{
DialogService.ShowMessageBox("Cannot add profile.",
"To add a profile, please select a keyboard in the options menu first.");
return;
}
var name = await DialogService.ShowInputDialog("Add new profile",
"Please provide a profile name unique to this game and keyboard.");
// Null when the user cancelled
if (name == null)
return;
if (name.Length < 2)
{
DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
return;
}
var profile = new ProfileModel
{
Name = name,
KeyboardSlug = _mainManager.DeviceManager.ActiveKeyboard.Slug,
Width = _mainManager.DeviceManager.ActiveKeyboard.Width,
Height = _mainManager.DeviceManager.ActiveKeyboard.Height,
GameName = _gameModel.Name
};
if (ProfileProvider.GetAll().Contains(profile))
{
var overwrite = await DialogService.ShowQuestionMessageBox("Overwrite existing profile",
"A profile with this name already exists for this game. Would you like to overwrite it?");
if (!overwrite.Value)
return;
}
ProfileProvider.AddOrUpdate(profile);
LoadProfiles();
SelectedProfile = profile;
}