2022-12-20 22:52:56 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
using CommonHelpers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PowerControl.Helper
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ProfileSettings : BaseSettings
|
|
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
public static String UserProfilesPath
|
2022-12-20 22:52:56 +01:00
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
|
|
|
|
var exeFolder = Path.GetDirectoryName(exePath) ?? Directory.GetCurrentDirectory();
|
2023-01-10 11:31:09 +01:00
|
|
|
|
var exeGameProfiles = Path.Combine(exeFolder, "GameProfiles");
|
|
|
|
|
|
if (!Directory.Exists(exeGameProfiles))
|
|
|
|
|
|
Directory.CreateDirectory(exeGameProfiles);
|
|
|
|
|
|
return exeGameProfiles;
|
2023-01-05 23:35:31 +01:00
|
|
|
|
}
|
2022-12-20 22:52:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-05 23:35:31 +01:00
|
|
|
|
public String ProfileName { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public ProfileSettings(string profileName) : base("PersistentSettings")
|
2022-12-20 22:52:56 +01:00
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
this.ProfileName = profileName;
|
|
|
|
|
|
this.ConfigFile = Path.Combine(UserProfilesPath, String.Format("PowerControl.Process.{0}.ini", profileName));
|
2022-12-20 22:52:56 +01:00
|
|
|
|
|
|
|
|
|
|
this.SettingChanging += delegate { };
|
|
|
|
|
|
this.SettingChanged += delegate { };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-05 23:35:31 +01:00
|
|
|
|
public String? GetValue(string key)
|
2022-12-20 22:52:56 +01:00
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
var result = base.Get(key, String.Empty);
|
|
|
|
|
|
if (result == String.Empty)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
return result;
|
2022-12-20 22:52:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-05 23:35:31 +01:00
|
|
|
|
public int GetInt(string key, int defaultValue)
|
2022-12-20 22:52:56 +01:00
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
return base.Get(key, defaultValue);
|
2022-12-20 22:52:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-05 23:35:31 +01:00
|
|
|
|
public void SetValue(string key, string value)
|
2022-12-20 22:52:56 +01:00
|
|
|
|
{
|
2023-01-05 23:35:31 +01:00
|
|
|
|
base.Set(key, value);
|
2022-12-20 22:52:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|