private void _text_TextChanged(object sender, EventArgs e) { UpdateTitle(); if (_settingText) { return; } if (!_dirty) { _lastSave = DateTime.UtcNow; } _lastModification = DateTime.UtcNow; if (_textView.Buffer.Text == "") { EnsureSaved(); } _textContents = _textView.Buffer.Text; if (_textContents == "") { _currentPage = Book.Pages.Count; Book.AddPage(); UpdateViewLabels(); } _currentIterator = null; _dirty = true; }
void NextPage() { _currentIterator = null; EnsureSaved(); if (_currentPage < Book.Pages.Count && Book.Pages[_currentPage].Text != "") { ++_currentPage; UpdateTextBox(); UpdateViewLabels(); } }
void PreviousPage() { _currentIterator = null; if (_currentPage > 0) { EnsureSaved(); --_currentPage; UpdateTextBox(); UpdateViewLabels(); } }
public void JumpToPage(int pageIndex) { if (pageIndex < 0 || pageIndex >= Book.Pages.Count) { return; } EnsureSaved(); _currentIterator = null; _currentPage = pageIndex; UpdateTextBox(); UpdateTitle(); UpdateViewLabels(); }
void PreviousVersion() { EnsureSaved(); if (_currentPage >= Book.Pages.Count) { return; } if (_currentIterator == null) { _currentIterator = Book.Pages[_currentPage].GetIterator(); _currentIterator.MoveToEnd(); } if (_currentIterator.MovePrevious()) { UpdateTextBox(); UpdateViewLabels(); } }
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); }