ContainingObjectIndex() public method

ContainingObjectIndex info about anchor.
public ContainingObjectIndex ( int level ) : int
level int
return int
Esempio n. 1
0
		/// <summary>
		/// This override ensures that we always have whole objects selected.
		/// Enhance: it may cause flicker during drag, in which case, we may change to only do it on mouse up,
		/// or only IF the mouse is up.
		/// </summary>
		protected override void  HandleSelectionChange(object sender, VwSelectionArgs args)
		{
			if (m_InSelectionChanged || RootBox.Selection == null)
				return;
			TextSelInfo info = new TextSelInfo(RootBox);
			int end = Math.Max(info.ContainingObjectIndex(info.Levels(true) - 1, true),
				info.ContainingObjectIndex(info.Levels(false) - 1, false));
			int begin = Math.Min(info.ContainingObjectIndex(info.Levels(true) - 1, true),
				info.ContainingObjectIndex(info.Levels(false) - 1, false));
			SelectRange(begin, end);
		}
Esempio n. 2
0
		/// <summary>
		/// This override ensures that we always have whole objects selected.
		/// Enhance: it may cause flicker during drag, in which case, we may change to only do it on mouse up,
		/// or only IF the mouse is up.
		/// </summary>
		protected virtual void HandleSelectionChange(object sender, VwSelectionArgs args)
		{
			CheckDisposed();

			if (m_InSelectionChanged || RootBox.Selection == null)
				return;

			var info = new TextSelInfo(RootBox);
			var end = Math.Max(info.ContainingObjectIndex(info.Levels(true) - 1, true),
				info.ContainingObjectIndex(info.Levels(false) - 1, false));
			SelectUpTo(end);
		}
Esempio n. 3
0
		/// <summary>
		/// This override ensures that we always have whole objects selected.
		/// Enhance: it may cause flicker during drag, in which case, we may change to only do it on mouse up,
		/// or only IF the mouse is up.
		/// </summary>
		/// <param name="prootb"></param>
		/// <param name="vwselNew"></param>
		public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew)
		{
			base.SelectionChanged(prootb, vwselNew);
			if (m_InSelectionChanged)
				return;
			if (RootBox.Selection == null)
				return;
			TextSelInfo info = new TextSelInfo(RootBox);
			int end = Math.Max(info.ContainingObjectIndex(info.Levels(true) - 1, true),
				info.ContainingObjectIndex(info.Levels(false) - 1, false));
			int begin = Math.Min(info.ContainingObjectIndex(info.Levels(true) - 1, true),
				info.ContainingObjectIndex(info.Levels(false) - 1, false));
			SelectRange(begin, end);
		}
Esempio n. 4
0
		/// <summary>
		/// This override ensures that we always have whole objects selected.
		/// Enhance: it may cause flicker during drag, in which case, we may change to only do it on mouse up,
		/// or only IF the mouse is up.
		/// </summary>
		/// <param name="prootb"></param>
		/// <param name="vwselNew"></param>
		public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew)
		{
			base.SelectionChanged(prootb, vwselNew);
			if (m_InSelectionChanged)
				return;
			if (RootBox.Selection == null)
				return;
			if (!(this is DialogInterlinRibbon)) // We want the selection in the dialog to behave differently.
			{
				TextSelInfo info = new TextSelInfo(RootBox);
				int end = Math.Max(info.ContainingObjectIndex(info.Levels(true) - 1, true),
					info.ContainingObjectIndex(info.Levels(false) - 1, false));
				SelectUpTo(end);
			}
		}
Esempio n. 5
0
		private static int GetIndexOfTopLevelObject(TextSelInfo info, bool fEndPoint)
		{
			return info.ContainingObjectIndex(info.Levels(fEndPoint) - 1, fEndPoint);
		}
Esempio n. 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called when [delete record].
		/// </summary>
		/// <param name="commandObject">The command object.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public override bool OnDeleteRecord(object commandObject)
		{
			CheckDisposed();

			IVwSelection vwsel = m_rootb.Selection;
			if (vwsel == null)
				return false;
			ISilDataAccess sda = m_fdoCache.MainCacheAccessor;
			IVwCacheDa cda = m_fdoCache.MainCacheAccessor as IVwCacheDa;
			List<XmlNode> columns = m_xbvvc.ColumnSpecs;
			if (columns == null || columns.Count == 0)
				return false;		// Something is broken!

			TextSelInfo tsi = new TextSelInfo(m_rootb.Selection);
			if (tsi.ContainingObject(0) == XmlRDEBrowseViewVc.khvoNewItem)
			{
				ClearColumnStringsFromNewRow();
			}
			else
			{
				// 1. Remove the domain from the sense shown in the second column.
				// 2. Delete the sense iff it is now empty except for the definition shown.
				// 3. Delete the entry iff the entry now has no senses.
#if false // JohnT: don't understand the following code at all. In particular it makes no sense
				// to use ihvoRoot to index rgvsli; ihvoRoot is always zero in this view, it has only one root.
				// Possibly this was an unsuccessful attempt to adapt some generic code I wrote to this
				// particular application involving senses and entries?
				// I'm leaving it in existence for now in case the original author turns up and
				// can explain what he was getting at.
				int cLevels = vwsel.get_BoxDepth(true);
				int iLevel;
				int cBoxes = -1;
				int iBox = -1;
				VwBoxType[] rgvbt = new VwBoxType[cLevels];
				VwBoxType vbt = VwBoxType.kvbtUnknown;
				for (iLevel = 0; iLevel < cLevels; ++iLevel)
				{
					vbt = vwsel.get_BoxType(false, iLevel);
					if (vbt == VwBoxType.kvbtTableCell)
					{
						cBoxes = vwsel.get_BoxCount(true, iLevel);
						iBox = vwsel.get_BoxIndex(true, iLevel);
						break;
					}
				}
				Debug.Assert(cBoxes == 2);
				Debug.Assert(iBox != -1);
				int hvoEntry;
				int hvoSense;
				if (iBox == 0)
				{
					hvoEntry = rgvsli[ihvoRoot].hvo;
					IVwSelection vwsel2 = m_rootb.MakeSelInBox(vwsel, false, iLevel, 1,
						true, false, false);
					SelLevInfo[] rgvsli2 = SelLevInfo.AllTextSelInfo(vwsel, vwsel2.CLevels(false) - 1,
						out ihvoRoot, out tag, out cpropPrevious, out ichAnchor, out ichEnd,
						out ws, out fAssocPrev, out ihvoEnd, out ttp);
					hvoSense = rgvsli2[ihvoRoot].hvo;
				}
				else
				{
					hvoSense = rgvsli[ihvoRoot].hvo;
					IVwSelection vwsel2 = m_rootb.MakeSelInBox(vwsel, false, iLevel, 0,
						true, false, false);
					SelLevInfo[] rgvsli2 = SelLevInfo.AllTextSelInfo(vwsel, vwsel2.CLevels(false) - 1,
						out ihvoRoot, out tag, out cpropPrevious, out ichAnchor, out ichEnd,
						out ws, out fAssocPrev, out ihvoEnd, out ttp);
					hvoEntry = rgvsli2[ihvoRoot].hvo;
				}
#else
				int cvsli = tsi.Levels(false) - 1;
				int ihvoRoot = tsi.ContainingObjectIndex(cvsli - 1);
				int tag = tsi.ContainingObjectTag(cvsli - 1);
				Debug.Assert(cvsli >= 1); // there should be at least one level (each row is a sense)
				// The outermost thing in the VC is a display of all the senses of the root domain.
				// Therefore the last thing in rgvsli is always the information identifying the sense we
				// want to process.
				int hvoSense = tsi.ContainingObject(cvsli - 1);
				int hvoEntry = m_fdoCache.GetOwnerOfObject(hvoSense);
#endif
				// If this was an editable object, it no longer is, because it's about to no longer exist.
				RDEVc.EditableObjectsRemove(hvoSense);

				ILexEntry le = LexEntry.CreateFromDBObject(m_fdoCache, hvoEntry);
				ILexSense ls = LexSense.CreateFromDBObject(m_fdoCache, hvoSense);
				string sUndo = XMLViewsStrings.ksUndoDeleteRecord;
				string sRedo = XMLViewsStrings.ksRedoDeleteRecord;
				using (new UndoRedoTaskHelper(Cache, sUndo, sRedo))
				{
					ls.SemanticDomainsRC.Remove(m_hvoRoot);
					if (ls.SemanticDomainsRC.Count == 0 &&
						ls.AnthroCodesRC.Count == 0 &&
						ls.AppendixesRC.Count == 0 &&
						ls.DomainTypesRC.Count == 0 &&
						ls.ThesaurusItemsRC.Count == 0 &&
						ls.UsageTypesRC.Count == 0)
					{
						bool fKeep = false;
						string s = ls.Gloss.AnalysisDefaultWritingSystem;
						if (s != null && s != "")
							fKeep = true;
						if (!fKeep)
						{
							s = ls.Gloss.UserDefaultWritingSystem;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.Gloss.VernacularDefaultWritingSystem;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.Definition.VernacularDefaultWritingSystem.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.DiscourseNote.AnalysisDefaultWritingSystem.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.DiscourseNote.UserDefaultWritingSystem.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.DiscourseNote.VernacularDefaultWritingSystem.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.ScientificName.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							s = ls.Source.Text;
							if (s != null && s != "")
								fKeep = true;
						}
						if (!fKeep)
						{
							le.SensesOS.Remove(hvoSense);
							ls = null;
						}
					}
					if (ls == null && le.SensesOS.Count == 0)
					{
						le.DeleteUnderlyingObject();
						le = null;
					}
				}
				sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll,
					hvoSense, tag, 0, 0, 1);
			}
			return true;
		}