Ejemplo n.º 1
0
 public static LedSettingsDto ToDto(this LedSetting ledSetting)
 {
     return(new LedSettingsDto()
     {
         Id = ledSetting.Id.ToString(),
         SettingName = ledSetting.SettingName,
         ComPortName = ledSetting.ComPortName,
         UserId = ledSetting.UserId
     });
 }
Ejemplo n.º 2
0
        public LedSetting AddSetting(string userId)
        {
            var newSetting = new LedSetting
            {
                ComPortName = "COM1",
                SettingName = "Setting1",
                Id          = Guid.NewGuid(),
                UserId      = userId
            };

            _dbContext.LedSettings.Add(newSetting);
            _dbContext.SaveChanges();

            return(newSetting);
        }
Ejemplo n.º 3
0
            internal MotherboardLedSettingsImpl(IMotherboardLedLayout layout, LedSetting defaultSetting)
            {
                dirty       = true;
                ledSettings = new LedSetting[layout.Length];
                IEnumerator <LedType> e = layout.GetEnumerator();

                for (int i = 0; i < ledSettings.Length; i++)
                {
                    if (!e.MoveNext())
                    {
                        throw new GLedAPIException(string.Format("Number of layouts < length ({0})", ledSettings.Length));
                    }
                    ledSettings[i] = defaultSetting;
                }
            }
Ejemplo n.º 4
0
 public void SetAll(LedSetting ledSetting) => motherboard.Value.SetAll(ledSetting);
Ejemplo n.º 5
0
        public void Main(string[] args)
        {
            context.SetDefaults();

            try
            {
                List <string> afterGeneric = genericOptions.Parse(args);

                if (context.flag_Help)
                {
                    ShowHelp(stdout);
                    return;
                }

                if (context.flag_Version)
                {
                    ShowVersion(stdout);
                    return;
                }

                zoneOptions.Parse(afterGeneric);

                if (context.flag_List || context.verbosity > 0)
                {
                    for (int i = 0; i < motherboardLEDs.Layout.Length; i++)
                    {
                        stdout.WriteLine("Zone {0}: {1}", i, motherboardLEDs.Layout[i]);
                    }
                }

                if (defaultZone.Count == 0 && zones.Count == 0)
                {
                    return;
                }
                else if (defaultZone.Count > 0 && zones.Count > 0)
                {
                    throw new InvalidOperationException(string.Format("Unexpected options {0} before zone-specific options", string.Join(" ", defaultZone.ToArray())));
                }

                foreach (int zone in zones.Keys)
                {
                    LedSetting setting = null;
                    foreach (LedSettingArgParser parser in ledSettingArgParsers)
                    {
                        setting = parser.TryParse(zones[zone]);
                        if (setting != null)
                        {
                            break;
                        }
                    }
                    motherboardLEDs.LedSettings[zone] = setting ?? throw new InvalidOperationException(string.Format("No LED mode specified for zone {0}", zone));
                }
                if (context.verbosity > 0)
                {
                    foreach (int zone in zones.Keys)
                    {
                        stdout.WriteLine("Set zone {0}: {1}", zone, motherboardLEDs.LedSettings[zone]);
                    }
                }
                if (zones.Count > 0)
                {
                    motherboardLEDs.Set(zones.Keys);
                }

                if (defaultZone.Count > 0)
                {
                    LedSetting setting = null;
                    foreach (LedSettingArgParser parser in ledSettingArgParsers)
                    {
                        setting = parser.TryParse(defaultZone);
                        if (setting != null)
                        {
                            break;
                        }
                    }

                    if (setting == null)
                    {
                        throw new InvalidOperationException("No LED mode specified");
                    }
                    if (context.verbosity > 0)
                    {
                        stdout.WriteLine("Set All: {0}", setting);
                    }
                    motherboardLEDs.SetAll(setting);
                    return;
                }
            }
            catch (Exception e)
            {
                ShowHelp(stderr);
                stderr.WriteLine();
                stderr.WriteLine("Error: {0}", e.ToString());
                throw;
            }
            return;
        }