Beispiel #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes this category to the the specified annotation, creating a new category if
        /// needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void WriteToCache(IScrScriptureNote ann)
        {
            int ws = (string.IsNullOrEmpty(IcuLocale) ? ann.Cache.DefaultAnalWs :
                      ScrNoteImportManager.GetWsForLocale(IcuLocale));

            ICmPossibility category;

            if (CategoryPath.IndexOf(StringUtils.kChObject) != -1)
            {
                // The category specified the full path of the category possibility.
                category = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws);
            }
            else
            {
                // The category does not contain a delimiter, so we may need to search
                // the entire possibility tree for a matching category in case it is a
                // sub-possibility.
                category = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws, false);
            }

            IFdoReferenceSequence <ICmPossibility> categoryList = ann.CategoriesRS;

            if (!categoryList.Contains(category))
            {
                categoryList.Add(category);
            }
        }
        IPhFeatureConstraint RemoveFeatureConstraint(IFdoReferenceSequence <IPhFeatureConstraint> featConstrs, IFsFeatDefn feat)
        {
            var constrToRemove = GetFeatureConstraint(featConstrs, feat);

            if (constrToRemove != null)
            {
                featConstrs.Remove(constrToRemove);
            }
            return(constrToRemove);
        }
        int GetVariablesWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv, bool polarity)
        {
            IFdoReferenceSequence <IPhFeatureConstraint> vars = polarity ? ctxt.PlusConstrRS : ctxt.MinusConstrRS;
            int maxLen = 0;

            foreach (IPhFeatureConstraint var in vars)
            {
                ITsString varLine = CreateVariableLine(var, polarity);
                int       len     = GetStrWidth(varLine, null, vwenv);
                if (len > maxLen)
                {
                    maxLen = len;
                }
            }
            return(maxLen);
        }
Beispiel #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the sequence of selected possibilities
		/// </summary>
		/// <param name="listToUpdate">Sequence of possibilities. All possibilities that may be in
		/// this list get deleted and the new ones added.</param>
		/// <returns>True if the sequence was changed, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		public bool GetPossibilities(IFdoReferenceSequence<ICmPossibility> listToUpdate)
		{
			CheckDisposed();

			Debug.Assert(listToUpdate != null);
			Guid[] origGuids = listToUpdate.ToGuidArray();

			// Clear the list first.
			listToUpdate.Clear();

			bool fAllItemsAreTheSame = true;
			int i = 0;
			foreach (ICmPossibility newPoss in tvPossibilities.SelectedPossibilities)
			{
				listToUpdate.Add(newPoss);
				fAllItemsAreTheSame &= (i < origGuids.Length && origGuids[i++] != newPoss.Guid);
			}

			return (!fAllItemsAreTheSame || i != origGuids.Length);
		}
        /// <summary>
        /// Remove either the given entry or any sense owned by that entry from the list.
        /// </summary>
        private static void RemoveEntryFromList(IFdoReferenceSequence <ICmObject> list, ILexEntry entry)
        {
            var objsToRemove = new List <ICmObject>();

            foreach (var item in list)
            {
                if ((item as ILexEntry) == entry)
                {
                    objsToRemove.Add(item);
                }
                else if (item is ILexSense && item.OwnerOfClass <ILexEntry>() == entry)
                {
                    objsToRemove.Add(item);
                }
            }
            foreach (var item in objsToRemove)
            {
                list.Remove(item);
            }
        }
		private int GetAffixSequenceContainingSlot(IMoInflAffixSlot slot, out IFdoReferenceSequence<IMoInflAffixSlot> seq, out int index)
		{
			index = m_template.PrefixSlotsRS.IndexOf(slot);
			if (index >= 0)
			{
				seq = m_template.PrefixSlotsRS;
				return MoInflAffixTemplateTags.kflidPrefixSlots;
			}
			else
			{
				index = m_template.SuffixSlotsRS.IndexOf(slot);
				if (index >= 0)
				{
					seq = m_template.SuffixSlotsRS;
					return MoInflAffixTemplateTags.kflidSuffixSlots;
				}
			}
			seq = null;
			return 0;
		}
		private bool SetEnabledIfFindSlotInSequence(IFdoReferenceSequence<IMoInflAffixSlot> slots, out bool fEnabled, bool bIsLeft)
		{
			var index = slots.IndexOf(m_obj as IMoInflAffixSlot);
			if (index >= 0)
			{	// it was found
				bool bAtEdge;
				if (bIsLeft)
					bAtEdge = (index == 0);
				else
					bAtEdge = (index == slots.Count - 1);
				if (bAtEdge || slots.Count == 1)
					fEnabled = false;  // Cannot move it left when it's at the left edge or there's only one
				else
					fEnabled = true;
				return true;
			}
			else
			{
				fEnabled = false;
				return false;
			}
		}
		private IPhFeatureConstraint RemoveFeatureConstraint(IFdoReferenceSequence<IPhFeatureConstraint> featConstrs, IFsFeatDefn feat)
		{
			var constrToRemove = GetFeatureConstraint(featConstrs, feat);
			if (constrToRemove != null)
				featConstrs.Remove(constrToRemove);
			return constrToRemove;
		}