int InsertContext(IPhSimpleContext ctxt, SelectionHelper sel, out int cellIndex) { int cellId = GetCell(sel); int index = InsertContextInto(ctxt, sel, Rule.StrucDescOS); Rule.UpdateStrucChange(cellId, index, true); cellIndex = ConvertToCellIndex(cellId, index); return(cellId); }
protected int InsertContextInto(IPhSimpleContext ctxt, SelectionHelper sel, IFdoOwningSequence<IPhSimpleContext> seq) { ICmObject[] ctxts = seq.Cast<ICmObject>().ToArray(); int index = GetInsertionIndex(ctxts, sel); // if the current selection is a range remove the items we are overwriting if (sel.IsRange) { var indices = GetIndicesToRemove(ctxts, sel); foreach (int idx in indices) { var c = (IPhSimpleContext) ctxts[idx]; c.PreRemovalSideEffects(); seq.Remove(c); } } seq.Insert(index, ctxt); return index; }
int InsertContext(IPhSimpleContext ctxt, int fsFlid, int fsHvo, SelectionHelper sel, out int cellIndex) { cellIndex = -1; int cellId = GetCell(sel); switch (cellId) { case (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc: IPhRegularRule rule = new PhRegularRule(m_cache, RHS.OwnerHVO); cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, rule.StrucDescOS); break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange: cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, RHS.StrucChangeOS); break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext: if (RHS.LeftContextOAHvo == 0) { RHS.LeftContextOA = ctxt; m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); } else { cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, CreateSeqCtxt(cellId)); } break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext: if (RHS.RightContextOAHvo == 0) { RHS.RightContextOA = ctxt; m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); } else { cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, CreateSeqCtxt(cellId)); } break; } return(cellId); }
protected int InsertContextInto(IPhSimpleContext ctxt, SelectionHelper sel, IPhSequenceContext seqCtxt) { m_cache.LangProject.PhonologicalDataOA.ContextsOS.Add(ctxt); ICmObject[] ctxts = seqCtxt.MembersRS.Cast<ICmObject>().ToArray(); int index = GetInsertionIndex(ctxts, sel); seqCtxt.MembersRS.Insert(index, ctxt); // if the current selection is a range remove the items we are overwriting if (sel.IsRange) { var indices = GetIndicesToRemove(ctxts, sel); foreach (int idx in indices) { var c = (IPhPhonContext) ctxts[idx]; c.PreRemovalSideEffects(); m_cache.LangProject.PhonologicalDataOA.ContextsOS.Remove(c); } } return index; }
int GetSimpleCtxtWidth(IPhSimpleContext ctxt, IVwEnv vwenv) { if (ctxt == null) { return(0); } switch (ctxt.ClassID) { case PhSimpleContextBdry.kclsidPhSimpleContextBdry: IPhSimpleContextBdry bdryCtxt = ctxt as IPhSimpleContextBdry; return(GetTermUnitWidth(bdryCtxt.FeatureStructureRA, vwenv)); case PhSimpleContextSeg.kclsidPhSimpleContextSeg: IPhSimpleContextSeg segCtxt = ctxt as IPhSimpleContextSeg; return(GetTermUnitWidth(segCtxt.FeatureStructureRA, vwenv)); case PhSimpleContextNC.kclsidPhSimpleContextNC: return(GetNCCtxtWidth(ctxt as IPhSimpleContextNC, vwenv)); } return(0); }
int GetSimpleCtxtWidth(IPhSimpleContext ctxt, IVwEnv vwenv) { if (ctxt == null) { return(0); } switch (ctxt.ClassID) { case PhSimpleContextBdryTags.kClassId: var bdryCtxt = (IPhSimpleContextBdry)ctxt; return(GetTermUnitWidth(bdryCtxt.FeatureStructureRA, vwenv)); case PhSimpleContextSegTags.kClassId: var segCtxt = (IPhSimpleContextSeg)ctxt; return(GetTermUnitWidth(segCtxt.FeatureStructureRA, vwenv)); case PhSimpleContextNCTags.kClassId: return(GetNCCtxtWidth(ctxt as IPhSimpleContextNC, vwenv)); } return(0); }
int InsertContext(IPhSimpleContext ctxt, SelectionHelper sel, out int cellIndex) { cellIndex = -1; int cellId = GetCell(sel); switch (cellId) { case PhSegmentRuleTags.kflidStrucDesc: cellIndex = InsertContextInto(ctxt, sel, Rhs.OwningRule.StrucDescOS); break; case PhSegRuleRHSTags.kflidStrucChange: cellIndex = InsertContextInto(ctxt, sel, Rhs.StrucChangeOS); break; case PhSegRuleRHSTags.kflidLeftContext: if (Rhs.LeftContextOA == null) { Rhs.LeftContextOA = ctxt; } else { cellIndex = InsertContextInto(ctxt, sel, CreateSeqCtxt(cellId)); } break; case PhSegRuleRHSTags.kflidRightContext: if (Rhs.RightContextOA == null) { Rhs.RightContextOA = ctxt; } else { cellIndex = InsertContextInto(ctxt, sel, CreateSeqCtxt(cellId)); } break; } return(cellId); }
bool DisplayOption(RuleInsertType type) { SelectionHelper sel = SelectionHelper.Create(m_view); int cellId = GetCell(sel); if (cellId == -1 || cellId == -2) { return(false); } switch (cellId) { case PhMetathesisRuleTags.kidxLeftSwitch: switch (type) { case RuleInsertType.WORD_BOUNDARY: return(false); case RuleInsertType.MORPHEME_BOUNDARY: if (Rule.LeftSwitchIndex == -1 || Rule.MiddleIndex != -1 || sel.IsRange) { return(false); } else { return(GetInsertionIndex(Rule.StrucDescOS.ToArray(), sel) == Rule.LeftSwitchIndex + 1); } default: if (Rule.LeftSwitchIndex == -1) { return(true); } else if (sel.IsRange) { var beginObj = GetItem(sel, SelectionHelper.SelLimitType.Top); var endObj = GetItem(sel, SelectionHelper.SelLimitType.Bottom); IPhSimpleContext lastCtxt = null; if (Rule.MiddleIndex != -1 && Rule.IsMiddleWithLeftSwitch) { lastCtxt = Rule.StrucDescOS[Rule.MiddleLimit - 1]; } else { lastCtxt = Rule.StrucDescOS[Rule.LeftSwitchLimit - 1]; } return(beginObj == Rule.StrucDescOS[Rule.LeftSwitchIndex] && endObj == lastCtxt); } return(false); } case PhMetathesisRuleTags.kidxRightSwitch: switch (type) { case RuleInsertType.WORD_BOUNDARY: return(false); case RuleInsertType.MORPHEME_BOUNDARY: if (Rule.RightSwitchIndex == -1 || Rule.MiddleIndex != -1 || sel.IsRange) { return(false); } else { return(GetInsertionIndex(Rule.StrucDescOS.ToArray(), sel) == Rule.RightSwitchIndex); } default: if (Rule.RightSwitchIndex == -1) { return(true); } else if (sel.IsRange) { var beginObj = GetItem(sel, SelectionHelper.SelLimitType.Top); var endObj = GetItem(sel, SelectionHelper.SelLimitType.Bottom); IPhSimpleContext firstCtxt = null; if (Rule.MiddleIndex != -1 && !Rule.IsMiddleWithLeftSwitch) { firstCtxt = Rule.StrucDescOS[Rule.MiddleIndex]; } else { firstCtxt = Rule.StrucDescOS[Rule.RightSwitchIndex]; } return(beginObj == firstCtxt && endObj == Rule.StrucDescOS[Rule.RightSwitchLimit - 1]); } return(false); } case PhMetathesisRuleTags.kidxLeftEnv: IPhSimpleContext[] leftCtxts = Rule.StrucDescOS.ToArray(); IPhSimpleContext first = null; if (Rule.StrucDescOS.Count > 0) { first = Rule.StrucDescOS[0]; } if (type == RuleInsertType.WORD_BOUNDARY) { // only display the word boundary option if we are at the beginning of the left context and // there is no word boundary already inserted if (sel.IsRange) { return(GetIndicesToRemove(leftCtxts, sel)[0] == 0); } else { return(GetInsertionIndex(leftCtxts, sel) == 0 && !IsWordBoundary(first)); } } else { // we cannot insert anything to the left of a word boundary in the left context return(sel.IsRange || GetInsertionIndex(leftCtxts, sel) != 0 || !IsWordBoundary(first)); } case PhMetathesisRuleTags.kidxRightEnv: IPhSimpleContext[] rightCtxts = Rule.StrucDescOS.ToArray(); IPhSimpleContext last = null; if (Rule.StrucDescOS.Count > 0) { last = Rule.StrucDescOS[Rule.StrucDescOS.Count - 1]; } if (type == RuleInsertType.WORD_BOUNDARY) { // only display the word boundary option if we are at the end of the right context and // there is no word boundary already inserted if (sel.IsRange) { int[] indices = GetIndicesToRemove(rightCtxts, sel); return(indices[indices.Length - 1] == rightCtxts.Length - 1); } else { return(GetInsertionIndex(rightCtxts, sel) == rightCtxts.Length && !IsWordBoundary(last)); } } else { // we cannot insert anything to the right of a word boundary in the right context return(sel.IsRange || GetInsertionIndex(rightCtxts, sel) != rightCtxts.Length || !IsWordBoundary(last)); } } return(false); }
int GetSimpleCtxtWidth(IPhSimpleContext ctxt, IVwEnv vwenv) { if (ctxt == null) return 0; switch (ctxt.ClassID) { case PhSimpleContextBdryTags.kClassId: var bdryCtxt = ctxt as IPhSimpleContextBdry; return GetTermUnitWidth(bdryCtxt.FeatureStructureRA, vwenv); case PhSimpleContextSegTags.kClassId: var segCtxt = ctxt as IPhSimpleContextSeg; return GetTermUnitWidth(segCtxt.FeatureStructureRA, vwenv); case PhSimpleContextNCTags.kClassId: return GetNCCtxtWidth(ctxt as IPhSimpleContextNC, vwenv); } return 0; }
int InsertContext(IPhSimpleContext ctxt, int fsFlid, int fsHvo, SelectionHelper sel, out int cellIndex) { int cellId = GetCell(sel); int index = InsertContextInto(ctxt, fsFlid, fsHvo, sel, Rule.StrucDescOS); Rule.UpdateStrucChange(cellId, index, true); cellIndex = ConvertToCellIndex(cellId, index); return cellId; }
protected int InsertContextInto(IPhSimpleContext ctxt, int fsFlid, int fsHvo, SelectionHelper sel, IPhSequenceContext seqCtxt) { m_cache.LangProject.PhonologicalDataOA.ContextsOS.Append(ctxt); m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); int[] hvos = seqCtxt.MembersRS.HvoArray; int index = GetInsertionIndex(hvos, sel); seqCtxt.MembersRS.InsertAt(ctxt, index); // if the current selection is a range remove the items we are overwriting if (sel.IsRange) { int[] indices = GetIndicesToRemove(hvos, sel); foreach (int idx in indices) { if (m_cache.LangProject.PhonologicalDataOA.ContextsOS.Contains(hvos[idx])) { IPhPhonContext removeCtxt = PhPhonContext.CreateFromDBObject(m_cache, hvos[idx]); removeCtxt.DeleteUnderlyingObject(); } } } return index; }
protected int InsertContextInto(IPhSimpleContext ctxt, int fsFlid, int fsHvo, SelectionHelper sel, FdoOwningSequence<IPhSimpleContext> seq) { int[] hvos = seq.HvoArray; int index = GetInsertionIndex(hvos, sel); // if the current selection is a range remove the items we are overwriting if (sel.IsRange) { int[] indices = GetIndicesToRemove(hvos, sel); foreach (int idx in indices) { if (seq.Contains(hvos[idx])) { IPhSimpleContext removeCtxt = PhSimpleContext.CreateFromDBObject(m_cache, hvos[idx]); removeCtxt.DeleteUnderlyingObject(); } } } seq.InsertAt(ctxt, index); m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); return index; }
int GetSimpleCtxtWidth(IPhSimpleContext ctxt, IVwEnv vwenv) { if (ctxt == null) return 0; switch (ctxt.ClassID) { case PhSimpleContextBdry.kclsidPhSimpleContextBdry: IPhSimpleContextBdry bdryCtxt = ctxt as IPhSimpleContextBdry; return GetTermUnitWidth(bdryCtxt.FeatureStructureRA, vwenv); case PhSimpleContextSeg.kclsidPhSimpleContextSeg: IPhSimpleContextSeg segCtxt = ctxt as IPhSimpleContextSeg; return GetTermUnitWidth(segCtxt.FeatureStructureRA, vwenv); case PhSimpleContextNC.kclsidPhSimpleContextNC: return GetNCCtxtWidth(ctxt as IPhSimpleContextNC, vwenv); } return 0; }
int InsertContext(IPhSimpleContext ctxt, int fsFlid, int fsHvo, SelectionHelper sel, out int cellIndex) { cellIndex = -1; int cellId = GetCell(sel); switch (cellId) { case (int)PhRegularRule.PhSegmentRuleTags.kflidStrucDesc: IPhRegularRule rule = new PhRegularRule(m_cache, RHS.OwnerHVO); cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, rule.StrucDescOS); break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidStrucChange: cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, RHS.StrucChangeOS); break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidLeftContext: if (RHS.LeftContextOAHvo == 0) { RHS.LeftContextOA = ctxt; m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); } else { cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, CreateSeqCtxt(cellId)); } break; case (int)PhSegRuleRHS.PhSegRuleRHSTags.kflidRightContext: if (RHS.RightContextOAHvo == 0) { RHS.RightContextOA = ctxt; m_cache.SetObjProperty(ctxt.Hvo, fsFlid, fsHvo); ctxt.NotifyNew(); } else { cellIndex = InsertContextInto(ctxt, fsFlid, fsHvo, sel, CreateSeqCtxt(cellId)); } break; } return cellId; }
int InsertContext(IPhSimpleContext ctxt, SelectionHelper sel, out int cellIndex) { cellIndex = -1; int cellId = GetCell(sel); switch (cellId) { case PhSegmentRuleTags.kflidStrucDesc: cellIndex = InsertContextInto(ctxt, sel, Rhs.OwningRule.StrucDescOS); break; case PhSegRuleRHSTags.kflidStrucChange: cellIndex = InsertContextInto(ctxt, sel, Rhs.StrucChangeOS); break; case PhSegRuleRHSTags.kflidLeftContext: if (Rhs.LeftContextOA == null) Rhs.LeftContextOA = ctxt; else cellIndex = InsertContextInto(ctxt, sel, CreateSeqCtxt(cellId)); break; case PhSegRuleRHSTags.kflidRightContext: if (Rhs.RightContextOA == null) Rhs.RightContextOA = ctxt; else cellIndex = InsertContextInto(ctxt, sel, CreateSeqCtxt(cellId)); break; } return cellId; }