protected override void OnCellValueNeeded(DataGridViewCellValueEventArgs e)
 {
     if (m_updatingContext && (e.RowIndex < 0 || e.RowIndex >= m_viewModel.BlockCountForCurrentBook))
     {
         // This should never happen, but because of the side-effects of various DGV properites and methods,
         // it seems to be incredibly difficult to ensure that things are done in an order that won't on
         // occassion cause it to request the value for a cell which no longer exists.
         e.Value = string.Empty;
     }
     else
     {
         var block = m_viewModel.GetNthBlockInCurrentBook(e.RowIndex);
         if (e.ColumnIndex == m_colReference.Index)
         {
             e.Value = m_viewModel.GetBlockReferenceString(block);
         }
         else if (e.ColumnIndex == m_colText.Index)
         {
             e.Value = block.GetText(true);
         }
         else
         {
             base.OnCellValueNeeded(e);
         }
     }
 }
        private void HandleDataGridViewBlocksCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            var block = m_viewModel.GetNthBlockInCurrentBook(e.RowIndex);

            if (e.ColumnIndex == colCharacter.Index)
            {
                Debug.Assert(m_getCharacterIdForUi != null);
                e.Value = m_getCharacterIdForUi(block.CharacterId);
            }
            else if (e.ColumnIndex == colDelivery.Index)
            {
                Debug.Assert(m_getDelivery != null);
                e.Value = m_getDelivery(block);
            }
        }
Beispiel #3
0
 protected override void OnCellValueNeeded(DataGridViewCellValueEventArgs e)
 {
     if (e.RowIndex < 0 || e.RowIndex >= m_viewModel.BlockCountForCurrentBook)
     {
         // This should never happen, but because of the side-effects of various DGV properites and methods,
         // it seems to be incredibly difficult to ensure that things are done in an order that won't on
         // occassion cause it to request the value for a cell which no longer exists.
         e.Value = string.Empty;
     }
     else
     {
         var block = m_viewModel.GetNthBlockInCurrentBook(e.RowIndex);
         if (e.ColumnIndex == m_colReference.Index)
         {
             e.Value = m_viewModel.GetBlockReferenceString(block);
         }
         else if (e.ColumnIndex == m_colText.Index)
         {
             e.Value = block.GetText(true);
         }
         else
         {
             if (m_viewModel.CurrentReferenceTextMatchup != null)
             {
                 var correspondingOrigBlock = m_viewModel.CurrentReferenceTextMatchup.GetCorrespondingOriginalBlock(block);
                 if (correspondingOrigBlock != null)
                 {
                     if (Columns[e.ColumnIndex].Name == "colCharacter")
                     {
                         e.Value = correspondingOrigBlock.CharacterIsUnclear() ? "" : correspondingOrigBlock.CharacterId;
                     }
                     else
                     {
                         e.Value = correspondingOrigBlock.Delivery;
                     }
                     return;
                 }
             }
             base.OnCellValueNeeded(e);
         }
     }
 }