本文整理汇总了C#中IVwSelection.PropInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IVwSelection.PropInfo方法的具体用法?C# IVwSelection.PropInfo怎么用?C# IVwSelection.PropInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwSelection
的用法示例。
在下文中一共展示了IVwSelection.PropInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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
//.........这里部分代码省略.........
示例3: GetSelectedFootnote
/// -----------------------------------------------------------------------------------
/// <summary>
/// Retrieves the flid and hvo corresponding to the current Scripture element (e.g., section
/// heading, section contents, or title) selected.
/// </summary>
/// <param name="vwsel">The current selection</param>
/// <param name="tag">The flid of the selected footnote</param>
/// <param name="hvoSel">The hvo of the selected footnote</param>
/// <returns>True, if a footnote is found at the current selection</returns>
/// -----------------------------------------------------------------------------------
protected bool GetSelectedFootnote(IVwSelection vwsel, out int tag, out int hvoSel)
{
hvoSel = 0;
tag = 0;
int hvoPrevLevel = 0;
int tagPrev = 0;
try
{
if (vwsel != null)
{
// If we look more than 10 levels then something is wrong.
for (int ilev = 0; ilev < 10; ilev++)
{
int ihvo, cpropPrev;
IVwPropertyStore qvps;
hvoPrevLevel = hvoSel;
tagPrev = tag;
vwsel.PropInfo(false, ilev, out hvoSel, out tag, out ihvo,
out cpropPrev, out qvps);
switch (tag)
{
case (int)ScrBook.ScrBookTags.kflidFootnotes:
{
hvoSel = hvoPrevLevel;
tag = tagPrev;
return true;
}
default:
break;
}
}
}
}
catch
{
}
return false;
}
示例4: SelectionChanged
/// -----------------------------------------------------------------------------------
/// <summary>
/// Notifies the site that something about the selection has changed.
/// </summary>
/// <param name="prootb"></param>
/// <param name="vwselNew">Selection</param>
/// <remarks>When overriding you should call the base class first.</remarks>
/// -----------------------------------------------------------------------------------
public override void SelectionChanged(IVwRootBox prootb, IVwSelection vwselNew)
{
CheckDisposed();
base.SelectionChanged(prootb, vwselNew);
if (vwselNew == null)
return;
int clev = vwselNew.CLevels(false); // anchor
int hvoRoot, tag, ihvo, cpropPrevious;
IVwPropertyStore vps;
vwselNew.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo,
out cpropPrevious, out vps);
Debug.Assert(hvoRoot == m_hvoRoot);
int hvoObjNewSel = m_fdoCache.MainCacheAccessor.get_VecItem(hvoRoot, tag, ihvo);
if (hvoObjNewSel != 0)
{
// Notify any delegates that the selection of the main object in the vector
// may have changed.
if (SelectionChangedEvent != null)
SelectionChangedEvent(this, new FwObjectSelectionEventArgs(hvoObjNewSel, ihvo));
}
}
示例5: GetRowIndexFromSelection
/// <summary>
/// Given a selection in the view, return the row index. Rarely may return -1 if unable to
/// identify a row.
/// </summary>
/// <param name="sel"></param>
/// <param name="fEndPoint">true to get index based on end of selection, false based on anchor.
/// deafault is true, so in a long drag we get the mouse-up row.</param>
/// <returns></returns>
internal int GetRowIndexFromSelection(IVwSelection sel, bool fEndPoint)
{
if (sel == null)
return -1;
try
{
int clev = sel.CLevels(fEndPoint);
int hvoRoot, tag, ihvo, cpropPrevious;
IVwPropertyStore vps;
sel.PropInfo(fEndPoint, clev - 1, out hvoRoot, out tag, out ihvo, out cpropPrevious, out vps);
if (tag != m_fakeFlid) // not sure how this could happen, but the precaution was in an earlier version.
return -1;
return ihvo;
}
catch (System.Runtime.InteropServices.COMException)
{
// This shouldn't happen, but don't let it be catastrophic if it does.
}
return -1;
}
示例6: DeleteFreeform
private bool DeleteFreeform(IVwSelection sel)
{
int hvoAnnotation;
if (!CanDeleteFF(sel, out hvoAnnotation))
return false;
int hvoSeg, tagFF, ihvoFF, cpropPrevious;
IVwPropertyStore vps;
// NOTE: Do not use ihvoFF for updating the cache directly, because the display vector indices
// does not necessarily correspond to the cache vector indices.
sel.PropInfo(false, 1, out hvoSeg, out tagFF, out ihvoFF, out cpropPrevious, out vps);
CmBaseAnnotation seg = new CmBaseAnnotation(Cache, hvoSeg);
CmIndirectAnnotation ft = new CmIndirectAnnotation(Cache, hvoAnnotation);
bool wasFt = ft.AnnotationTypeRAHvo == Cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation);
StTxtPara para = seg.BeginObjectRA as StTxtPara;
m_fdoCache.DeleteObject(hvoAnnotation);
m_fdoCache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoSeg, tagFF, ihvoFF, 0, 1);
if (wasFt && para != null)
FreeTransEditMonitor.UpdateMainTransFromSegmented(para, Cache.LangProject.CurAnalysisWssRS.HvoArray);
return true; // handled
}
示例7: 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;
}
示例8: 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;
}
示例9: HandleSelectionChange
/// -----------------------------------------------------------------------------------
/// <summary>
/// Notifies the site that something about the selection has changed.
/// </summary>
/// <param name="prootb"></param>
/// <param name="vwselNew">Selection</param>
/// <remarks>When overriding you should call the base class first.</remarks>
/// -----------------------------------------------------------------------------------
protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew)
{
CheckDisposed();
base.HandleSelectionChange(prootb, vwselNew);
if (vwselNew == null)
return;
int clev = vwselNew.CLevels(false); // anchor
int clevEnd = vwselNew.CLevels(true);
if (clev < 2 || clevEnd < 2)
return; // paranoia
int hvoRoot, tag, ihvo, ihvoEnd, cpropPrevious;
IVwPropertyStore vps;
vwselNew.PropInfo(true, clevEnd - 1, out hvoRoot, out tag, out ihvoEnd,
out cpropPrevious, out vps);
vwselNew.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo,
out cpropPrevious, out vps);
// Give up if the selection doesn't indicate any top-level object; I think this can happen with pictures.
// selection larger than a top-level object, maybe select all, side effects are confusing.
if (ihvo != ihvoEnd || ihvo < 0)
return;
if (hvoRoot == 0)
return;
Debug.Assert(hvoRoot == m_hvoRoot);
int hvoObjNewSel = m_sdaSource.get_VecItem(hvoRoot, tag, ihvo);
if (hvoObjNewSel != 0)
{
// Notify any delegates that the selection of the main object in the vector
// may have changed.
if (SelectionChangedEvent != null)
SelectionChangedEvent(this, new FwObjectSelectionEventArgs(hvoObjNewSel, ihvo));
}
}