/// <summary> /// Sets the number of occurrences of a context. /// </summary> /// <param name="min">The min.</param> /// <param name="max">The max.</param> public void SetContextOccurrence(int min, int max) { CheckDisposed(); SelectionHelper sel = SelectionHelper.Create(m_view); int cellId = GetCell(sel); int hvo = GetItemHvo(sel, SelectionHelper.SelLimitType.Anchor); IPhPhonContext ctxt = PhPhonContext.CreateFromDBObject(m_cache, hvo); int index = -1; using (new UndoRedoTaskHelper(m_cache, MEStrings.ksRegRuleUndoSetOccurrence, MEStrings.ksRegRuleRedoSetOccurrence)) { if (ctxt.ClassID == PhIterationContext.kclsidPhIterationContext) { // if there is an existing iteration context, just update it or remove it if it can occur only once IPhIterationContext iterCtxt = ctxt as IPhIterationContext; if (min == 1 && max == 1) { index = OverwriteContext(iterCtxt.MemberRA, iterCtxt, cellId == (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, false); } else { iterCtxt.Minimum = min; iterCtxt.Maximum = max; } } else if (min != 1 || max != 1) { // create a new iteration context IPhIterationContext iterCtxt = new PhIterationContext(); index = OverwriteContext(iterCtxt, ctxt, cellId == (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext, true); iterCtxt.MemberRAHvo = ctxt.Hvo; iterCtxt.Minimum = min; iterCtxt.Maximum = max; iterCtxt.NotifyNew(); } } if (index == -1) { IPhPhonContext envCtxt = cellId == (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext ? RHS.LeftContextOA : RHS.RightContextOA; IPhSequenceContext seqCtxt; index = GetIndex(ctxt, envCtxt, out seqCtxt); } ReconstructView(cellId, index, true); }
/// <summary> /// Gets the number of occurrences of the currently selected context. /// </summary> /// <param name="min">The min.</param> /// <param name="max">The max.</param> public void GetContextOccurrence(out int min, out int max) { CheckDisposed(); SelectionHelper sel = SelectionHelper.Create(m_view); int hvo = GetItemHvo(sel, SelectionHelper.SelLimitType.Anchor); IPhPhonContext ctxt = PhPhonContext.CreateFromDBObject(m_cache, hvo); if (ctxt.ClassID == PhIterationContext.kclsidPhIterationContext) { IPhIterationContext iterCtxt = ctxt as IPhIterationContext; min = iterCtxt.Minimum; max = iterCtxt.Maximum; } else { min = 1; max = 1; } }