private static IEnumerable <string> PartialTestamentBookSummary(BookSet bookSet, BookSet setToCompare) { if (bookSet.Count == 0) { return(Enumerable.Empty <string>()); } var result = new List <string>(); string start = null; string previous = null; foreach (int bookNum in setToCompare.SelectedBookNumbers) { if (bookSet.IsSelected(bookNum)) { string bookCode = BCVRef.NumberToBookCode(bookNum); if (start == null) { start = bookCode; } previous = bookCode; } else { if (start != null) { if (start == previous) { result.Add(start); } else { result.Add(start + "-" + previous); } start = null; previous = null; } } } if (previous != null) { if (start == previous) { result.Add(start); } else { result.Add(start + "-" + previous); } } return(result); }
public VerseControl() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); if (Platform.IsLinux) { // Set a smaller font on Linux. (Stops 'J''s being clipped) uiBook.Font = new Font("Microsoft Sans Serif", 8F, FontStyle.Regular, GraphicsUnit.Point, 0); // Also increase the ItemHeight as to stop clipping of items in the drop down menu.. uiBook.ItemHeight += 2; } // Create reference and set to English versification curRef = new VerseRef(ScrVers.English); // Add books... allBooks = new BookListItem[Canon.LastBook]; InitializeBooks(); //...to internal data structure PopulateBooks(); //...and to combobox list uiBook.GotFocus += control_GotFocus; uiChapter.GotFocus += control_GotFocus; uiVerse.GotFocus += control_GotFocus; // Cause Drop down list to be initally populated. // (stop intial click on Combo box drop down beinging ignored on mono) // TODO: fix mono bug where dropdown isn't shown if list is empty even // if dropdown event handlers populate list. if (Platform.IsMono) { uiBook.BeforeMouseDown += (sender, e) => { if (uiBook.Items.Count == 0) { PopulateBooks(); } } } ; } #endregion #region Helpers and Initializers void InitializeBooks() { int i = 0; StringBuilder abbrevs = new StringBuilder(); foreach (string abbrev in Canon.AllBookIds) { abbrevs.Append(abbrev); abbrevs.Append(","); BookListItem item = new BookListItem(abbrev); item.isPresent = booksPresentSet.IsSelected(i + Canon.FirstBook); allBooks[i] = item; i++; } abbreviations = abbrevs.ToString(); RelocalizeBooks(); }