public static int Main(string[] args) { string settingsFile = Path.ChangeExtension(Environment.GetCommandLineArgs()[0], ".settings"); Settings settings; if (File.Exists(settingsFile)) { using (TextReader reader = File.OpenText(settingsFile)) settings = new Settings(reader); } else { settings = new Settings(); } Application.Init("GtkScratchPad", ref args); if (args.Length != 1) { Console.WriteLine("Expected argument: storage directory"); return(1); } ScratchRoot root = new ScratchRoot(args[0]); MainWindow window = new MainWindow(root, settings); window.ShowAll(); Application.Run(); return(0); }
static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine("usage: {0} <root-dir>", Path.GetFileNameWithoutExtension( Environment.GetCommandLineArgs()[0])); Console.WriteLine("Output date-stamped log of modifications in order with titles at time of modification"); return(1); } ScratchRoot root = new ScratchRoot(args[0]); var updates = new List <Update>(); foreach (ScratchBook book in root.Books) { foreach (ScratchPage page in book.Pages) { ScratchIterator iter = page.GetIterator(); iter.MoveToEnd(); do { updates.Add(new Update { Title = new StringReader(iter.Text).ReadLine(), Stamp = iter.Stamp }); } while (iter.MovePrevious()); } } Update previous = null; Update finish = null; int updateCount = 0; foreach (var update in updates.OrderByDescending(x => x.Stamp).Where(x => x.Title != null)) { if (previous == null) { previous = update; continue; } if (previous.Title == update.Title && (previous.Stamp - update.Stamp).TotalHours < 1) { // within the hour => probably the same task if (finish == null) { // this is the start of a range finish = previous; updateCount = 1; } else { ++updateCount; } } else { if (finish != null) { // we've come to the start of a range, and previous was the beginning TimeSpan duration = finish.Stamp - previous.Stamp; Console.WriteLine("{0} {1} ({2}) {3}", previous.Stamp, NiceDuration(duration), updateCount, previous.Title); } else { // different task that previous, and not part of range Console.WriteLine("{0} {1}", previous.Stamp, previous.Title); } updateCount = 0; finish = null; } previous = update; } if (finish != null) { // we've come to the start of a range, and previous was the beginning TimeSpan duration = finish.Stamp - previous.Stamp; Console.WriteLine("{0} {1} ({2}) {3}", previous.Stamp, NiceDuration(duration), updates, previous.Title); } else { // different task that previous, and not part of range Console.WriteLine("{0} {1}", previous.Stamp, previous.Title); } return(0); }
public MainWindow(ScratchRoot root, Settings appSettings) : base("GTK ScratchPad") { Root = root; AppSettings = appSettings; InitComponent(); }