当前位置: 首页>>代码示例>>C#>>正文


C# IVwSelection.TextSelInfo方法代码示例

本文整理汇总了C#中IVwSelection.TextSelInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IVwSelection.TextSelInfo方法的具体用法?C# IVwSelection.TextSelInfo怎么用?C# IVwSelection.TextSelInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVwSelection的用法示例。


在下文中一共展示了IVwSelection.TextSelInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectionChanged

			public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew)
			{
				CheckDisposed();
				ITsString tssTyped;
				int ich, hvo, tag, ws;
				bool fAssocPrev;
				vwselNew.TextSelInfo(false, out tssTyped, out ich, out fAssocPrev, out hvo, out tag, out ws);
				base.SelectionChanged(prootb, vwselNew);
				if (tssTyped.Length != 0)
				{
					// user typed something in the dummy slice! Make a real object.
					// Save information required for RestoreSelection. MakeRealObject may well dispose this.
					System.Windows.Forms.Application.Idle += new EventHandler(Application_Idle);
				}
			}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:GhostStringSlice.cs

示例2: SelIPInVerseNumber

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If selection is a simple IP, check current run or runs on either side (if between
		/// runs). If run(s) is/are a verse number run, return true.
		/// </summary>
		/// <param name="vwsel">selection to check</param>
		/// <returns>True if IP is in or next to a verse number run</returns>
		/// ------------------------------------------------------------------------------------
		private bool SelIPInVerseNumber(IVwSelection vwsel)
		{
			if (vwsel.IsRange)
				return false;
			ITsString tss;
			int ich, hvo, tag, ws, ichMin, ichLim;
			bool fAssocPrev;
			vwsel.TextSelInfo(true, out tss, out ich, out fAssocPrev, out hvo, out tag, out ws);
			return InReference(tss, ich, false, out ichMin, out ichLim);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:18,代码来源:TeEditingHelper.cs

示例3: ValidToReplaceSelWithTss

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the given TsString can be pasted in the context of the target
		/// selection. An old DN-style embedded picture can only be pasted into paragraph
		/// contents.
		/// </summary>
		/// <param name="vwselTargetLocation">selection to be replaced by paste operation</param>
		/// <param name="tss">The TsString from the clipboard</param>
		/// <returns><c>true</c> if the given string does not contain any embedded strings or if
		/// the target location is a paragraph contents field.</returns>
		/// ------------------------------------------------------------------------------------
		protected override bool ValidToReplaceSelWithTss(IVwSelection vwselTargetLocation, ITsString tss)
		{
			// REVIEW (EberhardB): Do we still support DN-style embedded pictures?
			//+ Begin fix for Raid bug 897B
			// Check for an embedded picture.
			int crun = tss.RunCount;
			bool fHasPicture = false;
			ITsTextProps ttp;
			for (int irun = 0; irun < crun; ++irun)
			{
				ttp = tss.get_Properties(irun);
				string str = ttp.GetStrPropValue((int)FwTextStringProp.kstpObjData);
				if (str != null)
				{
					char chType = str[0];
					if (chType == (int)FwObjDataTypes.kodtPictOddHot ||
						chType == (int)FwObjDataTypes.kodtPictEvenHot)
					{
						fHasPicture = true;
						break;
					}
				}
			}

			if (fHasPicture)
			{
				// Vars to call TextSelInfo and find out whether it is a structured
				// text field.
				ITsString tssDummy;
				int ich;
				bool fAssocPrev;
				int hvoObj;
				int tag;
				int wsTmp;
				vwselTargetLocation.TextSelInfo(false, out tssDummy, out ich, out fAssocPrev,
					out hvoObj, out tag, out wsTmp);
				if (tag != StTxtParaTags.kflidContents)
				{
					// TODO (EberhardB): This seems to be Notebook specific!
					MessageBox.Show(ResourceHelper.GetResourceString("kstidPicsMultiPara"));
					return false;
				}
			}
			//- End fix for Raid bug 897B
			return base.ValidToReplaceSelWithTss(vwselTargetLocation, tss);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:57,代码来源:FwEditingHelper.cs

示例4: HandleSelectionChange

			protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew)
			{
				CheckDisposed();
				ITsString tssTyped;
				int ich, hvo, tag, ws;
				bool fAssocPrev;
				vwselNew.TextSelInfo(false, out tssTyped, out ich, out fAssocPrev, out hvo, out tag, out ws);
				base.HandleSelectionChange(prootb, vwselNew);
				if (tssTyped.Length != 0)
				{
					// user typed something in the dummy slice! Make a real object.
					// Save information required for RestoreSelection. MakeRealObject may well dispose this.
					m_mediator.IdleQueue.Add(IdleQueuePriority.High, SwitchToRealOnIdle);
				}
			}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:15,代码来源:GhostStringSlice.cs

示例5: GetSelectedStringRep

		/// <summary>
		/// Get the string representation of the current selection in the environment list,
		/// plus the selection object and some of its internal information.
		/// </summary>
		/// <param name="tss"></param>
		/// <param name="vwsel"></param>
		/// <param name="hvoDummyObj"></param>
		/// <param name="ichAnchor"></param>
		/// <param name="ichEnd"></param>
		/// <returns>false if selection spans two or more objects, true otherwise</returns>
		internal bool GetSelectedStringRep(out ITsString tss, out IVwSelection vwsel,
			out int hvoDummyObj, out int ichAnchor, out int ichEnd)
		{
			CheckDisposed();
			tss = null;
			vwsel = null;
			hvoDummyObj = 0;
			ichAnchor = 0;
			ichEnd = 0;
			try
			{
				ITsString tss2;
				bool fAssocPrev;
				int hvoObjEnd;
				int tag1;
				int tag2;
				int ws1;
				int ws2;
				vwsel = m_rootb.Selection;
				vwsel.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoDummyObj,
					out tag1, out ws1);
				vwsel.TextSelInfo(true, out tss2, out ichEnd, out fAssocPrev, out hvoObjEnd,
					out tag2, out ws2);
				if (hvoDummyObj != hvoObjEnd)
					return false;
			}
			catch
			{
				vwsel = null;
				tss = null;
				return true;
			}
			return true;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:44,代码来源:PhoneEnvReferenceView.cs

示例6: DoContextMenu

 protected override bool DoContextMenu(IVwSelection sel, Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot)
 {
     int hvo, tag, ihvo, cpropPrevious;
     IVwPropertyStore propStore;
     sel.PropInfo(false, 0, out hvo, out tag, out ihvo, out cpropPrevious, out propStore);
     string nodePath = null;
     if (propStore != null)
     {
         nodePath = propStore.get_StringProperty((int) FwTextPropType.ktptBulNumTxtBef);
     }
     if (string.IsNullOrEmpty(nodePath))
     {
         if (sel.SelType == VwSelType.kstPicture)
             return true;
         // may be a literal string, where we can get it from the string itself.
         ITsString tss;
         int ich, ws;
         bool fAssocPrev;
         sel.TextSelInfo(false, out tss, out ich, out fAssocPrev, out hvo, out tag, out ws);
         nodePath = tss.get_Properties(0).GetStrPropValue((int) FwTextPropType.ktptBulNumTxtBef);
     }
     if (m_configObjectName == null)
         m_configObjectName = XmlUtils.GetLocalizedAttributeValue(
             Mediator.StringTbl, m_xnSpec, "configureObjectName", null);
     string label;
     if (string.IsNullOrEmpty(nodePath))
         label = String.Format(xWorksStrings.ksConfigure, m_configObjectName);
     else
         label = String.Format(xWorksStrings.ksConfigureIn, nodePath.Split(':')[3], m_configObjectName);
     m_contextMenu = new ContextMenuStrip();
     var item = new ToolStripMenuItem(label);
     m_contextMenu.Items.Add(item);
     item.Click += RunConfigureDialogAt;
     item.Tag = nodePath;
     m_contextMenu.Show(this, pt);
     m_contextMenu.Closed += m_contextMenu_Closed;
     return true;
 }
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:38,代码来源:RecordDocView.cs

示例7: HandleSelectionChange

		// Handles a change in the view selection.
		protected override void HandleSelectionChange(IVwSelection vwselNew)
		{
			base.HandleSelectionChange(vwselNew);
			// Figure what property is selected and display combo only if relevant.
			SIL.FieldWorks.Common.COMInterfaces.ITsString tss;
			int ich, tag, enc;
			bool fAssocPrev;
			vwselNew.TextSelInfo(true, out tss, out ich, out fAssocPrev, out hvoObjSelected, out tag, out enc);
			string str = tss.get_Text();
			if (tag == ktagWord_Type)
			{
				// Display combo at selection
				SIL.FieldWorks.Common.COMInterfaces.Rect loc;
				vwselNew.GetParaLocation(out loc);
				typeComboBox.Location = new System.Drawing.Point(loc.left, loc.top);
				// 60 is an arbitrary minimum size to make the current contents visible.
				// Enhance JohnT: figure the width needed by the widest string, add width of arrow, use that
				// as minimum
				typeComboBox.Size = new System.Drawing.Size(Math.Max(loc.right - loc.left, 60), loc.bottom - loc.top);
				typeComboBox.Text = str;
				// This also makes it visible.
				this.Controls.Add(typeComboBox);
			}
			else
			{
				// Hide combo if visible.
				// Enhance JohnT: possibly also remove on loss of focus?
				if (this.Controls.Contains(typeComboBox))
				{
					this.Controls.Remove(typeComboBox);
				}
			}
			// Todo JohnT: make something interesting happen when a selection is made.
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:35,代码来源:InterlinearView.cs

示例8: SelectionChanged

			public override void SelectionChanged(IVwRootBox rootb, IVwSelection vwselNew)
			{
				CheckDisposed();

				if (vwselNew == null)
					return;

				base.SelectionChanged(rootb, vwselNew);

				ITsString tss;
				int ichAnchor;
				bool fAssocPrev;
				int hvoObj;
				int tag;
				int ws;
				vwselNew.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoObj, out tag, out ws);
				int ichEnd;
				int hvoObjEnd;
				vwselNew.TextSelInfo(true, out tss, out ichEnd, out fAssocPrev, out hvoObjEnd, out tag, out ws);
				if (hvoObjEnd != hvoObj)
				{
					// Can't do much with a multi-object selection.
					CheckHeight();
					return;
				}

				// The next level out in the view should be the entry in the index.
				int hvoIndex, ihvoEntry, cpropPrevious, tagEntry;
				IVwPropertyStore vps;
				vwselNew.PropInfo(false, 1, out hvoIndex, out tagEntry, out ihvoEntry, out cpropPrevious, out vps);
				// And the next one is the relevant index.
				int hvoSense, tagIndex, ihvoIndex;
				vwselNew.PropInfo(false, 2, out hvoSense, out tagIndex, out ihvoIndex, out cpropPrevious, out vps);

				int count = m_silCache.get_VecSize(hvoIndex, kFlidEntries);
				int lastEntryHvo = m_silCache.get_VecItem(hvoIndex, kFlidEntries, count - 1);

				//string oldForm = m_silCache.get_UnicodeProp(m_hvoOldSelection, (int)ReversalIndexEntry.ReversalIndexEntryTags.kflidForm);
				string oldForm = null;
				int wsIndex = m_silCache.get_IntProp(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
				ITsString tssEntry = m_silCache.get_MultiStringAlt(m_hvoOldSelection,
					(int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm, wsIndex);
				if (tssEntry != null)
					oldForm = tssEntry.Text;
				if (m_hvoOldSelection != 0
					&& hvoObj != m_hvoOldSelection
					&& (oldForm == null || oldForm.Length  == 0))
				{
					// Remove the old string from the dummy cache, since its length is 0.
					for (int i = 0; i < count; ++i)
					{
						if (m_hvoOldSelection == m_silCache.get_VecItem(hvoIndex, kFlidEntries, i))
						{
							RemoveFromDummyCache(hvoIndex, i);
							break;
						}
					}
				}
				// If it's not the last index in the list, we can just go on editing it.
				if (hvoObj != lastEntryHvo)
				{
					m_hvoOldSelection = hvoObj;
					CheckHeight();
					return;
				}
				// Even if it's the last object, if it's empty we don't need to do anything.
				if (tss.Length == 0)
				{
					CheckHeight();
					return;
				}
				// Create a new object, and recreate a new empty object.
				count = m_silCache.get_VecSize(hvoIndex, kFlidEntries);
				// Assign a new dummy ID.
				m_dummyId--;
				// Insert it at the end of the list.
				m_vwCache.CacheReplace(hvoIndex, kFlidEntries, count, count, new int[] {m_dummyId}, 1);
				Cache.EnableUndo = false;	// Things have changed in a way we can't Undo.
				// Set its 'form' to be an empty string in the appropriate writing system.
				ITsTextProps props = tss.get_PropertiesAt(0);
				int nVar;
				ws = props.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
				//m_vwCache.CacheUnicodeProp(m_dummyId, (int)ReversalIndexEntry.ReversalIndexEntryTags.kflidForm, String.Empty, 0);
				//m_vwCache.CacheIntProp(m_dummyId, (int)ReversalIndexEntry.ReversalIndexEntryTags.kflidWritingSystem, ws);
				ITsString tssEmpty = m_tsf.MakeString("", ws);
				m_vwCache.CacheStringAlt(m_dummyId, (int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm,
					ws, tssEmpty);
				// Refresh
				m_silCache.PropChanged(null, (int)PropChangeType.kpctNotifyAll,
					hvoIndex, kFlidEntries, count, 1, 0);

				// Reset selection.
				SelLevInfo[] rgvsli = new SelLevInfo[2];
				rgvsli[0].cpropPrevious = 0;
				rgvsli[0].tag = kFlidEntries;
				rgvsli[0].ihvo = count - 1;
				rgvsli[1].cpropPrevious = 0;
				rgvsli[1].tag = kFlidIndices;
				rgvsli[1].ihvo = ihvoIndex;
				try
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:ReversalIndexEntrySlice.cs

示例9: CanDeleteFF

		/// <summary>
		///  Answer true if the indicated selection is within a single freeform annotation we can delete.
		/// </summary>
		/// <param name="sel"></param>
		/// <returns></returns>
		private bool CanDeleteFF(IVwSelection sel, out int hvoAnnotation)
		{
			hvoAnnotation = 0;
			if (sel == null)
				return false;
			ITsString tss;
			int ichEnd, hvoEnd, tagEnd, wsEnd;
			bool fAssocPrev;
			sel.TextSelInfo(true, out tss, out ichEnd, out fAssocPrev, out hvoEnd, out tagEnd, out wsEnd);
			int ichAnchor, hvoAnchor, tagAnchor, wsAnchor;
			sel.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoAnchor, out tagAnchor, out wsAnchor);
			if (hvoEnd != hvoAnchor || tagEnd != tagAnchor || wsEnd != wsAnchor)
				return false; // must be a one-property selection
			if (tagAnchor != (int)CmAnnotation.CmAnnotationTags.kflidComment)
				return false; // must be a selection in a freeform annotation.
			hvoAnnotation = hvoAnchor;
			return true;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:23,代码来源:InterlinDocView.cs

示例10: HandleSelectionChange

		/// <summary>
		/// This is a demonstration of one way to handle special tricks as the user types.
		/// This is an oversimplified way of forcing numbers to be treated as verse numbers...
		/// for example, it will cause '5000' in the 'feeding of the 5000' to be treated as a verse number.
		/// </summary>
		/// <param name="vwselNew"></param>
		protected override void HandleSelectionChange(IVwSelection vwselNew)
		{
			base.HandleSelectionChange (vwselNew);
			if (vwselNew == null)
				return; // Not sure whether this happens, but best to be sure.

			int ichSel, hvoObj, tag, ws;
			bool fAssocPrev;
			ITsString tss;
			vwselNew.TextSelInfo(false, out tss, out ichSel, out fAssocPrev, out hvoObj, out tag, out ws);

			string text = tss.get_Text();
			if (text == null)
				return; // empty string.
			ITsStrBldr tsb = null;
			for (int ich = 0; ich < text.Length; ++ich)
			{
				if (Char.IsDigit(text[ich]))
				{
					ITsTextProps ttp = tss.get_PropertiesAt(ich);
					string styleName = ttp.GetStrPropValue((int)FwKernelLib.FwTextPropType.ktptNamedStyle);
					if (styleName != "verseNumber")
					{
						// We'll change just this one character. We could make this more efficient for dealing with
						// long strings of digits, but it's unlikely we'll ever have to deal with more than one.
						if (tsb == null)
							tsb = tss.GetBldr();
						tsb.SetStrPropValue(ich, ich + 1, (int)FwKernelLib.FwTextPropType.ktptNamedStyle, "verseNumber");
					}
				}
			}
			if (tsb != null)
			{
				ISilDataAccess sda = m_rootb.get_DataAccess();
				// In this sample the only string is a multistring. If in doubt, we could test for ws == 0 to
				// see whether it is a simple string.
				sda.SetMultiStringAlt(hvoObj, tag, ws, tsb.GetString());
				sda.PropChanged(null, (int)FwViews.PropChangeType.kpctNotifyAll, hvoObj, tag, 0, tss.get_Length(), tss.get_Length());
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:46,代码来源:ViewSampleView.cs

示例11: SelectionChanged

		public override void SelectionChanged(IVwRootBox rootb, IVwSelection vwselNew)
		{
			CheckDisposed();

			if (m_handlingSelectionChanged)
				return;

			m_handlingSelectionChanged = true;
			try
			{
				m_selectedSenseHvo = 0;
				if (vwselNew == null)
					return;
				base.SelectionChanged(rootb, vwselNew);

				// Get the Id of the selected snes, and store it.
				int cvsli = vwselNew.CLevels(false);
				// CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
				cvsli--;
				if (cvsli == 0)
				{
					// No objects in selection: don't allow a selection.
					m_rootb.DestroySelection();
					// Enhance: invoke launcher's selection dialog.
					return;
				}
				ITsString tss;
				int ichAnchor;
				int ichEnd;
				bool fAssocPrev;
				int hvoObj;
				int hvoObjEnd;
				int tag;
				int ws;
				vwselNew.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoObj,
					out tag, out ws);
				vwselNew.TextSelInfo(true, out tss, out ichEnd, out fAssocPrev, out hvoObjEnd,
					out tag, out ws);
				if (hvoObj != hvoObjEnd)
					return;
				m_selectedSenseHvo = hvoObj;
			}
			finally
			{
				m_handlingSelectionChanged = false;
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:47,代码来源:RevEntrySensesCollectionReferenceView.cs

示例12: GetInfoForJumpToTool

		/// <summary>
		/// Given a selection (typically from a click), determine the object that should be the target for jumping to,
		/// and return the property that was clicked (which in the case of a right-click may generate a spelling menu instead).
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="hvoReal"></param>
		/// <returns></returns>
		private int GetInfoForJumpToTool(IVwSelection sel, out int hvoReal)
		{
			int ws;
			int tagRightClickTextProp;
			bool fAssocPrev;
			ITsString tss;
			int ichAnchorDum;
			int hvoRightClickObject = 0;
			sel.TextSelInfo(false, out tss, out ichAnchorDum, out fAssocPrev,
				out hvoRightClickObject, out tagRightClickTextProp, out ws);
			switch (tagRightClickTextProp)
			{
				case ktagSbMorphPrefix:
				case ktagSbMorphPostfix:
					m_hvoRightClickMorph = hvoRightClickObject;
					// Pretend we clicked on the morph form.  (See LT-7590.)
					hvoRightClickObject = Caches.DataAccess.get_ObjectProp(hvoRightClickObject, ktagSbMorphForm);
					break;
				case ktagSbNamedObjName:
					if (sel.CLevels(false) < 2)
						break;
					int hvoOuterObj, tagOuter, ihvoOuter, cpropPreviousOuter;
					IVwPropertyStore vpsDummy;
					sel.PropInfo(false, 1, out hvoOuterObj, out tagOuter, out ihvoOuter, out cpropPreviousOuter, out vpsDummy);
					if (tagOuter == ktagSbMorphGloss || tagOuter == ktagSbMorphPos || tagOuter == ktagSbMorphForm
						|| tagOuter == ktagSbMorphEntry)
					{
						m_hvoRightClickMorph = hvoOuterObj;
					}
					break;
				default:
					m_hvoRightClickMorph = 0;
					break;
			}

			hvoReal = m_caches.RealHvo(hvoRightClickObject);
			return tagRightClickTextProp;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:45,代码来源:SandboxBase.cs

示例13: OnProblemDeletion

		/// <summary>
		/// Handle a problem deleting some selection in the sandbox. So far, the only cases we
		/// handle are backspace and delete merging morphemes.
		/// Enhance JohnT: could also handle deleting a range that merges morphemes.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
		{
			CheckDisposed();

			ITsString tss = null;
			bool fAssocPrev = false;
			int ichSel = -1;
			int hvoObj = 0;
			int tag = 0;
			int ws;
			sel.TextSelInfo(false, out tss, out ichSel, out fAssocPrev, out hvoObj, out tag, out ws);
			if (!m_editMonitor.IsPropMorphBreak(hvoObj, tag, ws))
				return VwDelProbResponse.kdprFail;
			switch (dpt)
			{
				case VwDelProbType.kdptBsAtStartPara:
				case VwDelProbType.kdptBsReadOnly:
					return m_editMonitor.HandleBackspace() ?
						VwDelProbResponse.kdprDone : VwDelProbResponse.kdprFail;
				case VwDelProbType.kdptDelAtEndPara:
				case VwDelProbType.kdptDelReadOnly:
					return m_editMonitor.HandleDelete() ?
						VwDelProbResponse.kdprDone : VwDelProbResponse.kdprFail;
				default:
					return VwDelProbResponse.kdprFail;
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:35,代码来源:SandboxBase.cs

示例14: SelectedObject

		/// <summary>
		/// Determine whether the current selection is at a place suitable for type-ahead. If not, answer 0.
		/// (In this case the values of hvoParent and ihvo should not be relied on.)
		/// If so, indicate the object whose property may be set by type-ahead (hvoParent), the object
		/// in the relevant property that is selected (return result), and its index within the property
		/// (0 if atomic).
		/// </summary>
		/// <param name="rootb"></param>
		/// <param name="sel"></param>
		/// <param name="hvoParent"></param>
		/// <param name="ihvo"></param>
		/// <returns></returns>
		private int SelectedObject(IVwRootBox rootb, IVwSelection sel, out int hvoParent, out int ihvo)
		{
			hvoParent = 0;
			ihvo = 0;
			if (rootb == null) // If we don't have a root box, can't do anything interesting.
				return 0;
			if (sel == null) // nothing interesting to do without a selection, either.
				return 0;
			ITsString tssA, tssE;
			int ichA, ichE, hvoObjA, hvoObjE, tagA, tagE, ws;
			bool fAssocPrev;
			// Enhance JohnT: what we're really trying to do here is confirm that the selection is
			// all in one string property. We could readily have a method in the selection interface to tell us that.
			sel.TextSelInfo(false, out tssA, out ichA, out fAssocPrev, out hvoObjA, out tagA, out ws);
			if (tagA != m_taTagName && tagA != m_snTagName)
				return 0; // selection not anchored in any sort of type-ahead name property.
			sel.TextSelInfo(true, out tssE, out ichE, out fAssocPrev, out hvoObjE, out tagE, out ws);
			int cch = tssA.Length;
			// To do our type-ahead trick, both ends of the seleciton must be in the same string property.
			// Also, we want the selection to extend to the end of the name.
			// Enhance JohnT: if we do a popup window, it may not matter whether the selection extends
			// to the end; just show items that match.
			if (tagE != tagA || hvoObjE != hvoObjA || cch != tssE.Length || Math.Max(ichA, ichE) != cch)
				return 0; // not going to attempt type-ahead behavior
			int clev = sel.CLevels(false);
			if (clev < 2)
				return 0; // can't be our property.
			int tagParent, cpropPrevious;
			IVwPropertyStore vps;
			sel.PropInfo(false, 1, out hvoParent, out tagParent, out ihvo, out cpropPrevious, out vps);
			if (tagParent != m_virtualTagObj)
				return 0; // not our virtual property!
			return hvoObjA;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:46,代码来源:TypeAheadSupportVc.cs

示例15: HandleSelectionChange

		protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew)
		{
			CheckDisposed();
			if (vwselNew == null)
				return;
			int cvsli = vwselNew.CLevels(false);
			// CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
			cvsli--;
			if (cvsli == 0)
			{
				// No objects in selection: don't allow a selection.
				m_rootb.DestroySelection();
				// Enhance: invoke launcher's selection dialog.
				return;
			}
			ITsString tss;
			int ichAnchor;
			int ichEnd;
			bool fAssocPrev;
			int hvoObj;
			int hvoObjEnd;
			int tag;
			int ws;
			vwselNew.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoObj,
				out tag, out ws);
			vwselNew.TextSelInfo(true, out tss, out ichEnd, out fAssocPrev, out hvoObjEnd,
				out tag, out ws);
			if (hvoObj != hvoObjEnd)
				return;

			int ihvoRoot;
			int tagTextProp;
			int cpropPrevious;
			int ihvoEnd;
			ITsTextProps ttp;
			SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(vwselNew, cvsli,
				out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
				out ws, out fAssocPrev, out ihvoEnd, out ttp);
			Debug.Assert(m_rootb != null);
			// Create a selection that covers the entire target object.  If it differs from
			// the new selection, we'll install it (which will recurse back to this method).
			IVwSelection vwselWhole = m_rootb.MakeTextSelInObj(ihvoRoot, cvsli, rgvsli, 0, null,
															   false, false, false, true, false);
			if (vwselWhole != null)
			{
				ITsString tssWhole;
				int ichAnchorWhole;
				int ichEndWhole;
				int hvoObjWhole;
				int hvoObjEndWhole;
				bool fAssocPrevWhole;
				int tagWhole;
				int wsWhole;
				vwselWhole.TextSelInfo(false, out tssWhole, out ichAnchorWhole,
					out fAssocPrevWhole, out hvoObjWhole, out tagWhole, out wsWhole);
				vwselWhole.TextSelInfo(true, out tssWhole, out ichEndWhole,
					out fAssocPrevWhole, out hvoObjEndWhole, out tagWhole, out wsWhole);
				if (hvoObj == hvoObjWhole && hvoObjEnd == hvoObjEndWhole &&
					(ichAnchor != ichAnchorWhole || ichEnd != ichEndWhole))
				{
					// Install it this time!
					m_rootb.MakeTextSelInObj(ihvoRoot, cvsli, rgvsli, 0, null,
						false, false, false, true, true);
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:66,代码来源:VectorReferenceView.cs


注:本文中的IVwSelection.TextSelInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。