Esempio n. 1
0
 internal void ApplyDevice(ArtemisDevice artemisDevice)
 {
     Device = artemisDevice;
     foreach (ArtemisLedLayout artemisLedLayout in Leds)
     {
         artemisLedLayout.ApplyDevice(Device);
     }
 }
Esempio n. 2
0
        internal void ApplyDevice(ArtemisDevice device)
        {
            Led = device.Leds.FirstOrDefault(d => d.RgbLed.Id.ToString() == RgbLayout.Id);
            if (Led != null)
            {
                Led.Layout = this;
            }

            ApplyCustomLedData(device);
        }
Esempio n. 3
0
        /// <summary>
        /// Automatically determine hints for this layer
        /// </summary>
        public List <IAdaptionHint> DetermineHints(IEnumerable <ArtemisDevice> devices)
        {
            List <IAdaptionHint> newHints = new();

            if (devices.All(DoesLayerCoverDevice))
            {
                DeviceAdaptionHint hint = new() { DeviceType = RGBDeviceType.All };
                AdaptionHints.Add(hint);
                newHints.Add(hint);
            }
            else
            {
                // Any fully covered device will add a device adaption hint for that type
                foreach (IGrouping <ArtemisDevice, ArtemisLed> deviceLeds in Layer.Leds.GroupBy(l => l.Device))
                {
                    ArtemisDevice device = deviceLeds.Key;
                    // If there is already an adaption hint for this type, don't add another
                    if (AdaptionHints.Any(h => h is DeviceAdaptionHint d && d.DeviceType == device.RgbDevice.DeviceInfo.DeviceType))
                    {
                        continue;
                    }
                    if (DoesLayerCoverDevice(device))
                    {
                        DeviceAdaptionHint hint = new() { DeviceType = device.RgbDevice.DeviceInfo.DeviceType };
                        AdaptionHints.Add(hint);
                        newHints.Add(hint);
                    }
                }

                // Any fully covered category will add a category adaption hint for its category
                foreach (DeviceCategory deviceCategory in Enum.GetValues <DeviceCategory>())
                {
                    if (AdaptionHints.Any(h => h is CategoryAdaptionHint c && c.Category == deviceCategory))
                    {
                        continue;
                    }

                    List <ArtemisDevice> categoryDevices = devices.Where(d => d.Categories.Contains(deviceCategory)).ToList();
                    if (categoryDevices.Any() && categoryDevices.All(DoesLayerCoverDevice))
                    {
                        CategoryAdaptionHint hint = new() { Category = deviceCategory };
                        AdaptionHints.Add(hint);
                        newHints.Add(hint);
                    }
                }
            }

            return(newHints);
        }
Esempio n. 4
0
        private void ApplyCustomLedData(ArtemisDevice artemisDevice)
        {
            if (LayoutCustomLedData.LogicalLayouts == null || !LayoutCustomLedData.LogicalLayouts.Any())
            {
                return;
            }

            Uri layoutDirectory = new(Path.GetDirectoryName(DeviceLayout.FilePath) !+"\\", UriKind.Absolute);
            // Prefer a matching layout or else a default layout (that has no name)
            LayoutCustomLedDataLogicalLayout logicalLayout = LayoutCustomLedData.LogicalLayouts
                                                             .OrderBy(l => l.Name == artemisDevice.LogicalLayout)
                                                             .ThenBy(l => l.Name == null)
                                                             .First();

            LogicalName = logicalLayout.Name;
            Image       = new Uri(layoutDirectory, logicalLayout.Image);
        }
Esempio n. 5
0
 internal ArtemisLed(Led led, ArtemisDevice device)
 {
     RgbLed = led;
     Device = device;
     CalculateRectangles();
 }
Esempio n. 6
0
 private bool DoesLayerCoverDevice(ArtemisDevice device)
 {
     return(device.Leds.All(l => Layer.Leds.Contains(l)));
 }
Esempio n. 7
0
 public ArtemisLed(Led led, ArtemisDevice device)
 {
     RgbLed = led;
     Device = device;
     CalculateRenderRectangle();
 }
Esempio n. 8
0
 internal DeviceEventArgs(ArtemisDevice device)
 {
     Device = device;
 }
Esempio n. 9
0
 public ScaleColorCorrection(ArtemisDevice device)
 {
     _device = device;
 }