public void ScrollPage() { CheckDisposed(); m_draftForm.Focus(); // Make sure we're somewhere in the view where paging down will actually move the // IP somewhere other than where it is before paging down. In other words, the // first test below will fail if the view is opened and the IP restored to at or // near the bottom of the view, in which case paging down will do nothing. Hence // this call to move the IP to the top... ramble, ramble, ramble. m_draftForm.ScrollToTop(); int ydCurr = m_draftForm.YPosition; // scroll one page down DummyDraftView draftView = m_draftForm.DraftView; draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.PageDown)); int ydCurr2 = m_draftForm.YPosition; Assert.IsFalse(ydCurr2 == ydCurr, "Position after Page down should be different from before"); Assert.IsTrue(m_draftForm.IsSelectionVisible(), "IP should be visible"); m_draftForm.ScrollToEnd(); ydCurr = m_draftForm.YPosition; // scroll one page up draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.PageUp)); ydCurr2 = m_draftForm.YPosition; Assert.IsFalse(ydCurr2 == ydCurr, "Position after Page up should be different from before"); Assert.IsTrue(m_draftForm.IsSelectionVisible(), "IP should be visible"); }
public void HardLineBreak() { CheckDisposed(); // Set IP in the middle of the second Scripture section head in James. // Then press Shift-Enter. This should put a hard line break in the middle of this // section head and the IP should be at the beginning of the second line. DummyDraftView draftView = m_draftForm.DraftView; draftView.RootBox.Activate(VwSelectionState.vssEnabled); draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); KeyEventArgs e = new KeyEventArgs(Keys.Right); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); // We should be between the 'a' and 'n' of the word "and" in the section head // containing "Faith and Wisdom". SelectionHelper selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); int ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(7, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have split the line between the 'a' and 'n' of the word "and". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(8, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. Scripture scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); ScrBook james = (ScrBook)scr.ScriptureBooksOS[1]; ScrSection modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[7]); // Second test: // Set IP at the beginning of the second Scripture section head in James. // Then press Shift-Enter. This should put an empty line at the beginning of this // section head and the IP should be at the beginning of the second line. draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have an blank line before Faith and Wisdom. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(2, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head containing "Faith and Wisdom". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); james = (ScrBook)scr.ScriptureBooksOS[1]; modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[0]); }