private void OrganizeComplete(MediaOrganizer organizer, OrganizeSummary summary) { if (this.InvokeRequired) { this.BeginInvoke(() => OrganizeComplete(organizer, summary)); return; } MessageBox.Show(summary.ToString(), "Media organization done", MessageBoxButtons.OK, MessageBoxIcon.Information); ProgressEnded(); }
private void OrganizeException(MediaOrganizer organizer, Exception exception) { if (this.InvokeRequired) { this.BeginInvoke(() => OrganizeException(organizer, exception)); return; } Exception innerException = exception.GetInnerMost(); MessageBox.Show(innerException.Message, "Media organization failed", MessageBoxButtons.OK, MessageBoxIcon.Error); ProgressEnded(); }
private void ParseComplete(MediaOrganizer organizer, ParseSummary summary) { if (this.InvokeRequired) { this.BeginInvoke(() => ParseComplete(organizer, summary)); return; } if (MessageBox.Show(summary.ToString(), "Continue organization?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { organizer.Abort(); ProgressEnded(); } }
private void ReportProgress(MediaOrganizer organizer, double value, string message) { if (this.InvokeRequired) { this.BeginInvoke(() => ReportProgress(organizer, value, message)); return; } double percent = value * 100.0; if (String.IsNullOrEmpty(message)) { message = $"{Math.Round(percent, 1)}%"; } else { message = $"{Math.Round(percent, 1)}% - {message}"; } progress.SetProgress(value, message); }
public int Run(string[] args) { IEnumerable <Arg> parsedArgs = ParseArgs.Parse(args, new string[] { "-r" }, new string[] { "-s", "-d" }); #if DEBUG Console.WriteLine("Arguments parsed:"); foreach (Arg arg in parsedArgs) { Console.WriteLine($" * {arg}"); } #endif string source = null; string destination = null; bool recursive = false; bool query = false; foreach (Arg arg in parsedArgs) { switch (arg.Key) { case "-s": source = arg.Value; break; case "-d": destination = arg.Value; break; case "-r": recursive = true; break; case "-q": query = true; break; } } if (query) { MediaQuerier querier = new MediaQuerier(); QuerySummary summary = querier.Query(source, recursive, QueryType.All, MetaType.Image); ConsoleColor originalColor = Console.ForegroundColor; foreach (var match in summary.matches) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(match.Key); foreach (Tuple <string, QueryType> duplicate in match.Value) { Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write(" `-- {0} [", duplicate.Item1); Console.ForegroundColor = ConsoleColor.Red; Console.Write(duplicate.Item2); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("]{0}", Console.Out.NewLine); } } Console.ForegroundColor = originalColor; if (summary.matches.Count == 0) { Console.WriteLine("<none>"); } else { Console.WriteLine("DONE"); } return(summary.matches.Count); } MediaOrganizer organizer = new MediaOrganizer(); organizer.sourcePath = source; organizer.destinationPath = destination; organizer.Recursive = recursive; //organizer.DuplicateMode = DuplicateMode.KeepAll; organizer.CopyMode = CopyMode.KeepUnique; //organizer.DestinationPatternImage = patternImage.Text; //organizer.DestinationPatternVideo = patternVideo.Text; //organizer.DestinationPatternAudio = patternAudio.Text; organizer.Locale = Thread.CurrentThread.CurrentUICulture; if (String.IsNullOrEmpty(source)) { throw new ArgumentException("No source path given (-s)", nameof(source)); } if (String.IsNullOrEmpty(destination)) { throw new ArgumentException("No destination path given (-d)", nameof(destination)); } try { organizer.Organize(); Console.WriteLine("Media organization completed successfully"); return(0); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(1); } }