public DeviceManager() { devices.Add(new Devices.Logitech.LogitechDevice()); devices.Add(new Devices.Corsair.CorsairDevice()); devices.Add(new Devices.Razer.RazerDevice()); string devices_scripts_path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "Scripts", "Devices"); if (Directory.Exists(devices_scripts_path)) { foreach (string device_script in Directory.EnumerateFiles(devices_scripts_path, "*.*")) { try { string ext = Path.GetExtension(device_script); switch (ext) { case ".py": var scope = Global.PythonEngine.ExecuteFile(device_script); dynamic main_type; if (scope.TryGetVariable("main", out main_type)) { dynamic script = Global.PythonEngine.Operations.CreateInstance(main_type); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(scripted_device); } else { Global.logger.LogLine(string.Format("Script \"{0}\" does not contain a public 'main' class", device_script), Logging_Level.External); } break; case ".cs": System.Reflection.Assembly script_assembly = CSScript.LoadCodeFrom(device_script); foreach (Type typ in script_assembly.ExportedTypes) { dynamic script = Activator.CreateInstance(typ); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(scripted_device); } break; default: Global.logger.LogLine(string.Format("Script with path {0} has an unsupported type/ext! ({1})", device_script, ext), Logging_Level.External); break; } } catch (Exception exc) { Global.logger.LogLine(string.Format("An error occured while trying to load script {0}. Exception: {1}", device_script, exc, Logging_Level.External)); } } } }
public DeviceManager() { devices.Add(new DeviceContainer(new Devices.Logitech.LogitechDevice())); // Logitech Device devices.Add(new DeviceContainer(new Devices.Corsair.CorsairDevice())); // Corsair Device devices.Add(new DeviceContainer(new Devices.Razer.RazerDevice())); // Razer Device devices.Add(new DeviceContainer(new Devices.Roccat.RoccatDevice())); // Roccat Device devices.Add(new DeviceContainer(new Devices.Clevo.ClevoDevice())); // Clevo Device devices.Add(new DeviceContainer(new Devices.CoolerMaster.CoolerMasterDevice())); // CoolerMaster Device devices.Add(new DeviceContainer(new Devices.AtmoOrbDevice.AtmoOrbDevice())); // AtmoOrb Ambilight Device devices.Add(new DeviceContainer(new Devices.SteelSeries.SteelSeriesDevice())); // SteelSeries Device devices.Add(new DeviceContainer(new Devices.UnifiedHID.UnifiedHIDDevice())); // UnifiedHID Device devices.Add(new DeviceContainer(new Devices.Wooting.WootingDevice())); // Wooting Device devices.Add(new DeviceContainer(new Devices.Creative.SoundBlasterXDevice())); // SoundBlasterX Device devices.Add(new DeviceContainer(new Devices.LightFX.LightFxDevice())); //Alienware devices.Add(new DeviceContainer(new Devices.Dualshock.DualshockDevice())); //DualShock 4 Device devices.Add(new DeviceContainer(new Devices.Drevo.DrevoDevice())); // Drevo Device devices.Add(new DeviceContainer(new Devices.YeeLight.YeeLightDevice())); // YeeLight Device devices.Add(new DeviceContainer(new Devices.Asus.AsusDevice())); // Asus Device devices.Add(new DeviceContainer(new Devices.NZXT.NZXTDevice())); //NZXT Device devices.Add(new DeviceContainer(new Devices.Vulcan.VulcanDevice())); string devices_scripts_path = System.IO.Path.Combine(Global.ExecutingDirectory, "Scripts", "Devices"); if (Directory.Exists(devices_scripts_path)) { foreach (string device_script in Directory.EnumerateFiles(devices_scripts_path, "*.*")) { try { string ext = Path.GetExtension(device_script); switch (ext) { case ".py": var scope = Global.PythonEngine.ExecuteFile(device_script); dynamic main_type; if (scope.TryGetVariable("main", out main_type)) { dynamic script = Global.PythonEngine.Operations.CreateInstance(main_type); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(new DeviceContainer(scripted_device)); } else { Global.logger.Error("Script \"{0}\" does not contain a public 'main' class", device_script); } break; case ".cs": System.Reflection.Assembly script_assembly = CSScript.LoadFile(device_script); foreach (Type typ in script_assembly.ExportedTypes) { dynamic script = Activator.CreateInstance(typ); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(new DeviceContainer(scripted_device)); } break; default: Global.logger.Error("Script with path {0} has an unsupported type/ext! ({1})", device_script, ext); break; } } catch (Exception exc) { Global.logger.Error("An error occured while trying to load script {0}. Exception: {1}", device_script, exc); } } } SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; }
public DeviceManager() { //DeviceContainers.Add(new DeviceContainer(new Clevo.ClevoDevice())); //DeviceContainers.Add(new DeviceContainer(new AtmoOrbDevice.AtmoOrbDevice())); //DeviceContainers.Add(new DeviceContainer(new SteelSeries.SteelSeriesDevice())); //DeviceContainers.Add(new DeviceContainer(new UnifiedHID.UnifiedHIDDevice())); //DeviceContainers.Add(new DeviceContainer(new Creative.SoundBlasterXDevice())); //DeviceContainers.Add(new DeviceContainer(new LightFX.LightFxDevice())); //DeviceContainers.Add(new DeviceContainer(new YeeLight.YeeLightDevice())); //DeviceContainers.Add(new DeviceContainer(new Asus.AsusDevice())); string devices_scripts_path = System.IO.Path.Combine(Global.ExecutingDirectory, "Scripts", "Devices"); if (Directory.Exists(devices_scripts_path)) { foreach (string device_script in Directory.EnumerateFiles(devices_scripts_path, "*.*")) { try { string ext = Path.GetExtension(device_script); switch (ext) { case ".py": var scope = Global.PythonEngine.ExecuteFile(device_script); dynamic main_type; if (scope.TryGetVariable("main", out main_type)) { dynamic script = Global.PythonEngine.Operations.CreateInstance(main_type); IDevice scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); DeviceContainers.Add(new DeviceContainer(scripted_device)); } else { Global.logger.Error("Script \"{0}\" does not contain a public 'main' class", device_script); } break; case ".cs": System.Reflection.Assembly script_assembly = CSScript.LoadFile(device_script); foreach (Type typ in script_assembly.ExportedTypes) { dynamic script = Activator.CreateInstance(typ); IDevice scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); DeviceContainers.Add(new DeviceContainer(scripted_device)); } break; default: Global.logger.Error("Script with path {0} has an unsupported type/ext! ({1})", device_script, ext); break; } } catch (Exception exc) { Global.logger.Error("An error occured while trying to load script {0}. Exception: {1}", device_script, exc); } } } string deviceDllFolder = Path.Combine(Global.ExecutingDirectory, "Plugins", "Devices"); Global.logger.Info("Loading Device Plugins"); if (Directory.Exists(deviceDllFolder)) { foreach (var deviceDll in Directory.EnumerateFiles(deviceDllFolder, "Device-*.dll")) { try { var deviceAssembly = Assembly.LoadFile(deviceDll); foreach (var type in deviceAssembly.GetExportedTypes()) { if (typeof(IDevice).IsAssignableFrom(type)) { IDevice devDll = (IDevice)Activator.CreateInstance(type); DeviceContainers.Add(new DeviceContainer(devDll)); } } } catch (Exception e) { Global.logger.Error($"Error loading device dll: {deviceDll}. Exception: {e.Message}"); } } } SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; }
public DeviceManager() { devices.Add(new DeviceContainer(new Devices.Logitech.LogitechDevice())); // Logitech Device devices.Add(new DeviceContainer(new Devices.Corsair.CorsairDevice())); // Corsair Device devices.Add(new DeviceContainer(new Devices.Razer.RazerDevice())); // Razer Device //devices.Add(new Devices.Roccat.RoccatDevice()); // Roccat Device devices.Add(new DeviceContainer(new Devices.Clevo.ClevoDevice())); // Clevo Device devices.Add(new DeviceContainer(new Devices.CoolerMaster.CoolerMasterDevice())); // CoolerMaster Device devices.Add(new DeviceContainer(new Devices.AtmoOrbDevice.AtmoOrbDevice())); // AtmoOrb Ambilight Device devices.Add(new DeviceContainer(new Devices.SteelSeries.SteelSeriesDevice())); // SteelSeries Device string devices_scripts_path = System.IO.Path.Combine(Global.ExecutingDirectory, "Scripts", "Devices"); if (Directory.Exists(devices_scripts_path)) { foreach (string device_script in Directory.EnumerateFiles(devices_scripts_path, "*.*")) { try { string ext = Path.GetExtension(device_script); switch (ext) { case ".py": var scope = Global.PythonEngine.ExecuteFile(device_script); dynamic main_type; if (scope.TryGetVariable("main", out main_type)) { dynamic script = Global.PythonEngine.Operations.CreateInstance(main_type); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(new DeviceContainer(scripted_device)); } else { Global.logger.Error("Script \"{0}\" does not contain a public 'main' class", device_script); } break; case ".cs": System.Reflection.Assembly script_assembly = CSScript.LoadCodeFrom(device_script); foreach (Type typ in script_assembly.ExportedTypes) { dynamic script = Activator.CreateInstance(typ); Device scripted_device = new Devices.ScriptedDevice.ScriptedDevice(script); devices.Add(new DeviceContainer(scripted_device)); } break; default: Global.logger.Error("Script with path {0} has an unsupported type/ext! ({1})", device_script, ext); break; } } catch (Exception exc) { Global.logger.Error("An error occured while trying to load script {0}. Exception: {1}", device_script, exc); } } } }