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 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);
 }
        public override void ApplyCurrentReferenceTextMatchup()
        {
            int numberOfBlocksCompleted = 0;

            if (DoingAssignmentTask)
            {
                numberOfBlocksCompleted = CurrentReferenceTextMatchup.OriginalBlocks.Count(b => !b.UserConfirmed && b.CharacterIsUnclear);
            }
            else if (DoingAlignmentTask)
            {
                numberOfBlocksCompleted = 1;
            }
            base.ApplyCurrentReferenceTextMatchup();

            //PG-1106: If the last block in the current matchup is part of a quote that might be continued in following blocks (outside
            // the current matchup), we'll need to check the following block(s) and add records to ProjectCharacterVerse for as many
            // following verses as needed.

            // PG-805: The block matchup UI does not prevent pairing a delivery with a character to which it does not correspond and
            // also allows addition of new character/delivery pairs, so we need to check to see whether this has happened and, if
            // so, add an appropriate entry to the project CV data.
            int iLastBlockInMatchup = CurrentReferenceTextMatchup.IndexOfStartBlockInBook + CurrentReferenceTextMatchup.OriginalBlockCount;
            var blocks = CurrentBook.GetScriptBlocks();

            for (int i = CurrentReferenceTextMatchup.IndexOfStartBlockInBook; i < iLastBlockInMatchup || (i < blocks.Count && blocks[i].IsContinuationOfPreviousBlockQuote); i++)
            {
                var block = blocks[i];
                if (block.IsScripture)
                {
                    AddRecordsToProjectControlFilesIfNeeded(block);
                }
            }

            m_pendingCharacterDeliveryAdditions.Clear();

            m_project.SaveBook(CurrentBook);
            OnSaveCurrentBook();
            if (numberOfBlocksCompleted > 0)
            {
                CompletedBlockCount += numberOfBlocksCompleted;
                OnAssignedBlocksIncremented(numberOfBlocksCompleted);
            }
        }