Ejemplo n.º 1
0
 public void Setup()
 {
     mock        = new GLedApiv1_0_0Mock(true);
     motherboard = new RGBFusionMotherboard(new GLedApiDotNet.Raw.GLedAPIv1_0_0Wrapper(mock));
 }
Ejemplo n.º 2
0
        public Application(IRGBFusionMotherboard motherboardLEDs, TextWriter stdout, TextWriter stderr)
        {
            this.motherboardLEDs = motherboardLEDs;
            this.stdout          = stdout;
            this.stderr          = stderr;

            context = new ApplicationContext();

            defaultZone = new List <string>();
            currentZone = defaultZone;

            genericOptions = new OptionSet
            {
                { string.Format("Usage: {0} [OPTION]... [[LEDSETTING] | [ZONE LEDSETTING]...]", AppDomain.CurrentDomain.FriendlyName) },
                { "Set RGB Fusion motherboard LEDs" },
                { "" },
                { "Options:" },
                { "v|verbose", v => context.verbosity++ },
                { "l|list", "list zones", v => context.flag_List = true },
                { "?|h|help", "show help and exit", v => context.flag_Help = true },
                { "version", "show version information and exit", v => context.flag_Version = true },
                { "" }
            };

            zoneOptions = new OptionSet
            {
                { "ZONE:" },
                { "z|zone=", "set zone", (int zone) => {
                      if (zone < 0)
                      {
                          throw new InvalidOperationException("Zones must be positive integers");
                      }
                      if (zones.ContainsKey(zone))
                      {
                          throw new InvalidOperationException(string.Format("Zone {0} already specified", zone));
                      }
                      if (zone >= motherboardLEDs.Layout.Length)
                      {
                          throw new InvalidOperationException(string.Format("Zone is {0}, max supported is {1}", zone, motherboardLEDs.Layout.Length));
                      }
                      currentZone = new List <string>();
                      zones.Add(zone, currentZone);
                  } },
                { "<>", v => currentZone.Add(v) },
            };

            ledSettingArgParsers = new List <LedSettingArgParser>
            {
                new StaticColorArgParser(),
                new ColorCycleArgParser(),
                new PulseArgParser(),
                new FlashArgParser(),
                new OffArgParser()
            };

            helpOptionSets = new List <OptionSet>
            {
                genericOptions,
                zoneOptions,
                new OptionSet {
                    ""
                },
                new OptionSet {
                    "LEDSETTING options:"
                }
            };
            foreach (LedSettingArgParser argParser in ledSettingArgParsers)
            {
                helpOptionSets.Add(new OptionSet {
                    ""
                });
                helpOptionSets.Add(argParser.RequiredOptions);
                helpOptionSets.Add(argParser.ExtraOptions);
            }
        }