Exemplo n.º 1
0
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;
            try
            {
                IList <IRGBDevice>    devices = new List <IRGBDevice>();
                ICorsairLinkRGBDevice device  = new CorsairLinkRGBDevice(new CorsairLinkRGBDeviceInfo());
                device.Initialize();
                devices.Add(device);
                Devices = new ReadOnlyCollection <IRGBDevice>(devices);
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                else
                {
                    return(false);
                }
            }

            IsInitialized = true;
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Internal constructor of managed <see cref="MsiRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="msiDeviceType">The internal type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="manufacturer">The manufacturer-name of the <see cref="IRGBDevice"/>.</param>
 /// <param name="model">The model-name of the <see cref="IRGBDevice"/>.</param>
 internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "Msi", string model = "Generic Msi-Device")
 {
     this.DeviceType    = deviceType;
     this.MsiDeviceType = msiDeviceType;
     this.Manufacturer  = manufacturer;
     this.Model         = model;
 }
Exemplo n.º 3
0
        private SurfaceArrangementType AddType(RGBDeviceType type, int zIndex)
        {
            SurfaceArrangementType surfaceArrangementType = new(this, type, zIndex);

            Types.Add(surfaceArrangementType);
            return(surfaceArrangementType);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Internal constructor of managed <see cref="AsusRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
 /// <param name="manufacturer">The manufacturer-name of the <see cref="IRGBDevice"/>.</param>
 /// <param name="model">The model-name of the <see cref="IRGBDevice"/>.</param>
 internal AsusRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, string model = "Generic Asus-Device", string manufacturer = "Asus")
 {
     this.DeviceType   = deviceType;
     this.Handle       = handle;
     this.Model        = model;
     this.Manufacturer = manufacturer;
 }
        /// <summary>
        /// Loads all devices the given <see cref="IRGBDeviceProvider"/> is able to provide.
        /// </summary>
        /// <param name="deviceProvider">The <see cref="IRGBDeviceProvider"/> to load the devices from.</param>
        /// <param name="loadFilter">Specifies which types of devices to load.</param>
        /// <param name="exclusiveAccessIfPossible">Specifies whether the application should request exclusive access of possible or not.</param>
        /// <param name="throwExceptions">Specifies whether exception during the initialization sequence should be thrown or not.</param>
        public void LoadDevices(IRGBDeviceProvider deviceProvider, RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType()))
            {
                return;
            }

            List <IRGBDevice> addedDevices = new List <IRGBDevice>();

            if (deviceProvider.IsInitialized || deviceProvider.Initialize(loadFilter, exclusiveAccessIfPossible, throwExceptions))
            {
                _deviceProvider.Add(deviceProvider);

                foreach (IRGBDevice device in deviceProvider.Devices)
                {
                    if (_devices.Contains(device))
                    {
                        continue;
                    }

                    addedDevices.Add(device);

                    device.PropertyChanged += DeviceOnPropertyChanged;
                    _devices.Add(device);
                }
            }

            if (addedDevices.Any())
            {
                UpdateSurfaceRectangle();
                SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevices, true, false));
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Internal constructor of managed <see cref="NovationRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="model">The represented device model.</param>
 /// <param name="deviceId">The (midi)-id of the <see cref="IRGBDevice"/>.</param>
 /// <param name="colorCapabilities">The <see cref="NovationColorCapabilities"/> of the <see cref="IRGBDevice"/>.</param>
 internal NovationRGBDeviceInfo(RGBDeviceType deviceType, string model, int deviceId, NovationColorCapabilities colorCapabilities)
 {
     this.DeviceType        = deviceType;
     this.Model             = model;
     this.DeviceId          = deviceId;
     this.ColorCapabilities = colorCapabilities;
 }
 public G102DeviceInfo(RGBDeviceType deviceType, string deviceName, string manufacturer, string model)
 {
     DeviceType   = deviceType;
     DeviceName   = deviceName;
     Manufacturer = manufacturer;
     Model        = model;
 }
Exemplo n.º 8
0
        /// <inheritdoc />
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.Unknown, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                List <IRGBDevice> devices = new List <IRGBDevice>();
                foreach (IWS281XDeviceDefinition deviceDefinition in DeviceDefinitions)
                {
                    try
                    {
                        devices.AddRange(deviceDefinition.CreateDevices());
                    }
                    catch { if (throwExceptions)
                            {
                                throw;
                            }
                    }
                }
                Devices = devices;

                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Internal constructor of managed <see cref="CoolerMasterRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="deviceIndex">The <see cref="CoolerMasterDevicesIndexes"/> of the <see cref="IRGBDevice"/>.</param>
        internal CoolerMasterRGBDeviceInfo(RGBDeviceType deviceType, CoolerMasterDevicesIndexes deviceIndex)
        {
            this.DeviceType  = deviceType;
            this.DeviceIndex = deviceIndex;

            Model = deviceIndex.GetDescription();
        }
Exemplo n.º 10
0
 public SurfaceArrangementType(SurfaceArrangement surfaceArrangement, RGBDeviceType deviceType, int zIndex)
 {
     SurfaceArrangement = surfaceArrangement;
     DeviceType         = deviceType;
     ZIndex             = zIndex;
     Configurations     = new List <SurfaceArrangementConfiguration>();
 }
Exemplo n.º 11
0
        /// <inheritdoc />
        /// <summary>
        /// Internal constructor of managed <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDeviceInfo" />.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using</param>
        internal AsusKeyboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, CultureInfo culture)
            : base(deviceType, handle, "Asus", "Claymore")
        {
            SetLayouts(culture.KeyboardLayoutId);

            Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\Keyboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
        }
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;
            try
            {
                _GloriousModelO.Reload();
                IList <IRGBDevice>       devices = new List <IRGBDevice>();
                IGloriousModelORGBDevice device  = new GloriousModelORGBDevice(new GloriousModelORGBDeviceInfo());
                device.Initialize();
                devices.Add(device);
                Devices = new ReadOnlyCollection <IRGBDevice>(devices);
                if (_GloriousModelO.DetectDevice() == 1)
                {
                    IsInitialized = true;
                }
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                else
                {
                    return(false);
                }
            }


            return(true);
        }
Exemplo n.º 13
0
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                UpdateTrigger.Stop();

                IList <IRGBDevice> devices = new List <IRGBDevice>();
                UpdateTrigger.ClientGroups = new Dictionary <StreamingHueClient, StreamingGroup>();

                foreach (HueClientDefinition clientDefinition in ClientDefinitions)
                {
                    // Create a temporary for this definition
                    ILocalHueClient client = new LocalHueClient(clientDefinition.Ip);
                    client.Initialize(clientDefinition.AppKey);

                    // Get the entertainment groups, no point continuing without any entertainment groups
                    IReadOnlyList <Group> entertainmentGroups = client.GetEntertainmentGroups().GetAwaiter().GetResult();
                    if (!entertainmentGroups.Any())
                    {
                        continue;
                    }

                    // Get all lights once, all devices can use this list to identify themselves
                    List <Light> lights = client.GetLightsAsync().GetAwaiter().GetResult().ToList();

                    foreach (Group entertainmentGroup in entertainmentGroups.OrderBy(g => int.Parse(g.Id)))
                    {
                        StreamingHueClient streamingClient = new StreamingHueClient(clientDefinition.Ip, clientDefinition.AppKey, clientDefinition.ClientKey);
                        StreamingGroup     streamingGroup  = new StreamingGroup(entertainmentGroup.Locations);
                        streamingClient.Connect(entertainmentGroup.Id).GetAwaiter().GetResult();

                        UpdateTrigger.ClientGroups.Add(streamingClient, streamingGroup);
                        foreach (string lightId in entertainmentGroup.Lights.OrderBy(int.Parse))
                        {
                            HueDeviceInfo deviceInfo = new HueDeviceInfo(entertainmentGroup, lightId, lights);
                            HueDevice     device     = new HueDevice(deviceInfo);
                            device.Initialize(new HueUpdateQueue(UpdateTrigger, lightId, streamingGroup));
                            devices.Add(device);
                        }
                    }
                }

                UpdateTrigger.Start();
                Devices       = new ReadOnlyCollection <IRGBDevice>(devices);
                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
        /// <inheritdoc />
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.Unknown, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                UpdateTrigger.Stop();

                IList <IRGBDevice> devices = new List <IRGBDevice>();

                foreach (ISoIPDeviceDefinition deviceDefinition in DeviceDefinitions)
                {
                    try
                    {
                        ISoIPRGBDevice device = null;

                        switch (deviceDefinition)
                        {
                        case SoIPServerDeviceDefinition serverDeviceDefinition:
                            if (serverDeviceDefinition.Leds.Count > 0)
                            {
                                device = new SoIPServerRGBDevice(new SoIPServerRGBDeviceInfo(serverDeviceDefinition), serverDeviceDefinition.Leds);
                            }
                            break;

                        case SoIPClientDeviceDefinition clientDeviceDefinition:
                            device = new SoIPClientRGBDevice(new SoIPClientRGBDeviceInfo(clientDeviceDefinition));
                            break;
                        }

                        if (device != null)
                        {
                            device.Initialize(UpdateTrigger);
                            devices.Add(device);
                        }
                    }
                    catch { if (throwExceptions)
                            {
                                throw;
                            }
                    }
                }

                UpdateTrigger.Start();

                Devices       = new ReadOnlyCollection <IRGBDevice>(devices);
                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }

            return(true);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogitechZoneUpdateQueue"/> class.
 /// </summary>
 /// <param name="updateTrigger">The update trigger used by this queue.</param>
 /// <param name="deviceType">The tpye of the device this queue is updating.</param>
 public LogitechZoneUpdateQueue(IDeviceUpdateTrigger updateTrigger, RGBDeviceType deviceType)
     : base(updateTrigger)
 {
     if (!DEVICE_TYPE_MAPPING.TryGetValue(deviceType, out _deviceType))
     {
         throw new ArgumentException($"Invalid type '{deviceType.ToString()}'", nameof(deviceType));
     }
 }
Exemplo n.º 16
0
        internal LedenetRGBDeviceInfo(RGBDeviceType deviceType, string model, string ipAddress)
        {
            DeviceType = deviceType;
            Model      = model;
            IpAddress  = ipAddress;

            DeviceName = $"Ledenet light ({IpAddress})";
        }
Exemplo n.º 17
0
        /// <summary>
        /// Internal constructor of managed <see cref="RazerRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceId">The Id of the <see cref="IRGBDevice"/>.</param>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
        internal RazerRGBDeviceInfo(Guid deviceId, RGBDeviceType deviceType, string model)
        {
            this.DeviceId   = deviceId;
            this.DeviceType = deviceType;
            this.Model      = model;

            DeviceName = $"{Manufacturer} {Model}";
        }
        /// <summary>
        /// Internal constructor of managed <see cref="CoolerMasterRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="deviceIndex">The <see cref="CoolerMasterDevicesIndexes"/> of the <see cref="IRGBDevice"/>.</param>
        internal CoolerMasterRGBDeviceInfo(RGBDeviceType deviceType, CoolerMasterDevicesIndexes deviceIndex)
        {
            this.DeviceType  = deviceType;
            this.DeviceIndex = deviceIndex;

            Model      = deviceIndex.GetDescription();
            DeviceName = $"{Manufacturer} {Model}";
        }
Exemplo n.º 19
0
 /// <summary>
 /// Internal constructor of <see cref="DebugRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceType">The <see cref="RGBDeviceType"/> of the device.</param>
 /// <param name="manufacturer">The manufacturer of the device.</param>
 /// <param name="model">The model of the device.</param>
 /// <param name="lighting">The <see cref="RGBDeviceLighting"/> of the device.</param>
 /// <param name="supportsSyncBack">True if the device supports syncback; false if not.</param>
 internal DebugRGBDeviceInfo(RGBDeviceType deviceType, string manufacturer, string model, RGBDeviceLighting lighting, bool supportsSyncBack)
 {
     this.DeviceType       = deviceType;
     this.Manufacturer     = manufacturer;
     this.Model            = model;
     this.Lighting         = lighting;
     this.SupportsSyncBack = supportsSyncBack;
 }
        internal YeeLightRGBDeviceInfo(RGBDeviceType deviceType, string model, string ipAddress)
        {
            this.DeviceType = deviceType;
            this.Model      = model;
            this.IpAddress  = IpAddress;

            DeviceName = "YeeLight Light";
        }
Exemplo n.º 21
0
        /// <summary>
        /// Internal constructor of managed <see cref="WootingRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="deviceIndex">The <see cref="WootingDevicesIndexes"/> of the <see cref="IRGBDevice"/>.</param>
        internal WootingRGBDeviceInfo(RGBDeviceType deviceType, WootingDevicesIndexes deviceIndex)
        {
            this.DeviceType  = deviceType;
            this.DeviceIndex = deviceIndex;

            Model      = deviceIndex.GetDescription();
            DeviceName = $"{Manufacturer} {Model}";
        }
Exemplo n.º 22
0
 /// <summary>
 /// Internal constructor of managed <see cref="CorsairRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice{TDeviceInfo}"/>.</param>
 /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
 internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
 {
     this.CorsairDeviceIndex = deviceIndex;
     this.DeviceType         = deviceType;
     this.CorsairDeviceType  = nativeInfo.type;
     this.Model    = nativeInfo.model == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(nativeInfo.model);
     this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
 }
        internal OpenRGBDeviceInfo(RGBDeviceType deviceType, string model = null, string manufacturer = "OpenRGB")
        {
            this.DeviceType   = deviceType;
            this.Model        = model;
            this.Manufacturer = manufacturer;

            DeviceName = $"{Manufacturer} {Model}";
        }
Exemplo n.º 24
0
        /// <inheritdoc />
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                UpdateTrigger?.Stop();

                IList <IRGBDevice> devices = new List <IRGBDevice>();

                if (loadFilter.HasFlag(RGBDeviceType.LedMatrix))
                {
                    for (int index = 0; index < OutputDeviceBase.DeviceCount; index++)
                    {
                        try
                        {
                            MidiOutCaps outCaps = OutputDeviceBase.GetDeviceCapabilities(index);
                            if (outCaps.name == null)
                            {
                                continue;
                            }

                            NovationDevices?deviceId = (NovationDevices?)Enum.GetValues(typeof(NovationDevices))
                                                       .Cast <Enum>()
                                                       .FirstOrDefault(x => string.Equals(x.GetDeviceId(), outCaps.name, StringComparison.OrdinalIgnoreCase));

                            if (deviceId == null)
                            {
                                continue;
                            }

                            INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
                            device.Initialize(UpdateTrigger);
                            devices.Add(device);
                        }
                        catch { if (throwExceptions)
                                {
                                    throw;
                                }
                        }
                    }
                }

                UpdateTrigger?.Start();
                Devices       = new ReadOnlyCollection <IRGBDevice>(devices);
                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }

            return(true);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Internal constructor of managed <see cref="LogitechRGBDeviceInfo"/>.
 /// </summary>
 /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
 /// <param name="model">The represented device model.</param>
 /// <param name="deviceCaps">The lighting-capabilities of the device.</param>
 /// <param name="imageLayout">The layout used to decide which images to load.</param>
 /// <param name="layoutPath">The path/name of the layout-file.</param>
 internal LogitechRGBDeviceInfo(RGBDeviceType deviceType, string model, LogitechDeviceCaps deviceCaps,
                                string imageLayout, string layoutPath)
 {
     this.DeviceType  = deviceType;
     this.Model       = model;
     this.DeviceCaps  = deviceCaps;
     this.ImageLayout = imageLayout;
     this.LayoutPath  = layoutPath;
 }
Exemplo n.º 26
0
        internal MsiusbRGBDeviceInfo(RGBDeviceType deviceType, int deviceID, string manufacturer = "MSI", string model = "Generic MysticLight USB Controller")
        {
            this.DeviceType   = deviceType;
            this.MsiDeviceID  = deviceID;
            this.Manufacturer = manufacturer;
            this.Model        = model;

            DeviceName = $"{Manufacturer} {Model}";
        }
        internal YeeLightRGBDeviceInfo(RGBDeviceType deviceType, string model, string ipAddress, bool placeHolder)
        {
            DeviceType  = deviceType;
            Model       = model;
            IpAddress   = ipAddress;
            PlaceHolder = placeHolder;

            DeviceName = "YeeLight Light";
        }
        internal MsirgbRGBDeviceInfo(RGBDeviceType deviceType, int deviceID, string manufacturer = "MSIRGB", string model = "Generic I/O Superchip")
        {
            this.DeviceType   = deviceType;
            this.MsiDeviceID  = deviceID;
            this.Manufacturer = manufacturer;
            this.Model        = model;

            DeviceName = $"{Manufacturer} {Model}";
        }
Exemplo n.º 29
0
        /// <summary>
        /// Internal constructor of managed <see cref="MsiRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="msiDeviceType">The internal type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="manufacturer">The manufacturer-name of the <see cref="IRGBDevice"/>.</param>
        /// <param name="model">The model-name of the <see cref="IRGBDevice"/>.</param>
        internal MsiRGBDeviceInfo(RGBDeviceType deviceType, string msiDeviceType, string manufacturer = "MSI", string model = "Generic Msi-Device")
        {
            this.DeviceType    = deviceType;
            this.MsiDeviceType = msiDeviceType;
            this.Manufacturer  = manufacturer;
            this.Model         = model;

            DeviceName = $"{Manufacturer} {Model}";
        }
Exemplo n.º 30
0
        /// <summary>
        /// Internal constructor of managed <see cref="NovationRGBDeviceInfo"/>.
        /// </summary>
        /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
        /// <param name="model">The represented device model.</param>
        /// <param name="deviceId">The (midi)-id of the <see cref="IRGBDevice"/>.</param>
        /// <param name="colorCapabilities">The <see cref="NovationColorCapabilities"/> of the <see cref="IRGBDevice"/>.</param>
        internal NovationRGBDeviceInfo(RGBDeviceType deviceType, string model, int deviceId, NovationColorCapabilities colorCapabilities)
        {
            this.DeviceType        = deviceType;
            this.Model             = model;
            this.DeviceId          = deviceId;
            this.ColorCapabilities = colorCapabilities;

            DeviceName = $"{Manufacturer} {Model}";
        }