Exemple #1
0
        public void Initialize(BlockNavigatorViewModel viewModel, Func <string, string> getCharacterIdForUi = null, Func <Block, string> getDelivery = null)
        {
            m_viewModel           = viewModel;
            m_getCharacterIdForUi = getCharacterIdForUi;
            m_getDelivery         = getDelivery;
            m_dataGridViewBlocks.Initialize(m_viewModel);

            m_viewModel.BackwardContextBlockCount = kContextBlocksBackward;
            m_viewModel.ForwardContextBlockCount  = kContextBlocksForward;

            if (m_getCharacterIdForUi == null)
            {
                m_dataGridViewBlocks.Columns.Remove(colCharacter);
            }

            if (m_getDelivery == null)
            {
                m_dataGridViewBlocks.Columns.Remove(colDelivery);
            }

            m_dataGridViewBlocks.Dock = DockStyle.Fill;

            Disposed += ScriptBlocksViewer_Disposed;

            m_viewModel.CurrentBlockChanged       += UpdateContextBlocksDisplay;
            m_blocksDisplayBrowser.VisibleChanged += UpdateContextBlocksDisplay;
            m_dataGridViewBlocks.VisibleChanged   += UpdateContextBlocksDisplay;
        }
        public void GetIndexOfClosestRelevantBlock_NoPreviousBlockIsRelevant_ReturnsNegative1()
        {
            var relevantBlocks = new List <BookBlockIndices>();

            relevantBlocks.Add(new BookBlockIndices(2, 14));
            relevantBlocks.Add(new BookBlockIndices(3, 2));
            Assert.AreEqual(-1, BlockNavigatorViewModel.GetIndexOfClosestRelevantBlock(
                                relevantBlocks, new BookBlockIndices(1, 3), true, 0, relevantBlocks.Count - 1));
        }
Exemple #3
0
        public void CleanUpMultiBlockQuotes(ScrVers versification)
        {
            var model = new BlockNavigatorViewModel(new[] { this }.ToReadOnlyList(), versification);

            foreach (IEnumerable <Block> multiBlock in GetScriptBlocks()
                     .Where(b => b.MultiBlockQuote == MultiBlockQuote.Start)
                     .Select(block => model.GetAllBlocksWhichContinueTheQuoteStartedByBlock(block)))
            {
                ProcessAssignmentForMultiBlockQuote(BCVRef.BookToNumber(BookId), multiBlock.ToList(), versification);
            }
        }
        public void Initialize(BlockNavigatorViewModel viewModel)
        {
            m_colReference = (DataGridViewTextBoxColumn)Columns[0];
            m_colText      = (DataGridViewTextBoxColumn)Columns.GetLastColumn(DataGridViewElementStates.Visible, DataGridViewElementStates.None);
            Debug.Assert(m_colReference != null);
            Debug.Assert(m_colText != null);
            m_viewModel = viewModel;

            m_originalDefaultFont = DefaultCellStyle.Font;
            SetFontsFromViewModel();

            m_viewModel.UiFontSizeChanged += (sender, args) => SetFontsFromViewModel();
        }
Exemple #5
0
        public void CleanUpMultiBlockQuotes(ScrVers versification)
        {
            var model = new BlockNavigatorViewModel(new ReadOnlyList <BookScript>(new[] { this }), versification);

            foreach (var blockToChange in GetScriptBlocks()
                     .Where(b => b.MultiBlockQuote == MultiBlockQuote.Start)
                     .Select(block => model.GetAllBlocksWithSameQuote(block))
                     .Where(blocks => blocks.Select(b => b.CharacterId).Distinct().Count() > 1)
                     .SelectMany(blocks => blocks))
            {
                blockToChange.CharacterId   = CharacterVerseData.AmbiguousCharacter;
                blockToChange.UserConfirmed = false;
            }
        }
        public void GetIndexOfClosestRelevantBlock_FollowingBlockIsRelevant_ReturnsClosestFollowingRelevantBlock()
        {
            var relevantBlocks = new List <BookBlockIndices>();

            relevantBlocks.Add(new BookBlockIndices(1, 2));
            relevantBlocks.Add(new BookBlockIndices(1, 20));
            relevantBlocks.Add(new BookBlockIndices(2, 1));
            relevantBlocks.Add(new BookBlockIndices(2, 7));
            relevantBlocks.Add(new BookBlockIndices(2, 8));
            relevantBlocks.Add(new BookBlockIndices(2, 14));
            relevantBlocks.Add(new BookBlockIndices(3, 2));
            Assert.AreEqual(2, BlockNavigatorViewModel.GetIndexOfClosestRelevantBlock(
                                relevantBlocks, new BookBlockIndices(1, 21), false, 0, relevantBlocks.Count - 1));
        }
        public void GetIndexOfClosestRelevantBlock_PreviousBlockIsRelevant_ReturnsClosestPreviousRelevantBlock()
        {
            var relevantBlocks = new List <BookBlockIndices>();

            relevantBlocks.Add(new BookBlockIndices(1, 2));
            relevantBlocks.Add(new BookBlockIndices(1, 20));
            relevantBlocks.Add(new BookBlockIndices(2, 1));
            relevantBlocks.Add(new BookBlockIndices(2, 7));
            relevantBlocks.Add(new BookBlockIndices(2, 8));
            relevantBlocks.Add(new BookBlockIndices(2, 14));
            relevantBlocks.Add(new BookBlockIndices(3, 2));
            Assert.AreEqual(4, BlockNavigatorViewModel.GetIndexOfClosestRelevantBlock(
                                relevantBlocks, new BookBlockIndices(2, 10), true, 0, relevantBlocks.Count - 1));
        }
Exemple #8
0
        public void Initialize(BlockNavigatorViewModel viewModel)
        {
            m_colReference = (DataGridViewTextBoxColumn)Columns[0];
            m_colText      = (DataGridViewTextBoxColumn)Columns.GetLastColumn(DataGridViewElementStates.Visible, DataGridViewElementStates.None);
            Debug.Assert(m_colReference != null);
            Debug.Assert(m_colText != null);
            m_viewModel = viewModel;

            m_originalDefaultFont = new FontProxy(DefaultCellStyle.Font);
            SetFontsFromViewModel();

            m_minimumWidthFromDesigner = MinimumSize.Width;
            SizeRefColumnForCurrentBook();

            m_viewModel.CurrentBlockChanged += CurrentBlockChanged;
            m_viewModel.UiFontSizeChanged   += HandleUiFontSizeChanged;
        }
 public void SetUp()
 {
     m_model = new BlockNavigatorViewModel(m_testProject, BlocksToDisplay.NeedAssignments);
     m_model.BackwardContextBlockCount = 10;
     m_model.ForwardContextBlockCount  = 10;
 }
 public void GetIndexOfClosestRelevantBlock_MinGreaterThanMax_ReturnsNegative1()
 {
     Assert.AreEqual(-1, BlockNavigatorViewModel.GetIndexOfClosestRelevantBlock(
                         new List <BookBlockIndices>(), new BookBlockIndices(1, 2), true, 1, 0));
 }