コード例 #1
0
        IPhFeatureConstraint GetFeatureConstraint(IEnumerable <int> featConstrs, int hvoClosedFeature)
        {
            IPhFeatureConstraint result = null;

            foreach (int hvo in featConstrs)
            {
                IPhFeatureConstraint curConstr = new PhFeatureConstraint(m_cache, hvo);
                if (curConstr.FeatureRAHvo == hvoClosedFeature)
                {
                    result = curConstr;
                    break;
                }
            }
            return(result);
        }
コード例 #2
0
        public override ITsString DisplayVariant(IVwEnv vwenv, int tag, object v, int frag)
        {
            CheckDisposed();

            // we use display variant to display literal strings that are editable
            ITsString tss = null;

            switch (frag)
            {
            case kfragEmpty:
                tss = m_empty;
                break;

            case kfragFeatureLine:
                IFsClosedValue value = new FsClosedValue(m_cache, vwenv.CurrentObject());
                tss = CreateFeatureLine(value);
                break;

            case kfragPlusVariableLine:
            case kfragMinusVariableLine:
                IPhFeatureConstraint var = new PhFeatureConstraint(m_cache, vwenv.CurrentObject());
                tss = CreateVariableLine(var, frag == kfragPlusVariableLine);
                break;

            case kfragIterCtxtMax:
                // if the max value is -1, it indicates that it is infinite
                int i = (int)v;
                if (i == -1)
                {
                    tss = m_infinity;
                }
                else
                {
                    tss = m_cache.MakeUserTss(Convert.ToString(i));
                }
                break;

            case kfragLeftBracketUpHook:
                tss = m_leftBracketUpHook;
                break;

            case kfragLeftBracketExt:
                tss = m_leftBracketExt;
                break;

            case kfragLeftBracketLowHook:
                tss = m_leftBracketLowHook;
                break;

            case kfragRightBracketUpHook:
                tss = m_rightBracketUpHook;
                break;

            case kfragRightBracketExt:
                tss = m_rightBracketExt;
                break;

            case kfragRightBracketLowHook:
                tss = m_rightBracketLowHook;
                break;

            case kfragLeftBracket:
                tss = m_leftBracket;
                break;

            case kfragRightBracket:
                tss = m_rightBracket;
                break;

            case kfragQuestions:
                tss = m_questions;
                break;

            case kfragLeftParen:
                tss = m_leftParen;
                break;

            case kfragRightParen:
                tss = m_rightParen;
                break;

            case kfragXVariable:
                tss = m_x;
                break;

            case kfragZeroWidthSpace:
                tss = m_zwSpace;
                break;
            }
            return(tss);
        }
コード例 #3
0
ファイル: RuleFormulaView.cs プロジェクト: sillsdev/WorldPad
		public override ITsString DisplayVariant(IVwEnv vwenv, int tag, object v, int frag)
		{
			CheckDisposed();

			// we use display variant to display literal strings that are editable
			ITsString tss = null;
			switch (frag)
			{
				case kfragEmpty:
					tss = m_empty;
					break;

				case kfragFeatureLine:
					IFsClosedValue value = new FsClosedValue(m_cache, vwenv.CurrentObject());
					tss = CreateFeatureLine(value);
					break;

				case kfragPlusVariableLine:
				case kfragMinusVariableLine:
					IPhFeatureConstraint var = new PhFeatureConstraint(m_cache, vwenv.CurrentObject());
					tss = CreateVariableLine(var, frag == kfragPlusVariableLine);
					break;

				case kfragIterCtxtMax:
					// if the max value is -1, it indicates that it is infinite
					int i = (int)v;
					if (i == -1)
						tss = m_infinity;
					else
						tss = m_cache.MakeUserTss(Convert.ToString(i));
					break;

				case kfragLeftBracketUpHook:
					tss = m_leftBracketUpHook;
					break;

				case kfragLeftBracketExt:
					tss = m_leftBracketExt;
					break;

				case kfragLeftBracketLowHook:
					tss = m_leftBracketLowHook;
					break;

				case kfragRightBracketUpHook:
					tss = m_rightBracketUpHook;
					break;

				case kfragRightBracketExt:
					tss = m_rightBracketExt;
					break;

				case kfragRightBracketLowHook:
					tss = m_rightBracketLowHook;
					break;

				case kfragLeftBracket:
					tss = m_leftBracket;
					break;

				case kfragRightBracket:
					tss = m_rightBracket;
					break;

				case kfragQuestions:
					tss = m_questions;
					break;

				case kfragLeftParen:
					tss = m_leftParen;
					break;

				case kfragRightParen:
					tss = m_rightParen;
					break;

				case kfragXVariable:
					tss = m_x;
					break;

				case kfragZeroWidthSpace:
					tss = m_zwSpace;
					break;
			}
			return tss;
		}
コード例 #4
0
        /// <summary>
        /// Updates the feature constraints in the context.
        /// </summary>
        void UpdateFeatureConstraints()
        {
            CheckDisposed();

            List <int> featureHvos = m_bvList.AllItems;

            foreach (int hvoClosedFeature in featureHvos)
            {
                string str = m_cache.GetUnicodeProperty(hvoClosedFeature, m_dummyPolarityFlid);
                if (str == null)
                {
                    IPhFeatureConstraint removedConstr = RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature);
                    if (removedConstr == null)
                    {
                        removedConstr = RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature);
                    }

                    if (removedConstr != null)
                    {
                        bool found = false;
                        foreach (int hvo in m_rule.FeatureConstraints)
                        {
                            if (removedConstr.Hvo == hvo)
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Remove(removedConstr);
                        }
                    }
                }
                else
                {
                    IPhFeatureConstraint var = GetFeatureConstraint(m_rule.FeatureConstraints, hvoClosedFeature);
                    if (var == null)
                    {
                        var = new PhFeatureConstraint();
                        m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Append(var);
                        var.FeatureRAHvo = hvoClosedFeature;
                        var.NotifyNew();
                    }

                    if (str == MEStrings.ksFeatConstrAgree)
                    {
                        if (!m_ctxt.PlusConstrRS.Contains(var))
                        {
                            m_ctxt.PlusConstrRS.Append(var);
                            RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature);
                        }
                    }
                    else if (str == MEStrings.ksFeatConstrDisagree)
                    {
                        if (!m_ctxt.MinusConstrRS.Contains(var))
                        {
                            m_ctxt.MinusConstrRS.Append(var);
                            RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature);
                        }
                    }
                }
            }
        }
コード例 #5
0
		IPhFeatureConstraint GetFeatureConstraint(IEnumerable<int> featConstrs, int hvoClosedFeature)
		{
			IPhFeatureConstraint result = null;
			foreach (int hvo in featConstrs)
			{
				IPhFeatureConstraint curConstr = new PhFeatureConstraint(m_cache, hvo);
				if (curConstr.FeatureRAHvo == hvoClosedFeature)
				{
					result = curConstr;
					break;
				}
			}
			return result;
		}
コード例 #6
0
		/// <summary>
		/// Updates the feature constraints in the context.
		/// </summary>
		void UpdateFeatureConstraints()
		{
			CheckDisposed();

			List<int> featureHvos = m_bvList.AllItems;
			foreach (int hvoClosedFeature in featureHvos)
			{
				string str = m_cache.GetUnicodeProperty(hvoClosedFeature, m_dummyPolarityFlid);
				if (str == null)
				{
					IPhFeatureConstraint removedConstr = RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature);
					if (removedConstr == null)
						removedConstr = RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature);

					if (removedConstr != null)
					{
						bool found = false;
						foreach (int hvo in m_rule.FeatureConstraints)
						{
							if (removedConstr.Hvo == hvo)
							{
								found = true;
								break;
							}
						}
						if (!found)
							m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Remove(removedConstr);
					}
				}
				else
				{
					IPhFeatureConstraint var = GetFeatureConstraint(m_rule.FeatureConstraints, hvoClosedFeature);
					if (var == null)
					{
						var = new PhFeatureConstraint();
						m_cache.LangProject.PhonologicalDataOA.FeatConstraintsOS.Append(var);
						var.FeatureRAHvo = hvoClosedFeature;
						var.NotifyNew();
					}

					if (str == MEStrings.ksFeatConstrAgree)
					{
						if (!m_ctxt.PlusConstrRS.Contains(var))
						{
							m_ctxt.PlusConstrRS.Append(var);
							RemoveFeatureConstraint(m_ctxt.MinusConstrRS, hvoClosedFeature);
						}
					}
					else if (str == MEStrings.ksFeatConstrDisagree)
					{
						if (!m_ctxt.MinusConstrRS.Contains(var))
						{
							m_ctxt.MinusConstrRS.Append(var);
							RemoveFeatureConstraint(m_ctxt.PlusConstrRS, hvoClosedFeature);
						}
					}
				}
			}
		}