Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called when cell value needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnCellValueNeeded(DataGridViewCellValueEventArgs e)
        {
            KeyTermRef keyTermRef = m_list[e.RowIndex] as KeyTermRef;

            if (keyTermRef == null)
            {
                e.Value = null;
                return;
            }

            switch (e.ColumnIndex)
            {
            case KeyTermRenderingsControl.kRefCol:
                e.Value = keyTermRef.Reference;
                break;

            case KeyTermRenderingsControl.kRenderingCol:
                e.Value = keyTermRef.Rendering;
                break;

            case KeyTermRenderingsControl.kStatusCol:
                e.Value = keyTermRef.RenderingStatus;
                break;

            case KeyTermRenderingsControl.kCommentCol:
                e.Value = keyTermRef.KeyWordString;
                break;
            }
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called when cell value needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnCellValueNeeded(DataGridViewCellValueEventArgs e)
        {
            Debug.Assert(m_list != null, "Why did OnCellValueNeeded get called without first setting KeyTermRefs?");

            KeyTermRef keyTermRef = (m_list == null) ? null : m_list[e.RowIndex] as KeyTermRef;

            if (keyTermRef == null)
            {
                e.Value = null;
                return;
            }

            switch (e.ColumnIndex)
            {
            case KeyTermRenderingsControl.kRefCol:
                e.Value = keyTermRef.Reference;
                break;

            case KeyTermRenderingsControl.kRenderingCol:
                e.Value = keyTermRef.Rendering;
                break;

            case KeyTermRenderingsControl.kStatusCol:
                e.Value = keyTermRef.RenderingStatus;
                break;

            case KeyTermRenderingsControl.kCommentCol:
                e.Value = keyTermRef.KeyWordString;
                break;
            }
        }
Пример #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor for the event args
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ScrRefEventArgs(KeyTermRef keyTermRef)
		{
			if (keyTermRef != null && keyTermRef != KeyTermRef.Empty)
			{
				KeyTermRef = keyTermRef;
				RefBCV = keyTermRef.ChkRef.Ref;
			}
		}
Пример #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor for the event args
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ScrRefEventArgs(KeyTermRef keyTermRef)
 {
     if (keyTermRef != null && keyTermRef != KeyTermRef.Empty)
     {
         KeyTermRef = keyTermRef;
         RefBCV     = keyTermRef.Ref;
     }
 }
Пример #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the enabled states of the buttons on the key terms tool strip.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void UpdateToolStripButtons(KeyTermRef keyTermRef)
        {
            Debug.Assert(m_wrapper != null,
                         "The key terms wrapper must be specified in KeyTermsToolStrip");

            m_tbbUseAsVern.Enabled       = m_wrapper.EnableUseAsRendering(keyTermRef);
            m_tbbVernNotAssigned.Enabled = m_wrapper.EnableIgnoreUnrendered(keyTermRef);
            m_tbbNotRendered.Enabled     = m_wrapper.EnableRenderingNotAssigned(keyTermRef);
            m_tbbApplyFilter.Checked     = m_wrapper.ApplyBookFilter;
        }
Пример #6
0
        public void IsRangeInKtRef_OutOfRange_NoVerseBridge()
        {
            ScrReference[] refRange = new ScrReference[2];
            refRange[0] = refRange[1] = new ScrReference(01001001, Paratext.ScrVers.English);
            int        hvoKtRef = m_inMemoryCache.NewHvo(ChkRef.kClassId);
            KeyTermRef ktRef    = new KeyTermRef(Cache, hvoKtRef);

            ktRef.Ref = 01001002;
            Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(ktRef, refRange, refRange));
        }
Пример #7
0
        public void IsRangeInKtRef_OutOfRange_ConvertedVersification()
        {
            // Jonah 2:1 in Original != Jonah 2:1 in English
            ScrReference[] refRange = new ScrReference[2];
            refRange[0] = refRange[1] = new ScrReference(32002001, Paratext.ScrVers.English);
            int        hvoKtRef      = m_inMemoryCache.NewHvo(ChkRef.kClassId);
            KeyTermRef ktRefJonah2_1 = new KeyTermRef(Cache, hvoKtRef);

            ktRefJonah2_1.Ref = 32002001;
            Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(ktRefJonah2_1, refRange, refRange));
        }
Пример #8
0
        public void IsRangeInKtRef_InAnchorButNotInEnd()
        {
            ScrReference[] anchorRefRange = new ScrReference[2];
            anchorRefRange[0] = anchorRefRange[1] = new ScrReference(01001001, Paratext.ScrVers.English);
            ScrReference[] endRefRange = new ScrReference[2];
            endRefRange[0] = endRefRange[1] = new ScrReference(01001002, Paratext.ScrVers.English);
            int        hvoKtRef = m_inMemoryCache.NewHvo(ChkRef.kClassId);
            KeyTermRef ktRef    = new KeyTermRef(Cache, hvoKtRef);

            ktRef.Ref = 01001001;
            Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(ktRef, anchorRefRange, endRefRange));
        }
Пример #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the index of the key term reference for the specified guid. If a key term
        /// reference for the guid cannot be found, then -1 is returned.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private int GetKeyTermRef(Guid guid)
        {
            for (int i = 0; i < m_list.Count; i++)
            {
                KeyTermRef keyTermRef = m_list[i] as KeyTermRef;
                if (keyTermRef != null && keyTermRef.Guid == guid)
                {
                    return(i);
                }
            }

            return(-1);
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public int FindIndexOfRefWithHvo(int hvo)
        {
            if (m_list != null && m_list.Count > 0)
            {
                for (int i = 0; i < m_list.Count; i++)
                {
                    KeyTermRef keyTermRef = m_list[i] as KeyTermRef;
                    if (keyTermRef != null && keyTermRef.Hvo == hvo)
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
Пример #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes this rendering to the specified cache.
        /// </summary>
        /// <param name="term">The term to which this rendering belongs.</param>
        /// <param name="ResolveConflict">The delegate to call to resolve a conflict when a
        /// different rendering already exists.</param>
        /// ------------------------------------------------------------------------------------
        internal void WriteToCache(IChkTerm term, Func <IChkRef, string, string, bool> ResolveConflict)
        {
            IChkRef occ = term.OccurrencesOS.FirstOrDefault(o => o.Ref == Reference && o.Location == Location);

            if (occ == null)
            {
                MessageBox.Show(string.Format("Couldn't find occurrence {0} in {1} for imported rendering of term: {2}.",
                                              Location, (new BCVRef(Reference)), term.Name.AnalysisDefaultWritingSystem), "Unable to Import");
                return;
            }

            if (string.IsNullOrEmpty(VernRendering))
            {
                if (occ.Status != KeyTermRenderingStatus.Ignored)
                {
                    occ.Status      = KeyTermRenderingStatus.Ignored;
                    occ.RenderingRA = null;
                }
                return;
            }

            string existingRendering = occ.RenderingRA == null ? null :
                                       occ.RenderingRA.Form.VernacularDefaultWritingSystem.Text;

            if (existingRendering == VernRendering)
            {
                return;                 // already set. Nothing to do.
            }
            if (!string.IsNullOrEmpty(existingRendering))
            {
                if (!ResolveConflict(occ, existingRendering, VernRendering))
                {
                    return;                     // Leave existing rendering
                }
            }

            // See if the word form already exists
            IWfiWordform wordForm = WfiWordformServices.FindOrCreateWordform(term.Cache,
                                                                             VernRendering, term.Services.WritingSystems.DefaultVernacularWritingSystem);

            KeyTermRef ktRef = new KeyTermRef(occ);

            // Change the reference's status and attach the word form to the ChkRef
            ktRef.AssignRendering(wordForm);
        }
Пример #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Recursively populate a list with key term references
        /// </summary>
        /// <param name="keyTerm">ChkTerm which is part of the keyterm hierarchy</param>
        /// <param name="filteredBookIds">list of books in the filter, or null if no filter</param>
        /// ------------------------------------------------------------------------------------
        private void PopulateKeyTermRefs(IChkTerm keyTerm, List <int> filteredBookIds)
        {
            foreach (IChkRef chkRef in keyTerm.OccurrencesOS)
            {
                KeyTermRef keyRef = new KeyTermRef(chkRef);
                if (filteredBookIds == null || filteredBookIds.Contains(keyRef.RefInCurrVersification.Book))
                {
                    keyRef.PropertyChanged -= OnKeyTermRefPropertyChanged;
                    keyRef.PropertyChanged += OnKeyTermRefPropertyChanged;
                    m_list.Add(keyRef);
                }
            }

            foreach (IChkTerm kt in keyTerm.SubPossibilitiesOS)
            {
                PopulateKeyTermRefs(kt, filteredBookIds);
            }
        }
Пример #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnSaveSettings(Microsoft.Win32.RegistryKey key)
        {
            CheckDisposed();
            base.OnSaveSettings(key);

            KeyTermRef keyTermRef = SelectedReference;

            // Sometimes we get here when the cache has already been disposed but the ref.
            // is still an object. In that case referencing the guid will cause a crash,
            // therefore ignore exceptions.
            try
            {
                if (key != null && keyTermRef != null && keyTermRef != KeyTermRef.Empty)
                {
                    key.SetValue("SelectedKeyTermRef", keyTermRef.Guid);
                }
            }
            catch { }
        }
Пример #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the enabled states of the buttons on the key terms tool strip.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal void UpdateToolStripButtons(KeyTermRef keyTermRef)
		{
			Debug.Assert(m_wrapper != null,
				"The key terms wrapper must be specified in KeyTermsToolStrip");

			m_tbbUseAsVern.Enabled = m_wrapper.EnableUseAsRendering(keyTermRef);
			m_tbbVernNotAssigned.Enabled = m_wrapper.EnableIgnoreUnrendered(keyTermRef);
			m_tbbNotRendered.Enabled = m_wrapper.EnableRenderingNotAssigned(keyTermRef);
			m_tbbApplyFilter.Checked = m_wrapper.ApplyBookFilter;
		}
Пример #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether or not there is a range selection consisting of at least one
		/// "word" (non-whitespace) in the draft view that is in the current check reference's
		/// reference.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private bool ValidKtTextIsSelected(KeyTermRef ktRef)
		{
			if (!IsKeyTermInRangeSelection(ktRef))
				return false;

			// The user is allowed to merely click on a word; they don't have to select it.
			// Therefore, we have to see if there is a range selection, and if not, see if
			// we can grow the selection into a word.
			ITsString tss = null;
			if (EditingHelper.CurrentSelection.Selection.IsRange)
			{
				EditingHelper.CurrentSelection.Selection.GetSelectionString(out tss,
					string.Empty);
			}
			else
			{
				IVwSelection sel = EditingHelper.CurrentSelection.Selection.GrowToWord();
				if (sel != null)
					sel.GetSelectionString(out tss, string.Empty);
			}

			return IsValidTSS(tss);
		}
Пример #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Writes this rendering to the specified cache.
		/// </summary>
		/// <param name="term">The term to which this rendering belongs.</param>
		/// <param name="ResolveConflict">The delegate to call to resolve a conflict when a
		/// different rendering already exists.</param>
		/// ------------------------------------------------------------------------------------
		internal void WriteToCache(IChkTerm term, Func<IChkRef, string, string, bool> ResolveConflict)
		{
			IChkRef occ = term.OccurrencesOS.FirstOrDefault(o => o.Ref == Reference && o.Location == Location);
			if (occ == null)
			{
				MessageBox.Show(string.Format("Couldn't find occurrence {0} in {1} for imported rendering of term: {2}.",
					Location, (new BCVRef(Reference)), term.Name.AnalysisDefaultWritingSystem), "Unable to Import");
				return;
			}

			if (string.IsNullOrEmpty(VernRendering))
			{
				if (occ.Status != KeyTermRenderingStatus.Ignored)
				{
					occ.Status = KeyTermRenderingStatus.Ignored;
					occ.RenderingRA = null;
				}
				return;
			}

			string existingRendering = occ.RenderingRA == null ? null :
				occ.RenderingRA.Form.VernacularDefaultWritingSystem.Text;

			if (existingRendering == VernRendering)
				return; // already set. Nothing to do.

			if (!string.IsNullOrEmpty(existingRendering))
			{
				if (!ResolveConflict(occ, existingRendering, VernRendering))
					return; // Leave existing rendering
			}

			// See if the word form already exists
			IWfiWordform wordForm = WfiWordformServices.FindOrCreateWordform(term.Cache,
				VernRendering, term.Services.WritingSystems.DefaultVernacularWritingSystem);

			KeyTermRef ktRef = new KeyTermRef(occ);
			// Change the reference's status and attach the word form to the ChkRef
			ktRef.AssignRendering(wordForm);
		}
Пример #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether or not there is a range selection in the draft view that is in
		/// the current check reference's reference.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private bool IsRangeSelectionInKtRef(KeyTermRef keyTermRef)
		{
			CheckDisposed();

			if (EditingHelper == null || EditingHelper.CurrentSelection == null)
				return false;

			// If the selection in the draft view is not a range selection, then there is
			// nothing to use.
			if (!EditingHelper.CurrentSelection.Selection.IsRange)
				return false;

			if (KeyTermRef.IsNullOrEmpty(keyTermRef))
				return false;

			return IsSelectionInRef(keyTermRef);
		}
Пример #18
0
		public void IsRangeInKtRef_InRange_VerseBridge()
		{
			ScrReference[] refRange = new ScrReference[2];
			refRange[0] = new ScrReference(01001001, Paratext.ScrVers.English);
			refRange[1] = new ScrReference(01001003, Paratext.ScrVers.English);
			int hvoKtRef = m_inMemoryCache.NewHvo(ChkRef.kClassId);
			KeyTermRef ktRef = new KeyTermRef(Cache, hvoKtRef);
			ktRef.Ref = 01001002;
			Assert.IsTrue(KeyTermsViewWrapper.IsRangeInKtRef(ktRef, refRange, refRange));
		}
Пример #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if the "Ignore Unrendered" command should be enabled
		/// </summary>
		/// <returns>true to enable, false to disable</returns>
		/// ------------------------------------------------------------------------------------
		public bool EnableIgnoreUnrendered(KeyTermRef keyTermRef)
		{
			CheckDisposed();
			if (keyTermRef == null)
				keyTermRef = SelectedReference;

			// If there are no references displayed, or there is not a current reference, then
			// do not enable the command.
			if (!Visible || KeyTermReferenceCount == 0 || keyTermRef == KeyTermRef.Empty)
				return false;

			// If the current key term reference is unrendered, then enable.
			return (keyTermRef.RenderingStatus != KeyTermRenderingStatus.Ignored);
		}
Пример #20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if the "Use As Rendering" command should be enabled
		/// </summary>
		/// <returns>true if it is valid to enable the command, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		public bool EnableUseAsRendering(KeyTermRef keyTermRef)
		{
			CheckDisposed();
			if (keyTermRef == null)
				keyTermRef = SelectedReference;

			// If there are no references displayed, or there is not a current reference, then
			// do not enable the command.
			if (!Visible || KeyTermReferenceCount == 0 || keyTermRef == KeyTermRef.Empty)
				return false;

			// If the focused window is not the renderings, or the draft view, then don't
			// enable the command.
			if (ActiveCheckingView != CheckView.Grid && ActiveCheckingView != CheckView.Draft)
				return false;

			return ValidKtTextIsSelected(keyTermRef);
		}
Пример #21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the specified key term reference falls within the given range of
		/// references. Normally this will only return <c>true</c> if the anchor and end are the
		/// same. That is to say, the selection represented by the given ranges must fall wholly
		/// within a single verse. (There is an anomalous case where it could succeed If the range crosses a verse number (or bridge) such that the end
		/// reference
		/// </summary>
		/// <param name="keyTermRef">The key term ref.</param>
		/// <param name="anchorRefRange">The anchor ref range (which is made up of two
		/// references to account for possible verse bridges).</param>
		/// <param name="endRefRange">The end ref range (which is made up of two
		/// references to account for possible verse bridges).</param>
		/// <returns>
		/// 	<c>true</c> if the specified key term ref falls within the given range;
		/// otherwise, <c>false</c>.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static bool IsRangeInKtRef(KeyTermRef keyTermRef, ScrReference[] anchorRefRange,
			ScrReference[] endRefRange)
		{
			ScrReference selectedKtRef = keyTermRef.RefInCurrVersification;
			return (anchorRefRange[0] <= selectedKtRef && anchorRefRange[1] >= selectedKtRef &&
				endRefRange[0] == anchorRefRange[0] && endRefRange[1] == anchorRefRange[1]);
		}
Пример #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Return the guid of the current row.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override object GetPreSortRow()
        {
            KeyTermRef keyTermRef = SelectedReference;

            return(keyTermRef != null && keyTermRef.IsValid ? keyTermRef.Guid : Guid.Empty);
        }
Пример #23
0
		public void IsRangeInKtRef_InRangeButAnchorAndEndAreDifferent()
		{
			ScrReference[] anchorRefRange = new ScrReference[2];
			ScrReference[] endRefRange = new ScrReference[2];
			anchorRefRange[0] = endRefRange[0] = new ScrReference(01001001, Paratext.ScrVers.English);
			anchorRefRange[1] = new ScrReference(01001001, Paratext.ScrVers.English);
			endRefRange[1] = new ScrReference(01001003, Paratext.ScrVers.English);
			int hvoKtRef = m_inMemoryCache.NewHvo(ChkRef.kClassId);
			KeyTermRef ktRef = new KeyTermRef(Cache, hvoKtRef);
			ktRef.Ref = 01001001;
			Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(ktRef, anchorRefRange, endRefRange));
		}
Пример #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether or not there is a range selection in the draft view that is in
		/// the current check reference's reference.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private bool IsKeyTermInRangeSelection(KeyTermRef ktRef)
		{
			if (EditingHelper == null || EditingHelper.CurrentSelection == null)
				return false;

			// If the selection in the draft view is not a range selection, or cannot be grown
			// into one, then there is nothing to use.
			if (!EditingHelper.CurrentSelection.Selection.IsRange)
			{
				IVwSelection sel = EditingHelper.CurrentSelection.Selection.GrowToWord();
				if (sel == null)
					return false;
			}

			// If the selection is not in the same Scripture reference as the selected key term
			// then don't enable the command.
			return IsSelectionInRef(ktRef);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Recursively populate a list with key term references
		/// </summary>
		/// <param name="keyTerm">ChkTerm which is part of the keyterm hierarchy</param>
		/// <param name="filteredBookIds">list of books in the filter, or null if no filter</param>
		/// ------------------------------------------------------------------------------------
		private void PopulateKeyTermRefs(IChkTerm keyTerm, List<int> filteredBookIds)
		{
			foreach (IChkRef chkRef in keyTerm.OccurrencesOS)
			{
				KeyTermRef keyRef = new KeyTermRef(chkRef);
				if (filteredBookIds == null || filteredBookIds.Contains(keyRef.RefInCurrVersification.Book))
				{
					keyRef.PropertyChanged -= OnKeyTermRefPropertyChanged;
					keyRef.PropertyChanged += OnKeyTermRefPropertyChanged;
					m_list.Add(keyRef);
				}
			}

			foreach (IChkTerm kt in keyTerm.SubPossibilitiesOS)
				PopulateKeyTermRefs(kt, filteredBookIds);
		}
Пример #26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
        {
            base.PropChanged(hvo, tag, ivMin, cvIns, cvDel);

            if (tag != (int)ChkRef.ChkRefTags.kflidRef &&
                tag != (int)ChkRef.ChkRefTags.kflidRendering &&
                tag != (int)ChkRef.ChkRefTags.kflidStatus &&
                tag != (int)ChkRef.ChkRefTags.kflidKeyWord)
            {
                return;
            }

            int iKeyTermRef = FindIndexOfRefWithHvo(hvo);

            if (iKeyTermRef < 0)
            {
                return;
            }

            KeyTermRef keyTermRef   = m_list[iKeyTermRef] as KeyTermRef;
            string     propertyName = m_cache.MetaDataCacheAccessor.GetFieldName((uint)tag);

            keyTermRef.OnPropertyChanged(propertyName);

            // In the data grid view we are displaying some artifical properties, yet
            // we change the underlaying property. If it is one of those we do a prop
            // changed for our artifical ones as well.
            int invalidateColumn = -1;             // column to invalidate

            switch (propertyName)
            {
            default: return;

            case "Status":
                propertyName     = "RenderingStatus";
                invalidateColumn = KeyTermRenderingsControl.kStatusCol;
                break;

            case "Ref":
                propertyName     = "Reference";
                invalidateColumn = KeyTermRenderingsControl.kRefCol;
                break;

            case "KeyWord":
                propertyName     = "KeyWordString";
                invalidateColumn = KeyTermRenderingsControl.kCommentCol;
                break;

            case "RenderingRA":
                propertyName     = "Rendering";
                invalidateColumn = KeyTermRenderingsControl.kRenderingCol;
                break;
            }
            // TE-6621: In some cases (which developers nor JAARS testers can reproduce), the
            // column index is invalid for the datagrid, so we confirm that the index is
            // within the proper range.
            if (invalidateColumn >= 0 && invalidateColumn < ColumnCount)
            {
                InvalidateColumn(invalidateColumn);
            }

            keyTermRef.OnPropertyChanged(propertyName);
        }
Пример #27
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Returns whether the specified kt ref is null or empty.
 /// </summary>
 /// <param name="ktRef">The key terms reference.</param>
 /// ------------------------------------------------------------------------------------
 internal static bool IsNullOrEmpty(KeyTermRef ktRef)
 {
     return(ktRef == null || ktRef == Empty);
 }
Пример #28
0
		public void IsRangeInKtRef_OutOfRange_ConvertedVersification()
		{
			// Jonah 2:1 in Original != Jonah 2:1 in English
			ScrReference[] refRange = new ScrReference[2];
			refRange[0] = refRange[1] = new ScrReference(32002001, Paratext.ScrVers.English);
			int hvoKtRef = m_inMemoryCache.NewHvo(ChkRef.kClassId);
			KeyTermRef ktRefJonah2_1 = new KeyTermRef(Cache, hvoKtRef);
			ktRefJonah2_1.Ref = 32002001;
			Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(ktRefJonah2_1, refRange, refRange));
		}
Пример #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns whether or not the current selection in the draft view is entirely contained
		/// in the verse which is the given reference.
		/// </summary>
		/// <param name="ktRef">The key terms reference.</param>
		/// ------------------------------------------------------------------------------------
		private bool IsSelectionInRef(KeyTermRef ktRef)
		{
			CheckDisposed();

			if (KeyTermRef.IsNullOrEmpty(ktRef))
				throw new ArgumentException("Parameter must not be null or empty", "ktRef");

			return IsRangeInKtRef(ktRef, EditingHelper.GetCurrentAnchorRefRange(),
				EditingHelper.GetCurrentEndRefRange());
		}
Пример #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns whether the specified kt ref is null or empty.
		/// </summary>
		/// <param name="ktRef">The key terms reference.</param>
		/// ------------------------------------------------------------------------------------
		internal static bool IsNullOrEmpty(KeyTermRef ktRef)
		{
			return (ktRef == null || ktRef == Empty);
		}
Пример #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check all of the sibling references for a key term to see if any of the verses
		/// have the same word form that was assigned. If they do, then the status will
		/// be set to auto-assigned.
		/// </summary>
		/// <param name="assignedRef">ChkRef that was explicitly assigned</param>
		/// <param name="wordForm">word for that was assigned to the ChkRef item</param>
		/// ------------------------------------------------------------------------------------
		private void AutoAssignVernacularEquivalents(IChkRef assignedRef, IWfiWordform wordForm)
		{
			int iDummy;
			IChkTerm parent = (IChkTerm)assignedRef.Owner;
			foreach (IChkRef autoAssignRef in parent.OccurrencesOS)
			{
				KeyTermRef ktRef = new KeyTermRef(autoAssignRef);
				if (ktRef.RenderingStatus != KeyTermRenderingStatus.Unassigned)
					continue;

				if (TeEditingHelper.FindTextInVerse(m_scr,
					wordForm.Form.get_String(wordForm.Cache.DefaultVernWs),
					ktRef.RefInCurrVersification, true,
					out iDummy, out iDummy, out iDummy, out iDummy))
				{
					// TODO: update the local view constructor cache
					ktRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned;
					ktRef.ChkRef.RenderingRA = wordForm;
				}
			}
		}