public void GoToNextPara_LastParaInView() { CheckDisposed(); ShowForm(Lng.English, DummyBasicViewVc.DisplayType.kNormal | DummyBasicViewVc.DisplayType.kDuplicateParagraphs); m_basicView.Show(); m_basicView.RefreshDisplay(); m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 1, 1, 0, 2, 6, 0, true); IVwSelection vwsel = m_SelectionHelper.SetSelection(true); Assert.IsNotNull(vwsel, "No selection made"); Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible"); ((RootSiteEditingHelper)m_basicView.EditingHelper).GoToNextPara(); // We expect that the selection will be unchanged. SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView); Assert.IsTrue(selectionHelper.IsRange); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0, 2, 6, 0, true, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); CheckSelectionHelperValues(SelectionHelper.SelLimitType.End, selectionHelper, 0, 2, 0, 0, false, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void GoToNextPara_NextFlid() { CheckDisposed(); // Add a title to the book m_scrInMemoryCache.AddTitleToMockedBook(m_hvoRoot, "The First Book of the Law given by Moses"); ShowForm(Lng.English, DummyBasicViewVc.DisplayType.kNormal | DummyBasicViewVc.DisplayType.kBookTitle); m_basicView.Show(); m_basicView.RefreshDisplay(); // Set the IP at the beginning of the only (0th) instance of the only (0th) paragraph // of the only (0th) instance of the second (1th) footnote of the book we're displaying. m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 1, 0, 0, 2, 0, 0, true); IVwSelection vwsel = m_SelectionHelper.SetSelection(true); Assert.IsNotNull(vwsel, "No selection made"); Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible"); ((RootSiteEditingHelper)m_basicView.EditingHelper).GoToNextPara(); // We expect that the selection will be at the start of the book title. SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView); Assert.IsFalse(selectionHelper.IsRange); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0, 0, 0, 0, false, 2, (int)ScrBook.ScrBookTags.kflidTitle, 0, 0, (int)StText.StTextTags.kflidParagraphs, 0, 0); }
public void GoToNextPara_FirstFlidInNextObject() { CheckDisposed(); ShowForm(Lng.English, DummyBasicViewVc.DisplayType.kBookFootnoteDetailsSeparateParas); m_basicView.Show(); m_basicView.RefreshDisplay(); m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 0, 0, 0, 0, 0, 0, true); IVwSelection vwsel = m_SelectionHelper.SetSelection(true); Assert.IsNotNull(vwsel, "No selection made"); Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible"); ((RootSiteEditingHelper)m_basicView.EditingHelper).GoToNextPara(); // We expect that the selection will be at the start of the second footnote's marker. SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView); Assert.IsFalse(selectionHelper.IsRange); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0, 0, 0, 0, false, 1, -1, -1, -1, m_flidContainingTexts, 0, 1); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets the selection at the specified character position in the specified instance of /// the specified paragraph in the specified instance of the specified footnote. /// </summary> /// <param name="cPropPrevFootnoteVec">Count of previous instances the vector of /// footnotes is displayed in the view</param> /// <param name="iFootnote">Index of footnote</param> /// <param name="cPropPrevParaVec">Count of previous instances the vector of paragraphs is /// displayed in the view</param> /// <param name="iPara">Index of paragraph</param> /// <param name="ichAnchor">Start character</param> /// <param name="ichEnd">End character</param> /// <returns>The made selection</returns> /// ------------------------------------------------------------------------------------ protected IVwSelection MakeSelection(int cPropPrevFootnoteVec, int iFootnote, int cPropPrevParaVec, int iPara, int ichAnchor, int ichEnd) { m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(cPropPrevFootnoteVec, iFootnote, cPropPrevParaVec, iPara, 0, ichAnchor, ichEnd, true); // Now that all the preparation to set the IP is done, set it. IVwSelection vwsel = m_SelectionHelper.SetSelection(m_basicView, true, true); Application.DoEvents(); return vwsel; }
public void SetSelection_DifferingLevelInfos() { CheckDisposed(); ShowForm(Lng.English | Lng.French, DummyBasicViewVc.DisplayType.kAll); // test with Anchor == End, but different LevelInfos! m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 1, 1, 0, 0, 6, 6, true); SetSelection(0, 2, 1, 0, 0, 6, 6, false); IVwSelection vwsel = m_SelectionHelper.SetSelection(true); Assert.IsNotNull(vwsel, "No selection made"); Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible"); SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0, 0, 6, 0, false, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); CheckSelectionHelperValues(SelectionHelper.SelLimitType.End, selectionHelper, 0, 0, 6, 0, true, 2, m_flidContainingTexts, 0, 2, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void ExistingIPPos() { CheckDisposed(); // Set selection somewhere (A == E); should set to same position m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 1, 1, 0, 0, 2, 2, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(2, newSel.IchAnchor); Assert.AreEqual(2, newSel.IchEnd); }
public void MultiSection_AnchorAfterEndAtEOT() { CheckDisposed(); // A exists, E at absolute end of text ( E < A ) m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 1, 1, 0, 0, 1, 1, true); SetSelection(0, 1, 1, 0, 0, DummyBasicView.kSecondParaEng.Length, DummyBasicView.kSecondParaEng.Length, false); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, newSel, 0, 0, 1, 0, true, 2, m_flidContainingTexts, 1, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); CheckSelectionHelperValues(SelectionHelper.SelLimitType.End, newSel, 0, 0, DummyBasicView.kSecondParaEng.Length, 0, false, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void MultiSection_EndBeforeAnchor() { CheckDisposed(); // Both A and E exist (E < A); should select range m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 1, 1, 0, 0, 2, 2, true); SetSelection(0, 1, 1, 0, 0, 6, 6, false); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, newSel, 0, 0, 2, 0, true, 2, m_flidContainingTexts, 1, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); CheckSelectionHelperValues(SelectionHelper.SelLimitType.End, newSel, 0, 0, 6, 0, false, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void MultiSection_AnchorAfterNonExistingEnd() { CheckDisposed(); // A does exist, E doesn't ( E < A ); should set E to end of paragraph m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 1, 1, 0, 0, 1, 1, true); SetSelection(0, 1, 1, 0, 0, 77, 77, false); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, newSel, 0, 0, 1, 0, true, 2, m_flidContainingTexts, 1, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); CheckSelectionHelperValues(SelectionHelper.SelLimitType.End, newSel, 0, 0, DummyBasicView.kSecondParaEng.Length, 0, false, 2, m_flidContainingTexts, 0, 1, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void ExistingEndBeforeAnchor() { CheckDisposed(); // Set selection somewhere (E < A); should make selection m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 0, 1, 0, 0, 5, 4, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(5, newSel.IchAnchor); Assert.AreEqual(4, newSel.IchEnd); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_SelectionHelper = null; base.Dispose(disposing); }
public void EndpointAfterEndOfLine() { CheckDisposed(); // Set endpoint after end of line (A < E); should set to end of line m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 1, 1, 0, 0, 3, 99, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(3, newSel.IchAnchor); Assert.AreEqual(DummyBasicView.kSecondParaEng.Length, newSel.IchEnd); }
public void EmptyLine() { CheckDisposed(); // Set selection somewhere on an empty line (A == E); should set to position 0 m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(0, 2, 0, 0, 0, 5, 5, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(0, newSel.IchAnchor); Assert.AreEqual(0, newSel.IchEnd); }
public void AfterEndOfLine() { CheckDisposed(); // Set selection after end of line (A == E); should set to last character m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 1, 1, 0, 0, 99, 99, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); int nExpected = DummyBasicView.kSecondParaEng.Length; Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(nExpected, newSel.IchAnchor); Assert.AreEqual(nExpected, newSel.IchEnd); }
public void GoToNextPara_MultiParaRangeSelection() { CheckDisposed(); ShowForm(Lng.English, DummyBasicViewVc.DisplayType.kNormal | DummyBasicViewVc.DisplayType.kDuplicateParagraphs); m_basicView.Show(); m_basicView.RefreshDisplay(); m_SelectionHelper = new DummySelectionHelper(null, m_basicView); // Make a bottom-up selection, just to be sure we're not using the anchor instead of // the top. SetSelection(0, 0, 0, 0, 2, 1, 1, false); // Set end SetSelection(0, 1, 0, 0, 1, 12, 12, true); // Set anchor IVwSelection vwsel = m_SelectionHelper.SetSelection(true); Assert.IsNotNull(vwsel, "No selection made"); ((RootSiteEditingHelper)m_basicView.EditingHelper).GoToNextPara(); // We expect that the selection will be at the start of the second paragraph in // the selected range. SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView); Assert.IsFalse(selectionHelper.IsRange); CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0, 0, 0, 0, false, 2, m_flidContainingTexts, 0, 0, (int)StText.StTextTags.kflidParagraphs, 1, 0); }
public void MakeBest_AnchorAtEndOfLine() { CheckDisposed(); // Set anchor at end of line (E < A) m_SelectionHelper = new DummySelectionHelper(null, m_basicView); SetSelection(1, 1, 1, 0, 0, DummyBasicView.kSecondParaEng.Length, 2, true); IVwSelection vwsel = m_SelectionHelper.MakeBest(true); SelectionHelper newSel = SelectionHelper.Create(m_basicView); Assert.IsNotNull(vwsel, "No selection made"); Assert.AreEqual(DummyBasicView.kSecondParaEng.Length, newSel.IchAnchor); Assert.AreEqual(2, newSel.IchEnd); }
public void RestoreSelectionAndScrollPos_TopOfWindow() { CheckDisposed(); // Test preparations ShowForm(Lng.English | Lng.Empty, DummyBasicViewVc.DisplayType.kAll); MakeSelection(0, 0, 0, 0, 0, 0); DummySelectionHelper oriSelection = DummySelectionHelper.Create(m_basicView); int dyIpTopOri = oriSelection.IPTopY; // scroll somewhere else and then restore the previous selection m_basicView.ScrollToEnd(); bool fRet = oriSelection.RestoreSelectionAndScrollPos(); // Verify results DummySelectionHelper newSelection = new DummySelectionHelper(null, m_basicView); Assert.IsTrue(fRet); Assert.AreEqual(dyIpTopOri, newSelection.IPTopY); Assert.AreEqual(0, m_basicView.ScrollPosition.Y); }
public void RestoreSelectionAndScrollPos_BottomOfWindow() { CheckDisposed(); // Test preparations ShowForm(Lng.English | Lng.Empty, DummyBasicViewVc.DisplayType.kAll); m_basicView.CallOnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 10, m_basicView.ClientRectangle.Height, 0)); m_basicView.ScrollSelectionIntoView(null, VwScrollSelOpts.kssoNearTop); DummySelectionHelper oriSelection = DummySelectionHelper.Create(m_basicView); // remember position within window int dyIpTopOri = oriSelection.IPTopY; int yScrollOri = m_basicView.ScrollPosition.Y; // scroll somewhere else and then restore the previous selection m_basicView.ScrollToEnd(); bool fRet = oriSelection.RestoreSelectionAndScrollPos(); // Verify results DummySelectionHelper newSelection = new DummySelectionHelper(null, m_basicView); Assert.IsTrue(fRet); Assert.AreEqual(dyIpTopOri, newSelection.IPTopY); Assert.AreEqual(yScrollOri, m_basicView.ScrollPosition.Y); }