diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 0575ca3..90c97e1 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -157,7 +157,7 @@ namespace RGB.NET.Core DeviceLayout layout = DeviceLayout.Load(layoutPath); if (layout != null) { - string imageBasePath = string.IsNullOrWhiteSpace(layout.ImageBasePath) ? null : PathHelper.GetAbsolutePath(layout.ImageBasePath); + string imageBasePath = string.IsNullOrWhiteSpace(layout.ImageBasePath) ? null : PathHelper.GetAbsolutePath(this, layout.ImageBasePath); if ((imageBasePath != null) && !string.IsNullOrWhiteSpace(layout.DeviceImage) && (DeviceInfo != null)) DeviceInfo.Image = new Uri(Path.Combine(imageBasePath, layout.DeviceImage), UriKind.Absolute); diff --git a/RGB.NET.Core/Events/ResolvePathEventArgs.cs b/RGB.NET.Core/Events/ResolvePathEventArgs.cs new file mode 100644 index 0000000..2b73a2e --- /dev/null +++ b/RGB.NET.Core/Events/ResolvePathEventArgs.cs @@ -0,0 +1,64 @@ +using System; + +namespace RGB.NET.Core +{ + public class ResolvePathEventArgs : EventArgs + { + #region Properties & Fields + + /// + /// Gets the filename used to resolve the path. + /// This has to be checked for null since it'S possible that only is used. + /// Also check before use. + /// + public string RelativePart { get; } + + /// + /// Gets the filename used to resolve the path. + /// This has to be checked for null since it'S possible that only is used. + /// Also check before use. + /// + public string FileName { get; } + + /// + /// Gets the relative path used to resolve the path. + /// If this is set and are unused. + /// + public string RelativePath { get; } + + /// + /// Gets or sets the resolved path. + /// + public string FinalPath { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The filename used to resolve the path. + /// The filename used to resolve the path. + /// The relative part used to resolve the path. + public ResolvePathEventArgs(string relativePart, string fileName, string finalPath) + { + this.RelativePart = relativePart; + this.FileName = fileName; + this.FinalPath = finalPath; + } + + /// + /// Initializes a new instance of the class. + /// + /// The relative path used to resolve the path. + /// The relative part used to resolve the path. + public ResolvePathEventArgs(string relativePath, string finalPath) + { + this.RelativePath = relativePath; + this.FinalPath = finalPath; + } + + #endregion + } +} diff --git a/RGB.NET.Core/Helper/PathHelper.cs b/RGB.NET.Core/Helper/PathHelper.cs index dc43f25..d67e5b7 100644 --- a/RGB.NET.Core/Helper/PathHelper.cs +++ b/RGB.NET.Core/Helper/PathHelper.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Reflection; namespace RGB.NET.Core @@ -8,20 +9,73 @@ namespace RGB.NET.Core /// public static class PathHelper { + #region Events + + /// + /// Occurs when a path is resolving. + /// + public static event EventHandler ResolvingAbsolutePath; + + #endregion + #region Methods /// /// Returns an absolute path created from an relative path relatvie to the location of the executung assembly. /// + /// The relative part of the path to convert. + /// The absolute path. + public static string GetAbsolutePath(string relativePath) => GetAbsolutePath((object)null, relativePath); + + /// + /// Returns an absolute path created from an relative path relatvie to the location of the executung assembly. + /// + /// The relative part of the path to convert. + /// The file name of the path to convert. + /// The absolute path. + public static string GetAbsolutePath(string relativePath, string fileName) => GetAbsolutePath(null, relativePath, fileName); + + /// + /// Returns an absolute path created from an relative path relatvie to the location of the executung assembly. + /// + /// The requester of this path. (Used for better control when using the event to override this behavior.) + /// The relative path to convert. + /// The file name of the path to convert. + /// The absolute path. + public static string GetAbsolutePath(object sender, string relativePath, string fileName) + { + string relativePart = Path.Combine(relativePath, fileName); + + string assemblyLocation = Assembly.GetEntryAssembly()?.Location; + if (assemblyLocation == null) return relativePart; + + string directoryName = Path.GetDirectoryName(assemblyLocation); + string path = directoryName == null ? null : Path.Combine(directoryName, relativePart); + + ResolvePathEventArgs args = new ResolvePathEventArgs(relativePath, fileName, path); + ResolvingAbsolutePath?.Invoke(sender, args); + + return args.FinalPath; + } + + /// + /// Returns an absolute path created from an relative path relatvie to the location of the executung assembly. + /// + /// The requester of this path. (Used for better control when using the event to override this behavior.) /// The relative path to convert. /// The absolute path. - public static string GetAbsolutePath(string relativePath) + public static string GetAbsolutePath(object sender, string relativePath) { string assemblyLocation = Assembly.GetEntryAssembly()?.Location; if (assemblyLocation == null) return relativePath; string directoryName = Path.GetDirectoryName(assemblyLocation); - return directoryName == null ? null : Path.Combine(directoryName, relativePath); + string path = directoryName == null ? null : Path.Combine(directoryName, relativePath); + + ResolvePathEventArgs args = new ResolvePathEventArgs(relativePath, path); + ResolvingAbsolutePath?.Invoke(sender, args); + + return args.FinalPath; } #endregion diff --git a/RGB.NET.Devices.Asus/Dram/AsusDramRGBDevice.cs b/RGB.NET.Devices.Asus/Dram/AsusDramRGBDevice.cs index 7e74550..315b1ed 100644 --- a/RGB.NET.Devices.Asus/Dram/AsusDramRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Dram/AsusDramRGBDevice.cs @@ -33,7 +33,7 @@ namespace RGB.NET.Devices.Asus //TODO DarthAffe 21.10.2017: We don't know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Drams\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Drams", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs index 679dd4a..de925fb 100644 --- a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs @@ -32,7 +32,7 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\GraphicsCards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs b/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs index c221e1e..e762d97 100644 --- a/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Headset/AsusHeadsetRGBDevice.cs @@ -32,7 +32,7 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.Headset1 + i, new Rectangle(i * 40, 0, 40, 8)); //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Headsets", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 320f39a..f16acf4 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -32,12 +32,12 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Asus\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); } /// protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; - + #endregion } } diff --git a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs index 907b704..df7d419 100644 --- a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs @@ -32,7 +32,7 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mainboards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs index bc9df80..a6a7ea3 100644 --- a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Asus for (int i = 0; i < ledCount; i++) InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mouses", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs index 360fa38..be0c0b2 100644 --- a/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Asus_Legacy/GraphicsCard/AsusGraphicsCardRGBDevice.cs @@ -34,7 +34,7 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\GraphicsCards", $"{ DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs index 6ced56e..d92d4d7 100644 --- a/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus_Legacy/Keyboard/AsusKeyboardRGBDevice.cs @@ -34,12 +34,12 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Asus\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); } /// protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.Keyboard_Escape; - + /// protected override Action GetUpdateColorAction() => _AsusSDK.SetClaymoreKeyboardColor; diff --git a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs index 26fecdb..4ea1c60 100644 --- a/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus_Legacy/Mainboard/AsusMainboardRGBDevice.cs @@ -34,7 +34,7 @@ namespace RGB.NET.Devices.Asus InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mainboards", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs index 03db09c..d318cae 100644 --- a/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs +++ b/RGB.NET.Devices.Asus_Legacy/Mouse/AsusMouseRGBDevice.cs @@ -33,7 +33,7 @@ namespace RGB.NET.Devices.Asus for (int i = 0; i < ledCount; i++) InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Asus\Mouses", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs index 3a30cc2..e8906e3 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs @@ -33,8 +33,8 @@ namespace RGB.NET.Devices.CoolerMaster InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath( - $@"Layouts\CoolerMaster\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\CoolerMaster\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + DeviceInfo.LogicalLayout.ToString()); } /// diff --git a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs index 3cbee5b..4281706 100644 --- a/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Mouse/CoolerMasterMouseRGBDevice.cs @@ -23,7 +23,7 @@ namespace RGB.NET.Devices.CoolerMaster #endregion #region Methods - + /// protected override void InitializeLayout() { @@ -33,7 +33,7 @@ namespace RGB.NET.Devices.CoolerMaster InitializeLed(led.Key, new Rectangle(led.Value.column * 19, led.Value.row * 19, 19, 19)); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\CoolerMaster\Mice\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\CoolerMaster\Mice", $"{model}.xml"), null); } /// diff --git a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs index 3386a7a..711d97c 100644 --- a/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Custom/CorsairCustomRGBDevice.cs @@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Corsair } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Customs\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Customs", $"{model}.xml"), null); } /// diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index 1f5f951..1ecbe9b 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -32,7 +32,7 @@ namespace RGB.NET.Devices.Corsair InitializeLed(LedId.Headset1, new Rectangle(0, 0, 10, 10)); InitializeLed(LedId.Headset2, new Rectangle(10, 0, 10, 10)); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Headsets", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs index ad855cb..ed25ad7 100644 --- a/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/HeadsetStand/CorsairHeadsetStandRGBDevice.cs @@ -51,9 +51,9 @@ namespace RGB.NET.Devices.Corsair foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\HeadsetStands", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } - + /// protected override object CreateLedCustomData(LedId ledId) => HeadsetStandIdMapping.DEFAULT.TryGetValue(ledId, out CorsairLedId id) ? id : CorsairLedId.Invalid; diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 8752ee5..4fdd829 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -48,8 +48,8 @@ namespace RGB.NET.Devices.Corsair } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath( - $@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, $@"Layouts\Corsair\Keyboards\{model}", $"{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + DeviceInfo.LogicalLayout.ToString()); } /// diff --git a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs index d9bb202..ed2c2fb 100644 --- a/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Memory/CorsairMemoryRGBDevice.cs @@ -48,7 +48,7 @@ namespace RGB.NET.Devices.Corsair } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Memory\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Memory", $"{model}.xml"), null); } /// diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index afa275d..6fcbffb 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -54,7 +54,7 @@ namespace RGB.NET.Devices.Corsair throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'"); } - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Mice", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index b83a0ca..e918b58 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -51,7 +51,7 @@ namespace RGB.NET.Devices.Corsair foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\Mousepads", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); } /// diff --git a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs index b8f6eab..02a8373 100644 --- a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs @@ -67,7 +67,7 @@ namespace RGB.NET.Devices.Logitech string layout = info.ImageLayout; string layoutPath = info.LayoutPath; - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, true); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Logitech", $"{layoutPath}.xml"), layout, true); } #endregion diff --git a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs index c0abd7f..6f58e93 100644 --- a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs @@ -47,7 +47,7 @@ namespace RGB.NET.Devices.Novation } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default"); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Novation\Launchpads", $"{model.ToUpper()}.xml"), "Default"); } /// diff --git a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs index 069aab8..79745d4 100644 --- a/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs +++ b/RGB.NET.Devices.Razer/ChromaLink/RazerChromaLinkRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\ChromaLink\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\ChromaLink", $"{model}.xml"), null); if (LedMapping.Count == 0) for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++) diff --git a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs index a5ef0ab..fb332dc 100644 --- a/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Headset/RazerHeadsetRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Headset\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Headset", $"{model}.xml"), null); if (LedMapping.Count == 0) for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++) diff --git a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs index 589faae..01f1820 100644 --- a/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keypad/RazerKeypadRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Keypad\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Keypad", $"{model}.xml"), null); if (LedMapping.Count == 0) { diff --git a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs index 2eeba61..4516f15 100644 --- a/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mouse/RazerMouseRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Mice\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Mice", $"{model}.xml"), null); if (LedMapping.Count == 0) { diff --git a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs index d0d8e1c..869c67b 100644 --- a/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Mousepad/RazerMousepadRGBDevice.cs @@ -31,7 +31,7 @@ namespace RGB.NET.Devices.Razer protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Mousepad\{model}.xml"), null); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Razer\Mousepad", $"{model}.xml"), null); if (LedMapping.Count == 0) for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++) diff --git a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs index b30d85b..f13d918 100644 --- a/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs +++ b/RGB.NET.Devices.SteelSeries/Generic/SteelSeriesRGBDevice.cs @@ -80,7 +80,7 @@ namespace RGB.NET.Devices.SteelSeries string layout = info.ImageLayout; string layoutPath = info.LayoutPath; - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\SteelSeries\{layoutPath}.xml"), layout, true); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\SteelSeries", $"{layoutPath}.xml"), layout, true); } #endregion