mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Transitioned Profiles to using ProfileRepository
Moving to using a ProfileRespository will make it easier when moving to a WPF style app, and it will allow some freedom if I want to change the storage to a database or soemthing different.
This commit is contained in:
@ -60,7 +60,7 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
args.Add($"-p \"{profile.Id}\"");
|
args.Add($"-p \"{profile.UUID}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(programAddress))
|
if (!string.IsNullOrWhiteSpace(programAddress))
|
||||||
@ -108,7 +108,7 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
args.Add($"-p \"{profile.Id}\"");
|
args.Add($"-p \"{profile.UUID}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (steamAppId > 0)
|
if (steamAppId > 0)
|
||||||
|
@ -40,6 +40,11 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="ResizeDrawing.cs" />
|
<Compile Include="ResizeDrawing.cs" />
|
||||||
<Compile Include="RestartManagerSession.cs" />
|
<Compile Include="RestartManagerSession.cs" />
|
||||||
<Compile Include="ScanLineOrdering.cs" />
|
<Compile Include="ScanLineOrdering.cs" />
|
||||||
@ -54,6 +59,7 @@
|
|||||||
<Compile Include="Rotation.cs" />
|
<Compile Include="Rotation.cs" />
|
||||||
<Compile Include="Scaling.cs" />
|
<Compile Include="Scaling.cs" />
|
||||||
<Compile Include="ShellHelper.cs" />
|
<Compile Include="ShellHelper.cs" />
|
||||||
|
<Compile Include="ProfileRepository.cs" />
|
||||||
<Compile Include="TaskBarSettings.cs" />
|
<Compile Include="TaskBarSettings.cs" />
|
||||||
<Compile Include="TaskBarStuckRectangle.cs" />
|
<Compile Include="TaskBarStuckRectangle.cs" />
|
||||||
<Compile Include="Topology\ProfileViewport.cs" />
|
<Compile Include="Topology\ProfileViewport.cs" />
|
||||||
@ -73,6 +79,10 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Resources\Language.resx">
|
<EmbeddedResource Include="Resources\Language.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Language.Designer.cs</LastGenOutput>
|
<LastGenOutput>Language.Designer.cs</LastGenOutput>
|
||||||
|
@ -15,12 +15,12 @@ using HeliosPlus.Shared.Topology;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using WindowsDisplayAPI;
|
using WindowsDisplayAPI;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace HeliosPlus.Shared
|
namespace HeliosPlus.Shared
|
||||||
{
|
{
|
||||||
public class ProfileItem
|
public class ProfileItem
|
||||||
{
|
{
|
||||||
private static ProfileItem _currentProfile;
|
|
||||||
private static List<ProfileItem> _allSavedProfiles = new List<ProfileItem>();
|
private static List<ProfileItem> _allSavedProfiles = new List<ProfileItem>();
|
||||||
private ProfileIcon _profileIcon;
|
private ProfileIcon _profileIcon;
|
||||||
private Bitmap _profileBitmap, _profileShortcutBitmap;
|
private Bitmap _profileBitmap, _profileShortcutBitmap;
|
||||||
@ -29,6 +29,11 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||||
|
|
||||||
|
private string _uuid;
|
||||||
|
private Version _version;
|
||||||
|
private bool _isActive = false;
|
||||||
|
private bool _isPossible = false;
|
||||||
|
|
||||||
|
|
||||||
#region JsonConverterBitmap
|
#region JsonConverterBitmap
|
||||||
internal class CustomBitmapConverter : JsonConverter
|
internal class CustomBitmapConverter : JsonConverter
|
||||||
@ -104,14 +109,22 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
public static Version Version = new Version(2, 1);
|
public static Version Version = new Version(2, 1);
|
||||||
|
|
||||||
public string Id { get; set; } = Guid.NewGuid().ToString("B");
|
#region Instance Properties
|
||||||
|
|
||||||
[JsonIgnore]
|
public string UUID
|
||||||
public bool IsActive
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _currentProfile.Equals(this);
|
if (String.IsNullOrWhiteSpace(_uuid))
|
||||||
|
_uuid = Guid.NewGuid().ToString("B");
|
||||||
|
return _uuid;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
string uuidV4Regex = @"/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i";
|
||||||
|
Match match = Regex.Match(value, uuidV4Regex, RegexOptions.IgnoreCase);
|
||||||
|
if (match.Success)
|
||||||
|
_uuid = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,34 +165,6 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
public ProfileViewport[] Viewports { get; set; } = new ProfileViewport[0];
|
public ProfileViewport[] Viewports { get; set; } = new ProfileViewport[0];
|
||||||
|
|
||||||
public static string SavedProfilesFilePath
|
|
||||||
{
|
|
||||||
get => System.IO.Path.Combine(AppDataPath, $"Profiles\\DisplayProfiles_{Version.ToString(2)}.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string SavedProfilesPath
|
|
||||||
{
|
|
||||||
get => System.IO.Path.Combine(AppDataPath, $"Profiles");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ProfileItem> AllSavedProfiles
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_allSavedProfiles.Count == 0)
|
|
||||||
{
|
|
||||||
ProfileItem.LoadAllProfiles();
|
|
||||||
}
|
|
||||||
return _allSavedProfiles;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProfileItem CurrentProfile
|
|
||||||
{
|
|
||||||
get => _currentProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ProfileIcon ProfileIcon
|
public ProfileIcon ProfileIcon
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -199,8 +184,7 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SavedProfileCacheFilename { get; set; }
|
public string SavedProfileIconCacheFilename { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[JsonConverter(typeof(CustomBitmapConverter))]
|
[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
public Bitmap ProfileBitmap
|
public Bitmap ProfileBitmap
|
||||||
@ -242,82 +226,7 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ProfileItem> LoadAllProfiles()
|
#endregion
|
||||||
{
|
|
||||||
|
|
||||||
if (File.Exists(SavedProfilesFilePath))
|
|
||||||
{
|
|
||||||
var json = File.ReadAllText(SavedProfilesFilePath, Encoding.Unicode);
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(json))
|
|
||||||
{
|
|
||||||
List<ProfileItem> profiles = new List<ProfileItem>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//var profiles = JsonConvert.DeserializeObject<Profile[]>(json, new JsonSerializerSettings
|
|
||||||
profiles = JsonConvert.DeserializeObject<List<ProfileItem>>(json, new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
MissingMemberHandling = MissingMemberHandling.Ignore,
|
|
||||||
NullValueHandling = NullValueHandling.Ignore,
|
|
||||||
DefaultValueHandling = DefaultValueHandling.Include,
|
|
||||||
TypeNameHandling = TypeNameHandling.Auto
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
Console.WriteLine("Unable to deserialize profile: " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Convert array to list
|
|
||||||
//List<Profile> profilesList = profiles.ToList<Profile>();
|
|
||||||
|
|
||||||
// Find which entry is being used now, and save that info in a class variable
|
|
||||||
ProfileItem myCurrentProfile = new ProfileItem
|
|
||||||
{
|
|
||||||
Name = "Current Display Profile",
|
|
||||||
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
|
||||||
};
|
|
||||||
|
|
||||||
_currentProfile = myCurrentProfile;
|
|
||||||
|
|
||||||
foreach (ProfileItem loadedProfile in profiles)
|
|
||||||
{
|
|
||||||
// Save a profile Icon to the profile
|
|
||||||
loadedProfile.ProfileIcon = new ProfileIcon(loadedProfile);
|
|
||||||
loadedProfile.ProfileBitmap = loadedProfile.ProfileIcon.ToBitmap(128,128);
|
|
||||||
|
|
||||||
if (loadedProfile.IsActive) {
|
|
||||||
_currentProfile = loadedProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_allSavedProfiles = profiles;
|
|
||||||
|
|
||||||
return _allSavedProfiles;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, then we don't have any profiles saved!
|
|
||||||
// So we gotta start from scratch
|
|
||||||
// Create a new profile based on our current display settings
|
|
||||||
_currentProfile = new ProfileItem
|
|
||||||
{
|
|
||||||
Name = "Current Display Profile",
|
|
||||||
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Save a profile Icon to the profile
|
|
||||||
_currentProfile.ProfileIcon = new ProfileIcon(_currentProfile);
|
|
||||||
_currentProfile.ProfileBitmap = _currentProfile.ProfileIcon.ToBitmap(128, 128);
|
|
||||||
|
|
||||||
// Create a new empty list of all our display profiles as we don't have any saved!
|
|
||||||
_allSavedProfiles = new List<ProfileItem>();
|
|
||||||
|
|
||||||
return _allSavedProfiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsValidName(string testName)
|
public static bool IsValidName(string testName)
|
||||||
{
|
{
|
||||||
@ -334,89 +243,33 @@ namespace HeliosPlus.Shared
|
|||||||
|
|
||||||
public static bool IsValidId(string testId)
|
public static bool IsValidId(string testId)
|
||||||
{
|
{
|
||||||
foreach (ProfileItem loadedProfile in _allSavedProfiles)
|
string uuidV4Regex = @"/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i";
|
||||||
{
|
Match match = Regex.Match(testId, uuidV4Regex, RegexOptions.IgnoreCase);
|
||||||
if (loadedProfile.Id == testId)
|
if (match.Success)
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void UpdateCurrentProfile()
|
|
||||||
{
|
|
||||||
_currentProfile = new ProfileItem
|
|
||||||
{
|
|
||||||
Name = "Current Display Profile",
|
|
||||||
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool SaveAllProfiles()
|
|
||||||
{
|
|
||||||
if (SaveAllProfiles(_allSavedProfiles))
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SaveAllProfiles(List<ProfileItem> profilesToSave)
|
|
||||||
|
public bool CopyTo(ProfileItem profile, bool overwriteId = false)
|
||||||
{
|
{
|
||||||
|
if (!(profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!Directory.Exists(SavedProfilesPath))
|
if (overwriteId)
|
||||||
{
|
profile.UUID = UUID;
|
||||||
try
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(SavedProfilesPath);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Unable to create Profile folder " + SavedProfilesPath + ": " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Copy all our profile data over to the other profile
|
||||||
// Now we loop over the profiles and save their images for later
|
profile.Name = Name;
|
||||||
foreach (ProfileItem profileToSave in profilesToSave)
|
profile.UUID = UUID;
|
||||||
{
|
profile.Name = Name;
|
||||||
profileToSave.SaveProfileImageToCache();
|
profile.Viewports = Viewports;
|
||||||
}
|
profile.ProfileIcon = ProfileIcon;
|
||||||
|
profile.SavedProfileIconCacheFilename = SavedProfileIconCacheFilename;
|
||||||
try
|
profile.ProfileBitmap = ProfileBitmap;
|
||||||
{
|
profile.ProfileTightestBitmap = ProfileTightestBitmap;
|
||||||
var json = JsonConvert.SerializeObject(profilesToSave, Formatting.Indented, new JsonSerializerSettings
|
return true;
|
||||||
{
|
|
||||||
NullValueHandling = NullValueHandling.Include,
|
|
||||||
DefaultValueHandling = DefaultValueHandling.Populate,
|
|
||||||
TypeNameHandling = TypeNameHandling.Auto
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(json))
|
|
||||||
{
|
|
||||||
var dir = System.IO.Path.GetDirectoryName(SavedProfilesPath);
|
|
||||||
|
|
||||||
if (dir != null)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
File.WriteAllText(SavedProfilesFilePath, json, Encoding.Unicode);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Unable to serialize profile: " + ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overwrite the list of saved profiles as the new lot we received.
|
|
||||||
_allSavedProfiles = profilesToSave;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -481,22 +334,7 @@ namespace HeliosPlus.Shared
|
|||||||
return uncheckedFilename;
|
return uncheckedFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SaveProfileImageToCache()
|
public void ApplyTopos()
|
||||||
{
|
|
||||||
this.SavedProfileCacheFilename = Path.Combine(SavedProfilesPath, GetValidFilename(String.Concat(this.Name + @".png")));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.ProfileBitmap.Save(this.SavedProfileCacheFilename, ImageFormat.Png);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Unable to create profile image in cache using " + this.SavedProfileCacheFilename + ": " + ex.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _applyTopos()
|
|
||||||
{
|
{
|
||||||
Debug.Print("_applyTopos()");
|
Debug.Print("_applyTopos()");
|
||||||
try
|
try
|
||||||
@ -533,7 +371,7 @@ namespace HeliosPlus.Shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _applyPathInfos()
|
public void ApplyPathInfos()
|
||||||
{
|
{
|
||||||
Debug.Print("_applyPathInfos()");
|
Debug.Print("_applyPathInfos()");
|
||||||
if (!IsPossible)
|
if (!IsPossible)
|
||||||
@ -550,8 +388,8 @@ namespace HeliosPlus.Shared
|
|||||||
{
|
{
|
||||||
var dict = new Dictionary<string, Action>()
|
var dict = new Dictionary<string, Action>()
|
||||||
{
|
{
|
||||||
{ "Applying_Topos", _applyTopos },
|
{ "Applying_Topos", ApplyTopos },
|
||||||
{ "Applying_Paths", _applyPathInfos }
|
{ "Applying_Paths", ApplyPathInfos }
|
||||||
};
|
};
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
@ -572,41 +410,6 @@ namespace HeliosPlus.Shared
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Apply()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
Debug.Print("Begin profile change");
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
_applyTopos();
|
|
||||||
|
|
||||||
Debug.Print("Finished setting topologies");
|
|
||||||
Debug.Print("Sleep");
|
|
||||||
Thread.Sleep(18000);
|
|
||||||
Debug.Print("Awake");
|
|
||||||
|
|
||||||
_applyPathInfos();
|
|
||||||
|
|
||||||
Debug.Print("Applying pathInfos");
|
|
||||||
Debug.Print("Sleep");
|
|
||||||
Thread.Sleep(10000);
|
|
||||||
Debug.Print("Awake");
|
|
||||||
|
|
||||||
UpdateCurrentProfile();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
UpdateCurrentProfile();
|
|
||||||
Console.WriteLine($"Profile: Problem applying the '{Name}' Display Profile: {ex.Message}");
|
|
||||||
MessageBox.Show($"Problem applying the '{Name}' Display Profile! \n(ex.Message)", $"Problem applying '{Name}' Profile", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom comparer for the Profile class
|
// Custom comparer for the Profile class
|
||||||
|
583
HeliosPlus.Shared/ProfileRepository.cs
Normal file
583
HeliosPlus.Shared/ProfileRepository.cs
Normal file
@ -0,0 +1,583 @@
|
|||||||
|
using HeliosPlus.Shared;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.IconLib;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using WindowsDisplayAPI.DisplayConfig;
|
||||||
|
using HeliosPlus.Shared.Resources;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NvAPIWrapper.Mosaic;
|
||||||
|
using NvAPIWrapper.Native.Mosaic;
|
||||||
|
using HeliosPlus.Shared.Topology;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using WindowsDisplayAPI;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Resources;
|
||||||
|
|
||||||
|
namespace HeliosPlus.Shared
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ProfileRepository
|
||||||
|
{
|
||||||
|
#region Class Variables
|
||||||
|
// Common items to the class
|
||||||
|
private static List<ProfileItem> _allProfiles = new List<ProfileItem>();
|
||||||
|
public static Version Version = new Version(1, 0, 0);
|
||||||
|
// Other constants that are useful
|
||||||
|
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||||
|
public static string AppIconPath = Path.Combine(AppDataPath, $"Icons");
|
||||||
|
public static string AppHeliosPlusIconFilename = Path.Combine(AppIconPath, @"HeliosPlus.ico");
|
||||||
|
private static string _profileStorageJsonPath = Path.Combine(AppDataPath, $"Profiles");
|
||||||
|
private static string _profileStorageJsonFileName = Path.Combine(_profileStorageJsonPath, $"DisplayProfiles_{Version.ToString(2)}.json");
|
||||||
|
private static uint _lastProfileId;
|
||||||
|
private static ProfileItem _currentProfile;
|
||||||
|
private static List<Display> _availableDisplays;
|
||||||
|
private static List<UnAttachedDisplay> _unavailableDisplays;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Instance Variables
|
||||||
|
// Individual items per class instance
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Class Constructors
|
||||||
|
public ProfileRepository()
|
||||||
|
{
|
||||||
|
// Load the Profiles from storage
|
||||||
|
LoadProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfileRepository(ProfileItem Profile) : this()
|
||||||
|
{
|
||||||
|
if (Profile is ProfileItem)
|
||||||
|
AddProfile(Profile);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Class Properties
|
||||||
|
public static List<ProfileItem> AllProfiles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_allProfiles == null)
|
||||||
|
// Load the Profiles from storage if they need to be
|
||||||
|
LoadProfiles();
|
||||||
|
return _allProfiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem CurrentProfile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
UpdateActiveProfile();
|
||||||
|
return _currentProfile;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value is ProfileItem)
|
||||||
|
{
|
||||||
|
_currentProfile = value;
|
||||||
|
// And if we have the _originalBitmap we can also save the Bitmap overlay, but only if the ProfileToUse is set
|
||||||
|
//if (_originalBitmap is Bitmap)
|
||||||
|
// _shortcutBitmap = ToBitmapOverlay(_originalBitmap, ProfileToUse.ProfileTightestBitmap, 256, 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ProfileCount
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _allProfiles.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Class Methods
|
||||||
|
public static bool AddProfile(ProfileItem Profile)
|
||||||
|
{
|
||||||
|
if (!(Profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Doublecheck if it already exists
|
||||||
|
// Because then we just update the one that already exists
|
||||||
|
if (ContainsProfile(Profile))
|
||||||
|
{
|
||||||
|
// We update the existing Profile with the data over
|
||||||
|
ProfileItem ProfileToUpdate = GetProfile(Profile.UUID);
|
||||||
|
Profile.CopyTo(ProfileToUpdate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add the Profile to the list of Profiles
|
||||||
|
_allProfiles.Add(Profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Doublecheck it's been added
|
||||||
|
if (ContainsProfile(Profile))
|
||||||
|
{
|
||||||
|
// Generate the Profile Icon ready to be used
|
||||||
|
SaveProfileIconToCache(Profile);
|
||||||
|
|
||||||
|
// Save the Profiles JSON as it's different
|
||||||
|
SaveProfiles();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RemoveProfile(ProfileItem Profile)
|
||||||
|
{
|
||||||
|
if (!(Profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove the Profile Icons from the Cache
|
||||||
|
List<ProfileItem> ProfilesToRemove = _allProfiles.FindAll(item => item.UUID.Equals(Profile.UUID));
|
||||||
|
foreach (ProfileItem ProfileToRemove in ProfilesToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// TODO check and report
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the Profile from the list.
|
||||||
|
int numRemoved = _allProfiles.RemoveAll(item => item.UUID.Equals(Profile.UUID));
|
||||||
|
|
||||||
|
if (numRemoved == 1)
|
||||||
|
{
|
||||||
|
SaveProfiles();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (numRemoved == 0)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
throw new ProfileRepositoryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool RemoveProfile(string ProfileName)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrWhiteSpace(ProfileName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove the Profile Icons from the Cache
|
||||||
|
List<ProfileItem> ProfilesToRemove = _allProfiles.FindAll(item => item.Name.Equals(ProfileName));
|
||||||
|
foreach (ProfileItem ProfileToRemove in ProfilesToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// TODO check and report
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the Profile from the list.
|
||||||
|
int numRemoved = _allProfiles.RemoveAll(item => item.Name.Equals(ProfileName));
|
||||||
|
|
||||||
|
if (numRemoved == 1)
|
||||||
|
{
|
||||||
|
SaveProfiles();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (numRemoved == 0)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
throw new ProfileRepositoryException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RemoveProfile(uint ProfileId)
|
||||||
|
{
|
||||||
|
if (ProfileId == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove the Profile Icons from the Cache
|
||||||
|
List<ProfileItem> ProfilesToRemove = _allProfiles.FindAll(item => item.UUID.Equals(ProfileId));
|
||||||
|
foreach (ProfileItem ProfileToRemove in ProfilesToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(ProfileToRemove.SavedProfileIconCacheFilename);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// TODO check and report
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the Profile from the list.
|
||||||
|
int numRemoved = _allProfiles.RemoveAll(item => item.UUID.Equals(ProfileId));
|
||||||
|
|
||||||
|
if (numRemoved == 1)
|
||||||
|
{
|
||||||
|
SaveProfiles();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (numRemoved == 0)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
throw new ProfileRepositoryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static bool ContainsProfile(ProfileItem Profile)
|
||||||
|
{
|
||||||
|
if (!(Profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (ProfileItem testProfile in _allProfiles)
|
||||||
|
{
|
||||||
|
if (testProfile.UUID.Equals(Profile.UUID))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ContainsProfile(string ProfileNameOrId)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrWhiteSpace(ProfileNameOrId))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (ProfileItem.IsValidId(ProfileNameOrId))
|
||||||
|
foreach (ProfileItem testProfile in _allProfiles)
|
||||||
|
{
|
||||||
|
if (testProfile.UUID.Equals(ProfileNameOrId))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
foreach (ProfileItem testProfile in _allProfiles)
|
||||||
|
{
|
||||||
|
if (testProfile.Name.Equals(ProfileNameOrId))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileItem GetProfile(string ProfileNameOrId)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrWhiteSpace(ProfileNameOrId))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (ProfileItem.IsValidId(ProfileNameOrId))
|
||||||
|
foreach (ProfileItem testProfile in _allProfiles)
|
||||||
|
{
|
||||||
|
if (testProfile.UUID.Equals(ProfileNameOrId))
|
||||||
|
return testProfile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
foreach (ProfileItem testProfile in _allProfiles)
|
||||||
|
{
|
||||||
|
if (testProfile.Name.Equals(ProfileNameOrId))
|
||||||
|
return testProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool RenameProfile(ProfileItem profile, string renamedName)
|
||||||
|
{
|
||||||
|
if (!(profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!IsValidFilename(renamedName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
profile.Name = GetValidFilename(renamedName);
|
||||||
|
|
||||||
|
// If it's been added to the list of AllProfiles
|
||||||
|
// then we also need to reproduce the Icons
|
||||||
|
if (ContainsProfile(profile))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// rename the old Profile Icon to the new name
|
||||||
|
string newSavedProfileIconCacheFilename = Path.Combine(_profileStorageJsonPath, String.Concat(@"profile-", GetValidFilename(profile.Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
|
||||||
|
File.Move(profile.SavedProfileIconCacheFilename, newSavedProfileIconCacheFilename);
|
||||||
|
|
||||||
|
// Then update the profile too
|
||||||
|
profile.SavedProfileIconCacheFilename = newSavedProfileIconCacheFilename;
|
||||||
|
|
||||||
|
// Save the Profiles JSON as it's different now
|
||||||
|
SaveProfiles();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void UpdateActiveProfile()
|
||||||
|
{
|
||||||
|
_currentProfile = new ProfileItem
|
||||||
|
{
|
||||||
|
Name = "Current Display Profile",
|
||||||
|
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray(),
|
||||||
|
ProfileIcon = new ProfileIcon(_currentProfile),
|
||||||
|
ProfileBitmap = _currentProfile.ProfileIcon.ToBitmap(256, 256)
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ProfileItem GetActiveProfile()
|
||||||
|
{
|
||||||
|
UpdateActiveProfile();
|
||||||
|
|
||||||
|
if (!(_currentProfile is ProfileItem))
|
||||||
|
return null;
|
||||||
|
return _currentProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsActiveProfile(ProfileItem profile)
|
||||||
|
{
|
||||||
|
UpdateActiveProfile();
|
||||||
|
|
||||||
|
if (!(_currentProfile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(profile is ProfileItem))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (profile.Equals(_currentProfile))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool LoadProfiles()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (File.Exists(_profileStorageJsonFileName))
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(_profileStorageJsonFileName, Encoding.Unicode);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
|
{
|
||||||
|
List<ProfileItem> profiles = new List<ProfileItem>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_allProfiles = JsonConvert.DeserializeObject<List<ProfileItem>>(json, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||||
|
NullValueHandling = NullValueHandling.Ignore,
|
||||||
|
DefaultValueHandling = DefaultValueHandling.Include,
|
||||||
|
TypeNameHandling = TypeNameHandling.Auto
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
Console.WriteLine($"Unable to load Profiles from JSON file {_profileStorageJsonFileName}: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfileItem myCurrentProfile = new ProfileItem
|
||||||
|
{
|
||||||
|
Name = "Current Display Profile",
|
||||||
|
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
||||||
|
};
|
||||||
|
|
||||||
|
_currentProfile = myCurrentProfile;
|
||||||
|
|
||||||
|
// Lookup all the Profile Names in the Saved Profiles
|
||||||
|
foreach (ProfileItem loadedProfile in profiles)
|
||||||
|
{
|
||||||
|
// Save a profile Icon to the profile
|
||||||
|
loadedProfile.ProfileIcon = new ProfileIcon(loadedProfile);
|
||||||
|
loadedProfile.ProfileBitmap = loadedProfile.ProfileIcon.ToBitmap(128, 128);
|
||||||
|
|
||||||
|
if (ProfileRepository.IsActiveProfile(loadedProfile))
|
||||||
|
_currentProfile = loadedProfile;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// If we get here, then we don't have any profiles saved!
|
||||||
|
// So we gotta start from scratch
|
||||||
|
// Create a new profile based on our current display settings
|
||||||
|
ProfileItem myCurrentProfile = new ProfileItem
|
||||||
|
{
|
||||||
|
Name = "Current Display Profile",
|
||||||
|
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
||||||
|
};
|
||||||
|
|
||||||
|
_currentProfile = myCurrentProfile;
|
||||||
|
|
||||||
|
// Save a profile Icon to the profile
|
||||||
|
_currentProfile.ProfileIcon = new ProfileIcon(_currentProfile);
|
||||||
|
_currentProfile.ProfileBitmap = _currentProfile.ProfileIcon.ToBitmap(256, 256);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool SaveProfiles()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!Directory.Exists(_profileStorageJsonPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_profileStorageJsonPath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Unable to create Profile folder {_profileStorageJsonPath}: " + ex.Message);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(_allProfiles, Formatting.Indented, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
NullValueHandling = NullValueHandling.Include,
|
||||||
|
DefaultValueHandling = DefaultValueHandling.Populate,
|
||||||
|
TypeNameHandling = TypeNameHandling.Auto
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
|
{
|
||||||
|
File.WriteAllText(_profileStorageJsonFileName, json, Encoding.Unicode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Unable to save Profile JSON file {_profileStorageJsonFileName}: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveProfileIconToCache(ProfileItem profile)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Work out the name of the Profile we'll save.
|
||||||
|
profile.SavedProfileIconCacheFilename = Path.Combine(_profileStorageJsonPath, String.Concat(@"profile-", GetValidFilename(profile.Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
|
||||||
|
|
||||||
|
MultiIcon ProfileIcon;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ProfileIcon = profile.ProfileIcon.ToIcon();
|
||||||
|
ProfileIcon.Save(profile.SavedProfileIconCacheFilename, MultiIconFormat.ICO);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// If we fail to create an icon based on the Profile, then we use the standard HeliosPlus profile one.
|
||||||
|
// Which is created on program startup.
|
||||||
|
File.Copy(AppHeliosPlusIconFilename, profile.SavedProfileIconCacheFilename);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateCurrentProfile()
|
||||||
|
{
|
||||||
|
_currentProfile = new ProfileItem
|
||||||
|
{
|
||||||
|
Name = "Current Display Profile",
|
||||||
|
Viewports = PathInfo.GetActivePaths().Select(info => new ProfileViewport(info)).ToArray()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ApplyProfile(ProfileItem profile)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug.Print("Begin profile change");
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
profile.ApplyTopos();
|
||||||
|
|
||||||
|
Debug.Print("Finished setting topologies");
|
||||||
|
Debug.Print("Sleep");
|
||||||
|
Thread.Sleep(18000);
|
||||||
|
Debug.Print("Awake");
|
||||||
|
|
||||||
|
profile.ApplyPathInfos();
|
||||||
|
|
||||||
|
Debug.Print("Applying pathInfos");
|
||||||
|
Debug.Print("Sleep");
|
||||||
|
Thread.Sleep(10000);
|
||||||
|
Debug.Print("Awake");
|
||||||
|
|
||||||
|
UpdateCurrentProfile();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
UpdateCurrentProfile();
|
||||||
|
Console.WriteLine($"Profile: Problem applying the '{profile.Name}' Display Profile: {ex.Message}");
|
||||||
|
MessageBox.Show($"Problem applying the '{profile.Name}' Display Profile! \n(ex.Message)", $"Problem applying '{profile.Name}' Profile", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValidFilename(string testName)
|
||||||
|
{
|
||||||
|
string strTheseAreInvalidFileNameChars = new string(Path.GetInvalidFileNameChars());
|
||||||
|
Regex regInvalidFileName = new Regex("[" + Regex.Escape(strTheseAreInvalidFileNameChars) + "]");
|
||||||
|
|
||||||
|
if (regInvalidFileName.IsMatch(testName)) { return false; };
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetValidFilename(string uncheckedFilename)
|
||||||
|
{
|
||||||
|
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
||||||
|
foreach (char c in invalid)
|
||||||
|
{
|
||||||
|
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");
|
||||||
|
}
|
||||||
|
return uncheckedFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Serializable]
|
||||||
|
public class ProfileRepositoryException : Exception
|
||||||
|
{
|
||||||
|
public ProfileRepositoryException() { }
|
||||||
|
public ProfileRepositoryException(string message) : base(message) { }
|
||||||
|
public ProfileRepositoryException(string message, Exception inner) : base(message, inner) { }
|
||||||
|
protected ProfileRepositoryException(
|
||||||
|
System.Runtime.Serialization.SerializationInfo info,
|
||||||
|
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
63
HeliosPlus.Shared/Properties/Resources.Designer.cs
generated
Normal file
63
HeliosPlus.Shared/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace HeliosPlus.Shared.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeliosPlus.Shared.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
HeliosPlus.Shared/Properties/Resources.resx
Normal file
120
HeliosPlus.Shared/Properties/Resources.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -149,7 +149,7 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
@ -235,7 +235,6 @@
|
|||||||
<None Include="Resources\HeliosPlus.ico" />
|
<None Include="Resources\HeliosPlus.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="HeliosPlus.ico" />
|
|
||||||
<Content Include="Resources\redarrows.png" />
|
<Content Include="Resources\redarrows.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -18,6 +18,7 @@ using HeliosPlus.Shared;
|
|||||||
using HeliosPlus.UIForms;
|
using HeliosPlus.UIForms;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace HeliosPlus {
|
namespace HeliosPlus {
|
||||||
public enum SupportedGameLibrary
|
public enum SupportedGameLibrary
|
||||||
@ -31,15 +32,21 @@ namespace HeliosPlus {
|
|||||||
{
|
{
|
||||||
|
|
||||||
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||||
|
public static string AppIconPath = Path.Combine(Program.AppDataPath, $"Icons");
|
||||||
|
public static string AppHeliosPlusIconFilename = Path.Combine(AppIconPath, @"HeliosPlus.ico");
|
||||||
|
public static string AppOriginIconFilename = Path.Combine(AppIconPath, @"Origin.ico");
|
||||||
|
public static string AppSteamIconFilename = Path.Combine(AppIconPath, @"Steam.ico");
|
||||||
|
public static string AppUplayIconFilename = Path.Combine(AppIconPath, @"Steam.ico");
|
||||||
|
public static string AppEpicIconFilename = Path.Combine(AppIconPath, @"Epic.ico");
|
||||||
//internal static string ShortcutIconCachePath;
|
//internal static string ShortcutIconCachePath;
|
||||||
|
|
||||||
|
|
||||||
internal static ProfileItem GetProfile(string profileName)
|
internal static ProfileItem GetProfile(string profileName)
|
||||||
{
|
{
|
||||||
// Create an array of display profiles we have
|
// Create an array of display profiles we have
|
||||||
var profiles = ProfileItem.LoadAllProfiles().ToArray();
|
var profiles = ProfileRepository.AllProfiles.ToArray();
|
||||||
// Check if the user supplied a --profile option using the profiles' ID
|
// Check if the user supplied a --profile option using the profiles' ID
|
||||||
var profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.Id.Equals(profileName, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
var profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.UUID.Equals(profileName, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
||||||
// If the profileID wasn't there, maybe they used the profile name?
|
// If the profileID wasn't there, maybe they used the profile name?
|
||||||
if (profileIndex == -1)
|
if (profileIndex == -1)
|
||||||
{
|
{
|
||||||
@ -52,10 +59,9 @@ namespace HeliosPlus {
|
|||||||
|
|
||||||
internal static bool GoProfile(ProfileItem profile)
|
internal static bool GoProfile(ProfileItem profile)
|
||||||
{
|
{
|
||||||
if (profile.IsActive)
|
// If we're already on the wanted profile then no need to change!
|
||||||
{
|
if (ProfileRepository.IsActiveProfile(profile))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
var instanceStatus = IPCService.GetInstance().Status;
|
var instanceStatus = IPCService.GetInstance().Status;
|
||||||
|
|
||||||
@ -68,7 +74,7 @@ namespace HeliosPlus {
|
|||||||
{
|
{
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
if (!profile.Apply())
|
if (!(ProfileRepository.ApplyProfile(profile)))
|
||||||
{
|
{
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
@ -97,7 +103,7 @@ namespace HeliosPlus {
|
|||||||
// Get the status of the thing
|
// Get the status of the thing
|
||||||
IPCService.GetInstance().Status = InstanceStatus.User;
|
IPCService.GetInstance().Status = InstanceStatus.User;
|
||||||
// Load all the profiles from JSON
|
// Load all the profiles from JSON
|
||||||
ProfileItem.LoadAllProfiles().ToArray();
|
//ProfileRepository.AllProfiles
|
||||||
// Start up the DisplayProfileForm directly
|
// Start up the DisplayProfileForm directly
|
||||||
new DisplayProfileForm(profile).ShowDialog();
|
new DisplayProfileForm(profile).ShowDialog();
|
||||||
// Then we close down as we're only here to edit one profile
|
// Then we close down as we're only here to edit one profile
|
||||||
@ -122,33 +128,6 @@ namespace HeliosPlus {
|
|||||||
Console.WriteLine(@"Copyright <20> Terry MacDonald 2020-{DateTime.Today.Year}");
|
Console.WriteLine(@"Copyright <20> Terry MacDonald 2020-{DateTime.Today.Year}");
|
||||||
Console.WriteLine(@"Based on Helios Display Management - Copyright <20> Soroush Falahati 2017-2020");
|
Console.WriteLine(@"Based on Helios Display Management - Copyright <20> Soroush Falahati 2017-2020");
|
||||||
|
|
||||||
/*// Figure out where the shortcut's will go
|
|
||||||
ShortcutIconCachePath = Path.Combine(AppDataPath, @"ShortcutIconCache");
|
|
||||||
|
|
||||||
// Create the Shortcut Icon Cache if it doesn't exist so that it's avilable for all the program
|
|
||||||
if (!Directory.Exists(AppDataPath))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ShortcutIconCachePath);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the Shortcut Icon Cache if it doesn't exist so that it's avilable for all the program
|
|
||||||
if (!Directory.Exists(ShortcutIconCachePath))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(ShortcutIconCachePath);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
var app = new CommandLineApplication();
|
var app = new CommandLineApplication();
|
||||||
|
|
||||||
//app.Name = "HeliosDM+";
|
//app.Name = "HeliosDM+";
|
||||||
@ -253,6 +232,66 @@ namespace HeliosPlus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Create the Shortcut Icon Cache if it doesn't exist so that it's avilable for all the program
|
||||||
|
if (!Directory.Exists(AppIconPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(AppIconPath);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Save a copy of the HeliosPlus Icon, and all the game library ones in preparation for future use
|
||||||
|
if (!File.Exists(AppHeliosPlusIconFilename))
|
||||||
|
{
|
||||||
|
Icon heliosIcon = (Icon)Properties.Resources.HeliosPlus;
|
||||||
|
using (FileStream fs = new FileStream(AppHeliosPlusIconFilename, FileMode.Create))
|
||||||
|
heliosIcon.Save(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save a copy of the Steam Icon, and all the game library ones in preparation for future use
|
||||||
|
if (!File.Exists(AppSteamIconFilename))
|
||||||
|
{
|
||||||
|
Icon heliosIcon = (Icon)Properties.Resources.Steam;
|
||||||
|
using (FileStream fs = new FileStream(AppSteamIconFilename, FileMode.Create))
|
||||||
|
heliosIcon.Save(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save a copy of the Uplay Icon, and all the game library ones in preparation for future use
|
||||||
|
if (!File.Exists(AppUplayIconFilename))
|
||||||
|
{
|
||||||
|
Icon heliosIcon = (Icon)Properties.Resources.Uplay;
|
||||||
|
using (FileStream fs = new FileStream(AppUplayIconFilename, FileMode.Create))
|
||||||
|
heliosIcon.Save(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save a copy of the Epic Icon, and all the game library ones in preparation for future use
|
||||||
|
if (!File.Exists(AppEpicIconFilename))
|
||||||
|
{
|
||||||
|
Icon heliosIcon = (Icon)Properties.Resources.Epic;
|
||||||
|
using (FileStream fs = new FileStream(AppEpicIconFilename, FileMode.Create))
|
||||||
|
heliosIcon.Save(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save a copy of the Origin Icon, and all the game library ones in preparation for future use
|
||||||
|
if (!File.Exists(AppOriginIconFilename))
|
||||||
|
{
|
||||||
|
Icon heliosIcon = (Icon)Properties.Resources.Origin;
|
||||||
|
using (FileStream fs = new FileStream(AppOriginIconFilename, FileMode.Create))
|
||||||
|
heliosIcon.Save(fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.User;
|
IPCService.GetInstance().Status = InstanceStatus.User;
|
||||||
Application.Run(new UIForms.MainForm());
|
Application.Run(new UIForms.MainForm());
|
||||||
|
|
||||||
@ -270,7 +309,7 @@ namespace HeliosPlus {
|
|||||||
|
|
||||||
private static void SwitchToExecutable(ProfileItem profile, string executableToRun, string processToMonitor, uint timeout, string executableArguments)
|
private static void SwitchToExecutable(ProfileItem profile, string executableToRun, string processToMonitor, uint timeout, string executableArguments)
|
||||||
{
|
{
|
||||||
var rollbackProfile = ProfileItem.CurrentProfile;
|
var rollbackProfile = ProfileRepository.CurrentProfile;
|
||||||
|
|
||||||
if (!profile.IsPossible)
|
if (!profile.IsPossible)
|
||||||
{
|
{
|
||||||
@ -361,7 +400,8 @@ namespace HeliosPlus {
|
|||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
||||||
|
|
||||||
if (!rollbackProfile.IsActive)
|
// Change back to the original profile if it is different
|
||||||
|
if (!ProfileRepository.IsActiveProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
if (!GoProfile(rollbackProfile))
|
if (!GoProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
@ -383,7 +423,7 @@ namespace HeliosPlus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the profile we're on now
|
// Save the profile we're on now
|
||||||
var rollbackProfile = ProfileItem.CurrentProfile;
|
var rollbackProfile = ProfileRepository.CurrentProfile;
|
||||||
|
|
||||||
// Check that the profile we've been asked to change to will actually work
|
// Check that the profile we've been asked to change to will actually work
|
||||||
if (!profile.IsPossible)
|
if (!profile.IsPossible)
|
||||||
@ -502,7 +542,8 @@ namespace HeliosPlus {
|
|||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
||||||
|
|
||||||
if (!rollbackProfile.IsActive)
|
// Change back to the original profile if it is different
|
||||||
|
if (!ProfileRepository.IsActiveProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
if (!GoProfile(rollbackProfile))
|
if (!GoProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
@ -515,7 +556,7 @@ namespace HeliosPlus {
|
|||||||
private static void SwitchToUplayGame(ProfileItem profile, string uplayGameIdToRun, uint timeout, string uplayGameArguments)
|
private static void SwitchToUplayGame(ProfileItem profile, string uplayGameIdToRun, uint timeout, string uplayGameArguments)
|
||||||
{
|
{
|
||||||
|
|
||||||
var rollbackProfile = ProfileItem.CurrentProfile;
|
var rollbackProfile = ProfileRepository.CurrentProfile;
|
||||||
|
|
||||||
if (!profile.IsPossible)
|
if (!profile.IsPossible)
|
||||||
{
|
{
|
||||||
@ -629,7 +670,8 @@ namespace HeliosPlus {
|
|||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
IPCService.GetInstance().Status = InstanceStatus.Busy;
|
||||||
|
|
||||||
if (!rollbackProfile.IsActive)
|
// Change back to the original profile if it is different
|
||||||
|
if (!ProfileRepository.IsActiveProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
if (!GoProfile(rollbackProfile))
|
if (!GoProfile(rollbackProfile))
|
||||||
{
|
{
|
||||||
@ -643,7 +685,7 @@ namespace HeliosPlus {
|
|||||||
// ReSharper disable once CyclomaticComplexity
|
// ReSharper disable once CyclomaticComplexity
|
||||||
private static void SwitchToProfile(ProfileItem profile)
|
private static void SwitchToProfile(ProfileItem profile)
|
||||||
{
|
{
|
||||||
var rollbackProfile = ProfileItem.CurrentProfile;
|
var rollbackProfile = ProfileRepository.CurrentProfile;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
IPCClient.QueryAll()
|
IPCClient.QueryAll()
|
||||||
|
16
HeliosPlus/Properties/Resources.Designer.cs
generated
16
HeliosPlus/Properties/Resources.Designer.cs
generated
@ -22,7 +22,7 @@ namespace HeliosPlus.Properties {
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources {
|
public class Resources {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeliosPlus.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeliosPlus.Properties.Resources", typeof(Resources).Assembly);
|
||||||
@ -51,7 +51,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
public static global::System.Globalization.CultureInfo Culture {
|
||||||
get {
|
get {
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon Epic {
|
public static System.Drawing.Icon Epic {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("Epic", resourceCulture);
|
object obj = ResourceManager.GetObject("Epic", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
@ -73,7 +73,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon HeliosPlus {
|
public static System.Drawing.Icon HeliosPlus {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("HeliosPlus", resourceCulture);
|
object obj = ResourceManager.GetObject("HeliosPlus", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
@ -83,7 +83,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon Origin {
|
public static System.Drawing.Icon Origin {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("Origin", resourceCulture);
|
object obj = ResourceManager.GetObject("Origin", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
@ -93,7 +93,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon Steam {
|
public static System.Drawing.Icon Steam {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("Steam", resourceCulture);
|
object obj = ResourceManager.GetObject("Steam", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
@ -103,7 +103,7 @@ namespace HeliosPlus.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Icon Uplay {
|
public static System.Drawing.Icon Uplay {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("Uplay", resourceCulture);
|
object obj = ResourceManager.GetObject("Uplay", resourceCulture);
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 115 KiB |
@ -102,7 +102,7 @@ namespace HeliosPlus
|
|||||||
_profileName = value;
|
_profileName = value;
|
||||||
|
|
||||||
// We try to find and set the ProfileTouse
|
// We try to find and set the ProfileTouse
|
||||||
foreach (ProfileItem profileToTest in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
if (profileToTest.Name.Equals(_profileName))
|
if (profileToTest.Name.Equals(_profileName))
|
||||||
_profileToUse = profileToTest;
|
_profileToUse = profileToTest;
|
||||||
|
@ -329,7 +329,7 @@ namespace HeliosPlus
|
|||||||
// Lookup all the Profile Names in the Saved Profiles
|
// Lookup all the Profile Names in the Saved Profiles
|
||||||
foreach (ShortcutItem updatedShortcut in _allShortcuts)
|
foreach (ShortcutItem updatedShortcut in _allShortcuts)
|
||||||
{
|
{
|
||||||
foreach (ProfileItem profile in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem profile in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (profile.Name.Equals(updatedShortcut.ProfileName))
|
if (profile.Name.Equals(updatedShortcut.ProfileName))
|
||||||
|
@ -81,31 +81,16 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
private void Delete_Click(object sender, EventArgs e)
|
private void Delete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_inDialog = true;
|
|
||||||
if (MessageBox.Show($"Are you sure you want to delete the '{_selectedProfile.Name}' Display Profile?", $"Delete '{_selectedProfile.Name}' Display Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
|
if (MessageBox.Show($"Are you sure you want to delete the '{_selectedProfile.Name}' Display Profile?", $"Delete '{_selectedProfile.Name}' Display Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ProfileItem profileToDelete = _selectedProfile;
|
|
||||||
string profileToDeleteFilename = _selectedProfile.SavedProfileCacheFilename;
|
|
||||||
|
|
||||||
// remove the profile from the imagelistview
|
// remove the profile from the imagelistview
|
||||||
int currentIlvIndex = ilv_saved_profiles.SelectedItems[0].Index;
|
int currentIlvIndex = ilv_saved_profiles.SelectedItems[0].Index;
|
||||||
ilv_saved_profiles.Items.RemoveAt(currentIlvIndex);
|
ilv_saved_profiles.Items.RemoveAt(currentIlvIndex);
|
||||||
|
|
||||||
// remove the profile from the saved profiles list
|
// Remove the Profile
|
||||||
_savedProfiles.Remove(profileToDelete);
|
ProfileRepository.RemoveProfile(_selectedProfile);
|
||||||
|
_selectedProfile = null;
|
||||||
// delete the profile image used in the image listview
|
|
||||||
// we'll delete the old PNG that we no longer need
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(profileToDeleteFilename);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// TODO write error to console
|
|
||||||
// TODO specify the correct the exceptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the imageview isn't empty
|
// If the imageview isn't empty
|
||||||
if (ilv_saved_profiles.Items.Count > 0)
|
if (ilv_saved_profiles.Items.Count > 0)
|
||||||
@ -132,13 +117,10 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
// We now only have an unsaved current profile, and no saved ones
|
// We now only have an unsaved current profile, and no saved ones
|
||||||
// So we need to change the mode
|
// So we need to change the mode
|
||||||
ChangeSelectedProfile(ProfileItem.CurrentProfile);
|
ChangeSelectedProfile(ProfileRepository.CurrentProfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then save the profiles so we always have it updated
|
|
||||||
// Generating the imagelistview images automatically as we save.
|
|
||||||
ProfileItem.SaveAllProfiles(_savedProfiles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshDisplayProfileUI()
|
private void RefreshDisplayProfileUI()
|
||||||
@ -166,7 +148,7 @@ namespace HeliosPlus.UIForms
|
|||||||
ilv_saved_profiles.Items.Add(newItem, _profileAdaptor);
|
ilv_saved_profiles.Items.Add(newItem, _profileAdaptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProfileItem.CurrentProfile.Equals(loadedProfile))
|
if (ProfileRepository.CurrentProfile.Equals(loadedProfile))
|
||||||
{
|
{
|
||||||
// We have already saved the selected profile!
|
// We have already saved the selected profile!
|
||||||
// so we need to show the selected profile
|
// so we need to show the selected profile
|
||||||
@ -179,7 +161,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// found a matching profile, then we need to show the current
|
// found a matching profile, then we need to show the current
|
||||||
// Profile
|
// Profile
|
||||||
if (!foundCurrentProfileInLoadedProfiles)
|
if (!foundCurrentProfileInLoadedProfiles)
|
||||||
ChangeSelectedProfile(ProfileItem.CurrentProfile);
|
ChangeSelectedProfile(ProfileRepository.CurrentProfile);
|
||||||
|
|
||||||
// Check if we were loading a profile to edit
|
// Check if we were loading a profile to edit
|
||||||
// If so, select that instead of all that other stuff above!
|
// If so, select that instead of all that other stuff above!
|
||||||
@ -192,7 +174,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// If there are no profiles at all then we are starting from scratch!
|
// If there are no profiles at all then we are starting from scratch!
|
||||||
// Show the profile in the DV window
|
// Show the profile in the DV window
|
||||||
// Use the current profile name in the label and the save name
|
// Use the current profile name in the label and the save name
|
||||||
ChangeSelectedProfile(ProfileItem.CurrentProfile);
|
ChangeSelectedProfile(ProfileRepository.CurrentProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart updating the saved_profiles listview
|
// Restart updating the saved_profiles listview
|
||||||
@ -213,7 +195,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// and the app will automatically recognise that things have changed.
|
// and the app will automatically recognise that things have changed.
|
||||||
|
|
||||||
// Reload the profiles in case we swapped to another program to change it
|
// Reload the profiles in case we swapped to another program to change it
|
||||||
ProfileItem.UpdateCurrentProfile();
|
ProfileRepository.UpdateCurrentProfile();
|
||||||
// Refresh the Profile UI
|
// Refresh the Profile UI
|
||||||
RefreshDisplayProfileUI();
|
RefreshDisplayProfileUI();
|
||||||
}
|
}
|
||||||
@ -221,9 +203,9 @@ namespace HeliosPlus.UIForms
|
|||||||
private void DisplayProfileForm_Load(object sender, EventArgs e)
|
private void DisplayProfileForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Load all the profiles to prepare things
|
// Load all the profiles to prepare things
|
||||||
_savedProfiles = (List<ProfileItem>)ProfileItem.LoadAllProfiles();
|
_savedProfiles = ProfileRepository.AllProfiles;
|
||||||
// Update the Current Profile
|
// Update the Current Profile
|
||||||
ProfileItem.UpdateCurrentProfile();
|
ProfileRepository.UpdateCurrentProfile();
|
||||||
// Refresh the Profile UI
|
// Refresh the Profile UI
|
||||||
RefreshDisplayProfileUI();
|
RefreshDisplayProfileUI();
|
||||||
}
|
}
|
||||||
@ -241,7 +223,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// And update the save/rename textbox
|
// And update the save/rename textbox
|
||||||
txt_profile_save_name.Text = _selectedProfile.Name;
|
txt_profile_save_name.Text = _selectedProfile.Name;
|
||||||
|
|
||||||
if (_selectedProfile.Equals(ProfileItem.CurrentProfile))
|
if (_selectedProfile.Equals(ProfileRepository.CurrentProfile))
|
||||||
{
|
{
|
||||||
if (_savedProfiles.Contains(_selectedProfile))
|
if (_savedProfiles.Contains(_selectedProfile))
|
||||||
{
|
{
|
||||||
@ -305,7 +287,7 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check we're not already using the name
|
// Check we're not already using the name
|
||||||
foreach (ProfileItem savedProfile in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem savedProfile in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
//if (String.Equals(txt_profile_save_name.Text, savedProfile.Name, StringComparison.InvariantCultureIgnoreCase))
|
//if (String.Equals(txt_profile_save_name.Text, savedProfile.Name, StringComparison.InvariantCultureIgnoreCase))
|
||||||
if (savedProfile.Name.Equals(txt_profile_save_name.Text))
|
if (savedProfile.Name.Equals(txt_profile_save_name.Text))
|
||||||
@ -322,7 +304,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// We're in 'save' mode!
|
// We're in 'save' mode!
|
||||||
|
|
||||||
// Check we're not already saving this profile
|
// Check we're not already saving this profile
|
||||||
foreach (ProfileItem savedProfile in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem savedProfile in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
//if (String.Equals(txt_profile_save_name.Text, savedProfile.Name, StringComparison.InvariantCultureIgnoreCase))
|
//if (String.Equals(txt_profile_save_name.Text, savedProfile.Name, StringComparison.InvariantCultureIgnoreCase))
|
||||||
if (savedProfile.Equals(_selectedProfile))
|
if (savedProfile.Equals(_selectedProfile))
|
||||||
@ -337,11 +319,10 @@ namespace HeliosPlus.UIForms
|
|||||||
// Update the name just to make sure we record it if the user changed it
|
// Update the name just to make sure we record it if the user changed it
|
||||||
_selectedProfile.Name = txt_profile_save_name.Text;
|
_selectedProfile.Name = txt_profile_save_name.Text;
|
||||||
|
|
||||||
// Add the current profile to the list of profiles so it gets saved later
|
// Add the current profile to the list of profiles so it gets saved
|
||||||
_savedProfiles.Add(_selectedProfile);
|
ProfileRepository.AddProfile(_selectedProfile);
|
||||||
|
|
||||||
// Also update the imagelistview so that we can see the new profile we just saved
|
// Also update the imagelistview so that we can see the new profile we just saved
|
||||||
//_selectedProfile.SaveProfileImageToCache();
|
|
||||||
|
|
||||||
// Load the currentProfile image into the imagelistview
|
// Load the currentProfile image into the imagelistview
|
||||||
//ImageListViewItem newItem = new ImageListViewItem(_selectedProfile.SavedProfileCacheFilename, _selectedProfile.Name);
|
//ImageListViewItem newItem = new ImageListViewItem(_selectedProfile.SavedProfileCacheFilename, _selectedProfile.Name);
|
||||||
@ -361,7 +342,6 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
// Lets save the old names for usage next
|
// Lets save the old names for usage next
|
||||||
string oldProfileName = _selectedProfile.Name;
|
string oldProfileName = _selectedProfile.Name;
|
||||||
string oldProfileCacheFilename = _selectedProfile.SavedProfileCacheFilename;
|
|
||||||
|
|
||||||
// Lets rename the entry in the imagelistview to the new name
|
// Lets rename the entry in the imagelistview to the new name
|
||||||
foreach (ImageListViewItem myItem in ilv_saved_profiles.Items)
|
foreach (ImageListViewItem myItem in ilv_saved_profiles.Items)
|
||||||
@ -372,30 +352,15 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Lets rename the selectedProfile to the new name
|
// Lets rename the selectedProfile to the new name
|
||||||
_selectedProfile.Name = txt_profile_save_name.Text;
|
ProfileRepository.RenameProfile(_selectedProfile, txt_profile_save_name.Text);
|
||||||
|
|
||||||
// Lets update the rest of the profile screen too
|
// Lets update the rest of the profile screen too
|
||||||
lbl_profile_shown.Text = txt_profile_save_name.Text;
|
lbl_profile_shown.Text = txt_profile_save_name.Text;
|
||||||
|
|
||||||
// Then we'll delete the old PNG that we renamed from so we don't get a buildup of them!
|
|
||||||
// as a new one will be created when we save later
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Delete(oldProfileCacheFilename);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
// TODO write error to console
|
|
||||||
// TODO specify the correct the exceptions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeSelectedProfile(_selectedProfile);
|
ChangeSelectedProfile(_selectedProfile);
|
||||||
|
|
||||||
// Then save the profiles so we always have it updated
|
|
||||||
// Generating the imagelistview images automatically as we save.
|
|
||||||
ProfileItem.SaveAllProfiles(_savedProfiles);
|
|
||||||
|
|
||||||
// now update the profiles image listview
|
// now update the profiles image listview
|
||||||
//ilv_saved_profiles.Refresh();
|
//ilv_saved_profiles.Refresh();
|
||||||
|
|
||||||
@ -416,7 +381,7 @@ namespace HeliosPlus.UIForms
|
|||||||
private void btn_view_current_Click(object sender, EventArgs e)
|
private void btn_view_current_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Reload the profiles in case we swapped to another program to change it
|
// Reload the profiles in case we swapped to another program to change it
|
||||||
ProfileItem.UpdateCurrentProfile();
|
ProfileRepository.UpdateCurrentProfile();
|
||||||
// Refresh the Profile UI
|
// Refresh the Profile UI
|
||||||
RefreshDisplayProfileUI();
|
RefreshDisplayProfileUI();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
ProfileItem profileToUse = null;
|
ProfileItem profileToUse = null;
|
||||||
|
|
||||||
foreach (ProfileItem profileToTest in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
if (profileToTest.Name == profileName)
|
if (profileToTest.Name == profileName)
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
if (profileToUse == null)
|
if (profileToUse == null)
|
||||||
{
|
{
|
||||||
profileToUse = ProfileItem.CurrentProfile;
|
profileToUse = ProfileRepository.CurrentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
|
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(() => { return false; });
|
||||||
@ -141,7 +141,7 @@ namespace HeliosPlus.UIForms
|
|||||||
string profileName = (string)key;
|
string profileName = (string)key;
|
||||||
ProfileItem profileToUse = null;
|
ProfileItem profileToUse = null;
|
||||||
|
|
||||||
foreach (ProfileItem profileToTest in ProfileItem.AllSavedProfiles)
|
foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles)
|
||||||
{
|
{
|
||||||
if (profileToTest.Name == profileName)
|
if (profileToTest.Name == profileName)
|
||||||
{
|
{
|
||||||
@ -152,7 +152,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
if (profileToUse == null)
|
if (profileToUse == null)
|
||||||
{
|
{
|
||||||
profileToUse = ProfileItem.CurrentProfile;
|
profileToUse = ProfileRepository.CurrentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file info
|
// Get file info
|
||||||
|
@ -603,12 +603,12 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Load all the profiles to prepare things
|
// Load all the profiles to prepare things
|
||||||
_loadedProfiles = (List<ProfileItem>)ProfileItem.LoadAllProfiles();
|
_loadedProfiles = ProfileRepository.AllProfiles;
|
||||||
|
|
||||||
bool foundCurrentProfileInLoadedProfiles = false;
|
bool foundCurrentProfileInLoadedProfiles = false;
|
||||||
foreach (ProfileItem loadedProfile in _loadedProfiles)
|
foreach (ProfileItem loadedProfile in _loadedProfiles)
|
||||||
{
|
{
|
||||||
if (ProfileItem.CurrentProfile.Equals(loadedProfile))
|
if (ProfileRepository.CurrentProfile.Equals(loadedProfile))
|
||||||
{
|
{
|
||||||
// We have already saved the selected profile!
|
// We have already saved the selected profile!
|
||||||
// so we need to show the selected profile
|
// so we need to show the selected profile
|
||||||
@ -844,7 +844,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// We also need to load the saved profile name to show the user
|
// We also need to load the saved profile name to show the user
|
||||||
lbl_profile_shown.Text = _profileToUse.Name;
|
lbl_profile_shown.Text = _profileToUse.Name;
|
||||||
|
|
||||||
if (_profileToUse.Equals(ProfileItem.CurrentProfile))
|
if (_profileToUse.Equals(ProfileRepository.CurrentProfile))
|
||||||
{
|
{
|
||||||
lbl_profile_shown_subtitle.Text = "(Current Display Profile in use)";
|
lbl_profile_shown_subtitle.Text = "(Current Display Profile in use)";
|
||||||
}
|
}
|
||||||
@ -900,7 +900,7 @@ namespace HeliosPlus.UIForms
|
|||||||
// found a matching profile, then we need to show the current
|
// found a matching profile, then we need to show the current
|
||||||
// Profile
|
// Profile
|
||||||
if (!foundCurrentProfileInLoadedProfiles)
|
if (!foundCurrentProfileInLoadedProfiles)
|
||||||
ChangeSelectedProfile(ProfileItem.CurrentProfile);
|
ChangeSelectedProfile(ProfileRepository.CurrentProfile);
|
||||||
|
|
||||||
// Check if we were loading a profile to edit
|
// Check if we were loading a profile to edit
|
||||||
// If so, select that instead of all that other stuff above!
|
// If so, select that instead of all that other stuff above!
|
||||||
|
@ -23,9 +23,9 @@ namespace HeliosPlus
|
|||||||
var profile = optionProfile.Value();
|
var profile = optionProfile.Value();
|
||||||
|
|
||||||
// Create an array of display profiles we have
|
// Create an array of display profiles we have
|
||||||
var profiles = ProfileItem.LoadAllProfiles().ToArray();
|
var profiles = ProfileRepository.AllProfiles.ToArray();
|
||||||
// Check if the user supplied a --profile option using the profiles' ID
|
// Check if the user supplied a --profile option using the profiles' ID
|
||||||
var profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.Id.Equals(profile, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
var profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.UUID.Equals(profile, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
||||||
// If the profileID wasn't there, maybe they used the profile name?
|
// If the profileID wasn't there, maybe they used the profile name?
|
||||||
if (profileIndex == -1)
|
if (profileIndex == -1)
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ namespace HeliosPlus
|
|||||||
return new ValidationResult($"Couldn't find Profile Name or ID supplied via command line: '{optionProfile.LongName}'. Please check the Profile Name or ID you supplied on the command line is correct.");
|
return new ValidationResult($"Couldn't find Profile Name or ID supplied via command line: '{optionProfile.LongName}'. Please check the Profile Name or ID you supplied on the command line is correct.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Using Profile: '{profiles[profileIndex].Name}' (ID:{profiles[profileIndex].Id})");
|
Console.WriteLine($"Using Profile: '{profiles[profileIndex].Name}' (ID:{profiles[profileIndex].UUID})");
|
||||||
return ValidationResult.Success;
|
return ValidationResult.Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user