Exemple #1
0
		/// <summary>
		/// Set description based on the content of the BasicIPASymbol field and the BasicIPAInfo document
		/// </summary>
		/// <param name="doc">XmlDocument containing the BasicIPAInfo</param>
		/// <param name="fJustChangedFeatures"></param>
		/// <returns><c>true</c> if the description was changed; <c>false</c> otherwise</returns>
		public bool SetFeaturesBasedOnIPA(XmlDocument doc, bool fJustChangedFeatures)
		{
			int tagLongName = Cache.VwCacheDaAccessor.GetVirtualHandlerName("FsFeatStruc", "LongNameTSS").Tag;
			int longNameOldLen = 0;
			if (FeaturesOA != null && FeaturesOA.LongName != null)
				longNameOldLen = FeaturesOA.LongName.Length;
			if (CanAddFeatures(fJustChangedFeatures))
			{
				string sXPath = "//SegmentDefinition[Representations/Representation[.='" + BasicIPASymbol.Text +
								"']]/Features";
				XmlNode features = doc.SelectSingleNode(sXPath);
				if (features != null)
				{
					bool fCreatedNewFS = false;
					foreach (XmlNode feature in features)
					{
						if (feature.Name != "FeatureValuePair")
							continue;
						string sFeature = XmlUtils.GetAttributeValue(feature, "feature");
						string sValue = XmlUtils.GetAttributeValue(feature, "value");
						int hvoFeature = FsFeatureSystem.GetClosedFeature(m_cache, sFeature);
						if (hvoFeature == 0)
							continue;
						int hvoValue = FsFeatureSystem.GetSymbolicValue(m_cache, sValue);
						if (hvoValue == 0)
							continue;
						if (FeaturesOA == null)
						{
							FeaturesOA = new FsFeatStruc();
							fCreatedNewFS = true;
						}
						FsClosedValue value = new FsClosedValue();
						FeaturesOA.FeatureSpecsOC.Add(value);
						value.FeatureRAHvo = hvoFeature;
						value.ValueRAHvo = hvoValue;
					}
					bool madeFeatures = false;
					if (FeaturesOA != null && FeaturesOA.FeatureSpecsOC.Count > 0)
					{
						// notify interested parties of the change
						if (fCreatedNewFS)
						{
							Cache.PropChanged(null, PropChangeType.kpctNotifyAll, Hvo,
											  (int) PhPhonemeTags.kflidFeatures,
											  0, 1, 0);
						}
						Cache.PropChanged(null, PropChangeType.kpctNotifyAll, FeaturesOA.Hvo,
										  (int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs,
										  0, FeaturesOA.FeatureSpecsOC.Count, 0);
						FeaturesOA.UpdateFeatureLongName(tagLongName, longNameOldLen);
						madeFeatures = true;
					}
					return madeFeatures;
				}
			}
			else if (BasicIPASymbol.Length == 0 && fJustChangedFeatures)
			{
				if (FeaturesOA != null)
				{
					// user has cleared the basic IPA symbol; clear the features
					int iCount = FeaturesOA.FeatureSpecsOC.Count;
					FeaturesOA.FeatureSpecsOC.RemoveAll();
					// notify interested parties of the change
					Cache.PropChanged(null, PropChangeType.kpctNotifyAll, FeaturesOA.Hvo,
									  (int) FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs,
									  0, 0, iCount);
					FeaturesOA.UpdateFeatureLongName(tagLongName, longNameOldLen);
				}
				return true;
			}
			return false;
		}
Exemple #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;
		}