2019-12-18 22:33:23 +01:00
|
|
|
|
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);
|
2020-03-19 03:39:07 +01:00
|
|
|
|
DS4Windows.Global.CacheExtraProfileInfo(deviceNum);
|
2019-12-18 22:33:23 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FireSaved()
|
|
|
|
|
{
|
|
|
|
|
ProfileSaved?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|