private amBXScene BuildScene(Settings settings, List<Frame> frames) { return new amBXScene() { SceneType = eSceneType.Singular, Frames = frames }; }
public Settings Read() { ValidateMessage(); var settings = new Settings(message); ReadSwitchesIntoSettings(settings); ThrowIfSettingsAreInvalid(settings); return settings; }
public MorseFrameBuilder AddFrames(Settings settings, IEnumerable<IMorseBlock> blocks) { foreach (var block in blocks) { AddFrame(settings, block); } return this; }
private List<Frame> GetFrames(Settings settings) { var morseBlocks = messageTranslator.Translate(settings.Message); if (settings.RepeatMessage) { morseBlocks.Add(new MessageEndMarker()); } return frameBuilder.AddFrames(settings, morseBlocks).Build(); }
private void AddFrame(Settings settings, IMorseBlock block) { AddFrame() .WithRepeated(settings.RepeatMessage) .WithFrameLength(block.Length * settings.UnitLength); if (settings.LightsEnabled) { WithLightSection(GetLightSection(block.Enabled, settings.Colour)); } if (settings.RumblesEnabled) { WithRumbleSection(GetRumbleSection(block.Enabled, settings.Rumble)); } }
private void ThrowIfSettingsAreInvalid(Settings settings) { if (!settings.LightsEnabled && !settings.RumblesEnabled) { throw new UsageException("Both lights and rumbles are disabled - nothing to show"); } if (settings.Colour.Red == 0 && settings.Colour.Green == 0 && settings.Colour.Blue == 0) { throw new UsageException("Invalid colour specified"); } }
private void ReadSwitchIntoSettings(Settings settings, string @switch) { switch (@switch.Substring(0, 2).ToLower()) { case @"/d": settings.RepeatMessage = true; break; case @"/r": settings.RumblesEnabled = true; break; case @"/l": settings.LightsEnabled = false; break; case @"/c": settings.Colour = ParseColour(@switch); break; case @"/u": settings.UnitLength = ParseUnitLength(@switch); break; } }
private void ReadSwitchesIntoSettings(Settings settings) { foreach (var @switch in switches) { try { ReadSwitchIntoSettings(settings, @switch); } catch (Exception e) { throw new UsageException("Error when reading Switch " + @switch + " : " + e); } } }
public amBXScene Generate(Settings settings) { var frames = GetFrames(settings); return BuildScene(settings, frames); }