public void SetCurrentBlockIndexInBook_BlockIsQuoteContinuationBlockForRelevantQuote_StateReflectsQuoteStartBlock()
        {
            var blocks = m_testProject.IncludedBooks[0].GetScriptBlocks();
            int i      = 1;

            for (; i < blocks.Count; i++)
            {
                if (blocks[i].MultiBlockQuote == MultiBlockQuote.Continuation)
                {
                    var quoteStart = i - 1;
                    if (blocks[quoteStart].CharacterIsUnclear())
                    {
                        break;
                    }
                    do
                    {
                        i++;
                    } while (blocks[i].MultiBlockQuote == MultiBlockQuote.Continuation);
                }
            }
            m_model.CurrentBlockIndexInBook = i;
            Assert.AreEqual(MultiBlockQuote.Start, m_model.CurrentBlock.MultiBlockQuote);
            Assert.IsTrue(m_model.GetIndicesOfQuoteContinuationBlocks(m_model.CurrentBlock).Any());
            Assert.IsTrue(m_model.IsCurrentBlockRelevant);
            Assert.IsTrue(m_model.CurrentBlockDisplayIndex > 0);
        }
Ejemplo n.º 2
0
        public void UpdateContext()
        {
            m_updatingContext = true;
            SuspendLayout();
            ClearSelection();
            bool changingRowCount = RowCount != m_viewModel.BlockCountForCurrentBook;
            bool multiSelect      = m_viewModel.CurrentBlock.MultiBlockQuote != MultiBlockQuote.None;

            if (changingRowCount || MultiSelect != multiSelect)
            {
                MultiSelect = multiSelect;
                if (changingRowCount)
                {
                    m_colReference.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                    AutoSizeRowsMode            = DataGridViewAutoSizeRowsMode.None;
                    RowCount = m_viewModel.BlockCountForCurrentBook;
                }
                // Need to clear the selection here again because some of the property setters on
                // DataGridView have the side-effect of creating a selection. We want to avoid having
                // HandleDataGridViewBlocksCellValueNeeded get called with an index that is out of
                // range for the new book.
                ClearSelection();
            }
            var firstRow = m_viewModel.CurrentBlockIndexInBook;
            var lastRow  = firstRow;

            Rows[firstRow].Selected = true;
            if (m_viewModel.CurrentBlock.MultiBlockQuote == MultiBlockQuote.Start)
            {
                foreach (var i in m_viewModel.GetIndicesOfQuoteContinuationBlocks(m_viewModel.CurrentBlock))
                {
                    Rows[i].Selected = true;
                    lastRow          = i;
                }
            }
            if (changingRowCount)
            {
                m_colReference.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                AutoSizeRowsMode            = DataGridViewAutoSizeRowsMode.DisplayedCells;
            }
            ScrollDesiredRowsIntoView(firstRow, lastRow);

            ResumeLayout();
            m_updatingContext = false;
        }