public void CopyImageMetadataToWholeBook(Metadata metadata) { using (var dlg = new ProgressDialogForeground()) //REVIEW: this foreground dialog has known problems in other contexts... it was used here because of its ability to handle exceptions well. TODO: make the background one handle exceptions well { dlg.ShowAndDoWork(progress => CurrentBook.CopyImageMetadataToWholeBookAndSave(metadata, progress)); } }
public void SplitBlock(IEnumerable <BlockSplitData> blockSplits, List <KeyValuePair <int, string> > characters) { // set the character for the first block Block currentBlock = CurrentBlock; var firstCharacterId = characters.First(c => c.Key == 0).Value; if (currentBlock.CharacterId != firstCharacterId) { currentBlock.CharacterId = firstCharacterId; currentBlock.Delivery = null; } foreach (var groupOfSplits in blockSplits.GroupBy(s => new { s.BlockToSplit })) { foreach (var blockSplitData in groupOfSplits.OrderByDescending(s => s, BlockSplitData.BlockSplitDataVerseAndOffsetComparer)) { // get the character selected for this split var characterId = characters.First(c => c.Key == blockSplitData.Id).Value; var newBlock = CurrentBook.SplitBlock(blockSplitData.BlockToSplit, blockSplitData.VerseToSplit, blockSplitData.CharacterOffsetToSplit, true, characterId, m_project.Versification); var newBlockIndices = GetBlockIndices(newBlock); var blocksIndicesNeedingUpdate = m_relevantBlocks.Where( r => r.BookIndex == newBlockIndices.BookIndex && r.BlockIndex >= newBlockIndices.BlockIndex); foreach (var block in blocksIndicesNeedingUpdate) { block.BlockIndex++; } AddToRelevantBlocksIfNeeded(newBlock); } } }
public IEnumerable <Layout> GetLayoutChoices() { foreach (var layout in CurrentBook.GetLayoutChoices()) { yield return(layout); } }
public Block SplitBlock(Block blockToSplit, string verseToSplit, int characterOffsetToSplit) { Block newBlock = CurrentBook.SplitBlock(blockToSplit, verseToSplit, characterOffsetToSplit); AddToRelevantBlocksIfNeeded(newBlock); return(newBlock); }
/* * Updates properties of a given Breakfast. */ public void UpdateBreakfast(BookingDecorator reference, String newDietRequirements) { CurrentBook = CurrentBook.Undecorate(reference); CurrentBook = bFact.AddBreakfast(CurrentBook, newDietRequirements); }
/* * Returns a list of references to each of the CurrentBooking's * decorators (= extras), or null if it is not decorated at all. */ public List <BookingDecorator> GetCurrentExtras() { List <BookingDecorator> references; CurrentBook.Unwrap(out references); return(references); }
/* * Updates properties of a given EveningMeal. */ public void UpdateEveningMeal(BookingDecorator reference, String newDietRequirements) { CurrentBook = CurrentBook.Undecorate(reference); CurrentBook = bFact.AddEveningMeal(CurrentBook, newDietRequirements); }
/* * Updates the BookingComponent instance currently loaded in the * system. */ public void UpdateBooking(DateTime arrival, DateTime departure) { List <PersonComponent> savedGuests = CurrentBook.GetGuests(); List <BookingDecorator> decorationStack; BookingComponent booking = CurrentBook.Unwrap(out decorationStack); booking = bFact.UpdateBooking(booking.GetBookingNb(), CurrentCust, arrival, departure); if (decorationStack != null) { foreach (BookingDecorator reference in decorationStack) { reference.Setcomponent(booking); booking = reference; } } CurrentBook = booking; foreach (PersonComponent g in savedGuests) { CurrentBook.AddGuest(g); } }
/* * Deletes the guest at given index in list of guests for the * current booking. * Undecorates that guest if if it is also a * customer and updates CurrentCustomer with the correct * memory reference. */ public void DeleteGuest(int index) { // First unwrap guest decorator from current customer if they are // the guest being deleted: if (CurrentBook.GetGuests().ElementAt(index).IsCustomer()) { List <PersonComponent> savedGuests = CurrentBook.GetGuests(); DateTime arrival; DateTime departure; CurrentBook.GetDates(out arrival, out departure); CurrentCust = CurrentCust.UndecorateOnce(); CurrentBook = bFact.UpdateBooking(CurrentBook.GetBookingNb(), CurrentCust, arrival, departure); foreach (PersonComponent g in savedGuests) { CurrentBook.GetGuests().Add(g); } } // Then delete selected guest reference from guests list: CurrentBook.GetGuests().RemoveAt(index); }
private void LoadNextVerse() { if (!HasStarted) { return; } StopTimer(); FinishedVerse(CurrentVerse); if (CurrentVerse.Field <int>("SequenceInBook") == CurrentBook.AsEnumerable().Max(p => p.Field <int>("SequenceInBook"))) { if ((BookEnum)CurrentVerse.Field <int>("BookId") == BookEnum.Revelation) { // Finalizou a leitura. Terminamos. Stop(false); return; } // Terminou a leitura do livro atual. Vamos para o próximo livro. LoadNextBook(); return; } // Próximo versículo do livro atual. CurrentVerse = GetNextVerse(CurrentVerse); UpdateVerse(); }
/// <summary> /// user has selected or de-selected a content language /// </summary> public void ContentLanguagesSelectionChanged() { Logger.WriteEvent("Changing Content Languages"); string l2 = null; string l3 = null; foreach (var language in _contentLanguages) { if (language.Locked) { continue; //that's the vernacular } if (language.Selected && l2 == null) { l2 = language.Iso639Code; } else if (language.Selected) { l3 = language.Iso639Code; break; } } //Reload to display these changes SaveNow(); CurrentBook.SetMultilingualContentLanguages(l2, l3); CurrentBook.PrepareForEditing(); _view.UpdateSingleDisplayedPage(_pageSelection.CurrentSelection); _view.UpdatePageList(true); //counting on this to redo the thumbnails Logger.WriteEvent("ChangingContentLanguages"); Analytics.Track("Change Content Languages"); }
public void ViewVisibleNowDoSlowStuff() { if (_currentlyDisplayedBook != CurrentBook) { CurrentBook.PrepareForEditing(); } _currentlyDisplayedBook = CurrentBook; var errors = _bookSelection.CurrentSelection.GetErrorsIfNotCheckedBefore(); if (!string.IsNullOrEmpty(errors)) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(errors); return; } var page = _bookSelection.CurrentSelection.FirstPage; if (page != null) { _pageSelection.SelectPage(page); } if (_view != null) { if (ShowTemplatePanel) { _view.UpdateTemplateList(); } _view.UpdatePageList(false); } }
private DataRow GetNextBibleVerse(DataRow verse) { return (CurrentBook.AsEnumerable() .FirstOrDefault( x => x.Field <int>("SequenceInBook") == verse.Field <int>("SequenceInBook") + 1)); }
public override void PrintBook() { Console.WriteLine("Publisher: {0}", Publisher); foreach (BookCollection CurrentBook in _BookCollection) { CurrentBook.PrintBook(); } }
public void SetLayout(Layout layout) { SaveNow(); CurrentBook.SetLayout(layout); CurrentBook.PrepareForEditing(); _view.UpdateSingleDisplayedPage(_pageSelection.CurrentSelection); _view.UpdatePageList(true); //counting on this to redo the thumbnails }
/* * Updates given customer's details with new values for all bookings * of his. */ public void UpdateCurrentCustomer(String newName, String newAddress) { BookingComponent processedBooking; List <PersonComponent> savedGuests; List <BookingDecorator> decorationStack; List <Dictionary <String, String> > bookingData; DateTime arrival; DateTime departure; // update values within all persisted bookings made by current // customer foreach (int bookingNb in dpFacade.GetAllBookingNbs(CurrentCust.GetCustNb())) { dpFacade.Read(bookingNb, out bookingData); processedBooking = bFact.Restore(bookingData) .Unwrap(out decorationStack); savedGuests = processedBooking.GetGuests(); processedBooking.GetDates(out arrival, out departure); processedBooking = bFact.UpdateBooking( processedBooking.GetBookingNb(), pFact.UpdateCustomer( processedBooking.GetCustomer(), newName, newAddress), arrival, departure); if (decorationStack != null) { foreach (BookingDecorator reference in decorationStack) { reference.Setcomponent(processedBooking); processedBooking = reference; } } foreach (PersonComponent g in savedGuests) { processedBooking.AddGuest(g); } CurrentCust = processedBooking.GetCustomer(); dpFacade.Persist(processedBooking); } // reload current booking into the system to upload changes if (IsABookingLoaded()) { RestoreBooking(CurrentBook.GetBookingNb()); } }
/* * Removes the selected extra from the booking. */ public void RemoveExtra(int index) { List <BookingDecorator> references = GetCurrentExtras(); if (references != null) { CurrentBook = CurrentBook.Undecorate( references.ElementAt(index)); } }
/* * Returns a list of the names of all the guests currently booked for * the current booking. */ public List <String> GetGuestNames() { List <String> guestNames = new List <String>(); foreach (PersonComponent g in CurrentBook.GetGuests()) { guestNames.Add(g.Name); } return(guestNames); }
/* * Returns the number of guests currently booked for the current * booking(also 0 if no booking is currently loaded). */ public int GetCurrentNbGuests() { int nbGuests = 0; if (CurrentBook != null) { nbGuests = CurrentBook.GetNbGuests(); } return(nbGuests); }
/* * Returns the current booking's booking number, or -1 if no booking * is currently loaded. */ public int GetCurrentBookNb() { int currentBookingNb = -1; if (CurrentBook != null) { currentBookingNb = CurrentBook.GetBookingNb(); } return(currentBookingNb); }
/* * Updates properties of a given CarHire. */ public void UpdateCarHire(BookingDecorator reference, String newDriverName, DateTime newStart, DateTime newEnd) { CurrentBook = CurrentBook.Undecorate(reference); CurrentBook = bFact.AddCarHire(CurrentBook, newDriverName, newStart, newEnd); }
/* * Returns the current booking's cost per night, or -1 if no booking * is currently loaded. */ public float GetCurrentCostPerNight() { float costPerNight = -1; if (CurrentBook != null) { List <BookingDecorator> extras = GetCurrentExtras(); costPerNight = CurrentBook.Unwrap(out extras).GetCostPerNight(); } return(costPerNight); }
/* * Returns the current booking's number of nights, or -1 if no * booking is currently loaded. */ public int GetCurrentNbNights() { int nbNights = -1; if (CurrentBook != null) { List <BookingDecorator> extras; nbNights = CurrentBook.Unwrap(out extras).GetNbNights(); } return(nbNights); }
/* * True if the element at given index in list of guests is a * cutomer. */ public bool IsGuestACustomer(int index) { if (index >= 0) { return(CurrentBook.GetGuests().ElementAt(index).IsCustomer()); } else { return(false); } }
/* * Updates details of guest at given index in current booking's * list of guests. */ public void EditGuest(int index, String name, String passportNb, int age) { CurrentBook.GetGuests().RemoveAt(index); CurrentBook.GetGuests().Insert(index, pFact.GetNewGuest(name, passportNb, age)); }
/* * Updates guest details of current customer at given index in current * booking's list of guests. */ public void EditCustomerGuestDetails(int index, String passportNb, int age) { CurrentBook.GetGuests().RemoveAt(index); CurrentBook.GetGuests().Insert(index, pFact.GetNewGuest( CurrentCust.UndecorateOnce(), passportNb, age)); }
private int GetIndexOfPreviousRelevantBlockNotInCurrentMatchup() { for (int i = m_currentBlockIndex - 1; i >= 0; i--) { if (m_relevantBlocks[i].BookIndex != m_relevantBlocks[m_currentBlockIndex].BookIndex || !m_currentRefBlockMatchups.OriginalBlocks.Contains(CurrentBook.GetScriptBlocks(false)[m_relevantBlocks[i].BlockIndex])) { return(i); } } return(-1); }
private void LoadNextBook() { if ((BookEnum)CurrentBook.AsEnumerable().First().Field <int>("BookId") == BookEnum.Revelation) { LoadBook(BookEnum.Genesis); return; } LoadBook((BookEnum)CurrentBook.AsEnumerable().First().Field <int>("BookId") + 1); SetCurrentVerseAsFirstOne(); UpdateVerse(); }
private int GetIndexOfNextRelevantBlockNotInCurrentMatchup() { for (int i = m_currentBlockIndex + 1; i < RelevantBlockCount; i++) { if (m_relevantBlocks[i].BookIndex != m_relevantBlocks[m_currentBlockIndex].BookIndex || !m_currentRefBlockMatchups.OriginalBlocks.Contains( CurrentBook.GetScriptBlocks(false)[m_relevantBlocks[i].BlockIndex])) { return(i); } } return(-1); }
private DataRow GetPreviousVerse(DataRow verse) { if ((BookEnum)verse.Field <int>("BookId") == BookEnum.Genesis && verse.Field <int>("SequenceInBook") == 1) { throw new InvalidOperationException(); } return (CurrentBook.AsEnumerable() .First( x => x.Field <int>("SequenceInBook") == verse.Field <int>("SequenceInBook") - 1)); }