示例#1
0
 internal void ApplyDevice(ArtemisDevice artemisDevice)
 {
     Device = artemisDevice;
     foreach (ArtemisLedLayout artemisLedLayout in Leds)
     {
         artemisLedLayout.ApplyDevice(Device);
     }
 }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#5
0
 internal ArtemisLed(Led led, ArtemisDevice device)
 {
     RgbLed = led;
     Device = device;
     CalculateRectangles();
 }
示例#6
0
 private bool DoesLayerCoverDevice(ArtemisDevice device)
 {
     return(device.Leds.All(l => Layer.Leds.Contains(l)));
 }
示例#7
0
 public ArtemisLed(Led led, ArtemisDevice device)
 {
     RgbLed = led;
     Device = device;
     CalculateRenderRectangle();
 }
示例#8
0
 internal DeviceEventArgs(ArtemisDevice device)
 {
     Device = device;
 }
示例#9
0
 public ScaleColorCorrection(ArtemisDevice device)
 {
     _device = device;
 }