private void SaveFile_Impl() { if (!string.IsNullOrEmpty(OpenFileName)) { try { var list = Showlights.Items .OrderBy(sl => sl.Time) .Select(x => x.Model) .ToList(); ShowLights.Save(OpenFileName, list); if (FileDirty) { UndoManager.FileWasSaved(); FileDirty = false; } } catch (Exception ex) { services.ShowError("Saving the file failed:" + Environment.NewLine + ex.Message); } } else { SaveFileAs_Impl(); } }
private static int Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; int returnCode = 0; Parser.Default .ParseArguments <Options>(args) .WithParsed(o => { var beamSourceArrangement = o.BeamSourceArrangement switch { null => o.FogSourceArrangement, _ => o.BeamSourceArrangement }; var targetPath = o.TargetPath switch { null => Path.Combine(".", "showlights.xml"), _ => o.TargetPath }; var fogOptions = new FogGenerationOptions { ShouldGenerate = true, GenerationMethod = ParseFogMethod(o.FogMethod), MinTimeBetweenNotes = Math.Max(0.01f, o.FogTime), ChangeFogColorEveryNthBar = Math.Max(1, o.FogBars), RandomizeColors = o.Randomize.Contains("fog") }; var beamOptions = new BeamGenerationOptions { ShouldGenerate = true, GenerationMethod = ParseBeamMethod(o.BeamMethod), MinTimeBetweenNotes = Math.Max(0.01f, o.BeamTime), UseCompatibleColors = o.UseCompatibleColors, RandomizeColors = o.Randomize.Contains("beam") }; var laserOptions = new LaserGenerationOptions { ShouldGenerate = true, DisableLaserLights = o.EnableLasers != true }; if (o.Verbose) { Console.WriteLine("FOG"); Console.WriteLine("Source: {0}", o.FogSourceArrangement); Console.WriteLine("Method: {0}", fogOptions.GenerationMethod); if (fogOptions.GenerationMethod == FogGenerationMethod.ChangeEveryNthBar) { Console.WriteLine("Minimum bars: {0}", fogOptions.ChangeFogColorEveryNthBar); } else if (fogOptions.GenerationMethod == FogGenerationMethod.MinTimeBetweenChanges) { Console.WriteLine("Minimum time: {0} seconds", fogOptions.MinTimeBetweenNotes); } Console.WriteLine("Randomized: {0}", fogOptions.RandomizeColors); Console.WriteLine("--------------------------------------------"); Console.WriteLine("BEAMS"); Console.WriteLine("Source: {0}", beamSourceArrangement); Console.WriteLine("Method: {0}", beamOptions.GenerationMethod); if (beamOptions.GenerationMethod == BeamGenerationMethod.MinTimeBetweenChanges) { Console.WriteLine("Minimum time: {0} seconds", beamOptions.MinTimeBetweenNotes); } Console.WriteLine("Use compatible colors: {0}", beamOptions.UseCompatibleColors); Console.WriteLine("Randomized: {0}", beamOptions.RandomizeColors); Console.WriteLine("--------------------------------------------"); Console.WriteLine("LASERS"); Console.WriteLine("Enabled: {0}", !laserOptions.DisableLaserLights); Console.WriteLine("--------------------------------------------"); Console.WriteLine("Output path: {0}", targetPath); } try { var generator = new Generator(o.FogSourceArrangement, beamSourceArrangement, fogOptions, beamOptions, laserOptions); ShowLights.Save(targetPath, generator.Generate()); if (o.Verbose) { Console.WriteLine("File generated successfully."); } } catch (Exception e) { Console.WriteLine("ERROR: Generation failed: {0}", e.Message); Console.WriteLine(e.StackTrace); returnCode = 1; } }); return(returnCode); }