public static void Commit(MontageAction action) { var now = DateTime.Now; var time = (int)(now - recordStartTime).TotalMilliseconds; var cmd = new MontageCommand { Action = action, Time = time, Id = Log.Id, }; MontageCommandIO.AppendCommand(cmd, FileName); Id++; if (action == MontageAction.Commit) { goodSplitTime += now - lastCommitTime; } if (action == MontageAction.CommitAndSplit) { goodStartTime += goodSplitTime; goodSplitTime = new TimeSpan(); } lastCommitTime = now; }
void MainWindowKeyDown(object sender, KeyEventArgs e) { MontageAction action = MontageAction.Commit; switch (e.Key) { case Key.Enter: action = MontageAction.Commit; break; case Key.Decimal: action = MontageAction.Delete; break; case Key.NumPad1: action = MontageAction.Screen; break; case Key.NumPad2: action = MontageAction.Face; break; case Key.Add: action = MontageAction.CommitAndSplit; break; case Key.NumPad9: this.Scroller.ScrollToVerticalOffset(Scroller.VerticalOffset - 100); return; case Key.NumPad6: this.Scroller.ScrollToVerticalOffset(Scroller.VerticalOffset + 100); return; case Key.NumPad8: this.Viewer.Zoom += 20; return; case Key.NumPad5: this.Viewer.Zoom -= 20; return; default: ShowStatus("question"); return; } Log.Commit(action); if (action != MontageAction.Delete) { ShowStatus("clapper"); } else { ShowStatus("trash"); } if (action == MontageAction.Face) { VideoSource.SetResourceReference(Image.SourceProperty, "face"); } if (action == MontageAction.Screen) { VideoSource.SetResourceReference(Image.SourceProperty, "screen"); } // refresh displayed clock label now TimerTick(null, EventArgs.Empty); clockTimer.Stop(); clockTimer.Start(); }
/// <summary> /// Intialize ImageCaster commands, parse arguments, /// and process the command the user input. /// /// This method also times the time taken to perform /// the command to help optimizations in development /// or user configurations. /// </summary> /// <param name="args">Command line arguments.</param> /// <returns>The exit code.</returns> public static async Task <int> Main(string[] args) { RootCommand command = new RootCommand("Perform aggregate tasks against a collection of images") { new Command("archive", "Archive collections of images or files into compressed archives") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new ArchiveAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (FileNotFoundException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) }, new Command("build", "Export the output images from the source") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new BuildAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } return((int)ExitCode.Normal); } catch (JsonException ex) { return(OnJsonException(ex)); } }) }, new Command("check", "Validate that the project structure and standards are maintained") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new CheckAction(config.Checks); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (ValidationException ex) { Logger.Error(ex.Message); return((int)ExitCode.CheckFailures); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) }, new Command("montage", "Export a single image comprised of all matching output images") { Handler = CommandHandler.Create <FileInfo>((file) => { try { ImageCasterConfig config = ConfigurationFile.LoadFromFile(file.FullName); IAction action = new MontageAction(config); try { action.Execute(); } catch (ConfigurationException ex) { Logger.Error(ex.Message); return((int)ExitCode.MalformedConfigFields); } catch (Exception ex) { return(OnInternalException(ex)); } } catch (JsonException ex) { return(OnJsonException(ex)); } return((int)ExitCode.Normal); }) } }; command.Name = "imagecaster"; CommandLineBuilder commandLineBuilder = new CommandLineBuilder(command) { EnableDirectives = false }; // Default middlewares we want to add to our console application. commandLineBuilder.UseVersionOption().UseHelp().UseParseErrorReporting().CancelOnProcessTermination(); // These are our own defined middlewares. commandLineBuilder.UseLogger().UseTimer().UseLicense().UseImageCaster(); Parser parser = commandLineBuilder.Build(); return(await parser.InvokeAsync(args)); }
public void Montage([FromBody] ImageCasterConfig config) { MontageAction montage = new MontageAction(config); montage.Execute(); }