cemu-DS4Windows/DS4Windows/ProfileEntity.cs
2019-12-18 15:33:23 -06:00

58 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS4WinWPF
{
public class ProfileEntity
{
private string name;
public string Name
{
get => name;
set
{
if (name == value) return;
name = value;
NameChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler NameChanged;
public event EventHandler ProfileSaved;
public event EventHandler ProfileDeleted;
public void DeleteFile()
{
if (!string.IsNullOrWhiteSpace(name))
{
string filepath = DS4Windows.Global.appdatapath + @"\Profiles\" + name + ".xml";
if (File.Exists(filepath))
{
File.Delete(filepath);
ProfileDeleted?.Invoke(this, EventArgs.Empty);
}
}
}
public void SaveProfile(int deviceNum)
{
if (!string.IsNullOrWhiteSpace(name))
{
DS4Windows.Global.SaveProfile(deviceNum, name);
DS4Windows.Global.calculateProfileActionCount(deviceNum);
DS4Windows.Global.calculateProfileActionDicts(deviceNum);
DS4Windows.Global.cacheProfileCustomsFlags(deviceNum);
}
}
public void FireSaved()
{
ProfileSaved?.Invoke(this, EventArgs.Empty);
}
}
}