本文整理汇总了C#中IVwSelection类的典型用法代码示例。如果您正苦于以下问题:C# IVwSelection类的具体用法?C# IVwSelection怎么用?C# IVwSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVwSelection类属于命名空间,在下文中一共展示了IVwSelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParaPropStores
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets an array of property stores, one for each paragraph in the given selection.
/// </summary>
/// <param name="vwsel">The selection.</param>
/// <param name="vqvps">The property stores.</param>
/// ------------------------------------------------------------------------------------
protected override void GetParaPropStores(IVwSelection vwsel,
out IVwPropertyStore[] vqvps)
{
if (m_fOverrideGetParaPropStores)
vqvps = new IVwPropertyStore[1];
else
base.GetParaPropStores(vwsel, out vqvps);
}
示例2: SelectionBeginningGrowToWord
/// <summary>
/// Return a word selection based on the beginning of the current selection.
/// Here the "beginning" of the selection is the offset corresponding to word order,
/// not the selection anchor.
/// </summary>
/// <returns>null if we couldn't handle the selection</returns>
private static IVwSelection SelectionBeginningGrowToWord(IVwSelection sel)
{
if (sel == null)
return null;
var sel2 = sel.EndBeforeAnchor ? sel.EndPoint(true) : sel.EndPoint(false);
if (sel2 == null)
return null;
var sel3 = sel2.GrowToWord();
return sel3;
}
示例3: AllTextSelInfo
/// <summary>
/// Get an array of SelLevInfo structs from the given selection.
/// </summary>
/// <param name="vwsel"></param>
/// <param name="cvsli"></param>
/// <param name="ihvoRoot"></param>
/// <param name="tagTextProp"></param>
/// <param name="cpropPrevious"></param>
/// <param name="ichAnchor"></param>
/// <param name="ichEnd"></param>
/// <param name="ws"></param>
/// <param name="fAssocPrev"></param>
/// <param name="ihvoEnd"></param>
/// <param name="ttp"></param>
/// <returns></returns>
public static SelLevInfo[] AllTextSelInfo(IVwSelection vwsel, int cvsli,
out int ihvoRoot, out int tagTextProp, out int cpropPrevious, out int ichAnchor,
out int ichEnd, out int ws, out bool fAssocPrev, out int ihvoEnd, out ITsTextProps ttp)
{
Debug.Assert(vwsel != null);
using (ArrayPtr rgvsliPtr = MarshalEx.ArrayToNative<SelLevInfo>(cvsli))
{
vwsel.AllTextSelInfo(out ihvoRoot, cvsli, rgvsliPtr,
out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
out ws, out fAssocPrev, out ihvoEnd, out ttp);
return MarshalEx.NativeToArray<SelLevInfo>(rgvsliPtr, cvsli);
}
}
示例4: HandleSelectionChange
protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew)
{
CheckDisposed();
if (m_handlingSelectionChanged)
return;
m_handlingSelectionChanged = true;
try
{
m_selectedSenseHvo = 0;
if (vwselNew == null)
return;
base.HandleSelectionChange(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;
}
}
示例5: SelPositionInfo
private IVwSelection m_sel; // the selection.
#endregion
/// ------------------------------------------------------------------------------------
/// <summary>
/// Construct and save info about selection at top left of rootSite.
/// </summary>
/// <param name="rootSite">rootSite</param>
/// ------------------------------------------------------------------------------------
public SelPositionInfo(SimpleRootSite rootSite)
{
m_rootSite = rootSite;
if (rootSite == null)
return;
int xdLeft = m_rootSite.ClientRectangle.X;
int ydTop = m_rootSite.ClientRectangle.Y;
Rectangle rcSrcRoot, rcDstRoot;
m_rootSite.GetCoordRects(out rcSrcRoot, out rcDstRoot);
m_sel = m_rootSite.RootBox.MakeSelAt(xdLeft + 1,ydTop + 1, rcSrcRoot, rcDstRoot, false);
if (m_sel != null)
{
bool fEndBeforeAnchor;
m_rootSite.SelectionRectangle(m_sel, out m_rcPrimaryOld, out fEndBeforeAnchor);
}
}
示例6: FindInDictionary
public void FindInDictionary(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess, IVwSelection sel)
{
using (FdoCache cache = new FdoCache(ode, mdc, oleDbAccess))
{
if (sel == null)
return;
IVwSelection sel2 = sel.EndPoint(false);
if (sel2 == null)
return;
IVwSelection sel3 = sel2.GrowToWord();
if (sel3 == null)
return;
ITsString tss;
int ichMin, ichLim, hvo, tag, ws;
bool fAssocPrev;
sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws);
sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws);
// TODO (TimS): need to supply help information (last 2 params)
LexEntryUi.DisplayOrCreateEntry(cache, hvo, tag, ws, ichMin, ichLim, null, null, null, string.Empty);
return;
}
}
示例7: OnProblemDeletion
/// <summary>
/// This handles deleting the "owning" sense or entry from a calendar type lex
/// reference by posting a message instead of simply removing the sense or entry from
/// the reference vector. This keeps things nice and tidy on the screen, and behaving
/// like users would (or ought to) expect. See LT-4114.
/// </summary>
/// <param name="sel"></param>
/// <param name="dpt"></param>
/// <returns></returns>
public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
VwDelProbType dpt)
{
CheckDisposed();
int cvsli;
int hvoObj;
if (!CheckForValidDelete(sel, out cvsli, out hvoObj))
{
return VwDelProbResponse.kdprAbort;
}
else if (hvoObj == m_hvoDisplayParent)
{
// We need to handle this the same way as the delete command in the slice menu,
// but can't do it directly because we've stacked up an undo handler.
m_mediator.PostMessage("DataTreeDelete", null);
return VwDelProbResponse.kdprDone;
}
else
{
return DeleteObjectFromVector(sel, cvsli, hvoObj);
}
}
示例8: HandleSelectionChange
/// -----------------------------------------------------------------------------------
/// <summary>
/// Handle a selection changed event.
/// </summary>
/// <param name="rootb">root box that has the selection change</param>
/// <param name="vwselNew">Selection</param>
/// -----------------------------------------------------------------------------------
protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew)
{
CheckDisposed();
base.HandleSelectionChange(rootb, vwselNew);
// It's possible that the base either changed the selection or invalidated it in
// calling commit and made this selection no longer useable.
SelectionHelper helper = EditingHelper.CurrentSelection;
if (helper == null || !helper.Selection.IsValid)
return;
// scroll the footnote pane to be in synch with the draft view
// (TimS): Focused was taken out because it was causing selection changes that
// happended from a menu item wouldn't scroll to the footnote.
if (TheDraftViewWrapper != null && TheDraftViewWrapper.FootnoteViewShowing &&
Options.FootnoteSynchronousScrollingSetting)
{
// For performance on typing, don't try to scroll footnote pane on every update
SelLevInfo paraInfo;
if (helper.GetLevelInfoForTag(StTextTags.kflidParagraphs, out paraInfo))
{
IStTxtPara para = m_fdoCache.ServiceLocator.GetInstance<IStTxtParaRepository>().GetObject(paraInfo.hvo);
ITsString tss = para.Contents;
if (helper.IchAnchor <= tss.Length)
{
int iRun = (helper.IchAnchor >= 0) ? tss.get_RunAt(helper.IchAnchor) : -1;
if (iRun != -1 && (m_prevSelectedParagraph != paraInfo.hvo ||
iRun != m_prevAnchorPosition))
{
SynchFootnoteView(helper);
// Save selection information
m_prevSelectedParagraph = paraInfo.hvo;
m_prevAnchorPosition = iRun;
}
}
}
}
// Debug code was taken out. It was put in to help with testing using TestLangProj.
// Most of our tests are using the InMemoryCache so this information is almost useless.
// If you need it, just change the "DEBUG_not_exist" to "DEBUG" and then compile.
#region Debug code
#if DEBUG_not_exist
// This section of code will display selection information in the status bar when the
// program is compiled in Debug mode. The information shown in the status bar is useful
// when you want to make selections in tests.
try
{
string text;
SelLevInfo paraInfo = helper.GetLevelInfoForTag(StTextTags.kflidParagraphs);
SelLevInfo secInfo = helper.GetLevelInfoForTag(ScrBookTags.kflidSections);
SelLevInfo bookInfo = helper.GetLevelInfoForTag(BookFilter.Tag);
bool inBookTitle = TeEditingHelper.InBookTitle;
bool inSectionHead = TeEditingHelper.InSectionHead;
text = "Book: " + bookInfo.ihvo +
" Section: " + (inBookTitle ? "Book Title" : secInfo.ihvo.ToString()) +
" Paragraph: " + paraInfo.ihvo +
" Anchor: " + helper.IchAnchor + " End: " + helper.IchEnd +
" AssocPrev: " + helper.AssocPrev;
if (!inBookTitle && bookInfo.ihvo >= 0)
{
IStTxtPara para = m_fdoCache.ServiceLocator.GetInstance<IStTxtParaRepository>().GetObject(paraInfo.hvo);
ITsString tss = para.Contents;
if (helper.IchAnchor <= tss.Length)
text += " Run No.: " + tss.get_RunAt(helper.IchAnchor);
}
if (TheMainWnd != null)
TheMainWnd.StatusStrip.Items[0].Text = text;
}
catch
{
}
#endif
#endregion
}
示例9: GetSandboxSelLocation
/// summary>
/// Get the location of the given selection, presumably that of a Sandbox.
/// /summary>
Point GetSandboxSelLocation(IVwSelection sel)
{
Debug.Assert(sel != null);
Rect rcPrimary = GetPrimarySelRect(sel);
// The location includes margins, so for RTL we need to adjust the
// Sandbox so it isn't hard up against the next word.
// Enhance JohnT: ideally we would probably figure this margin
// to exactly match the margin between words set by the VC.
int left = rcPrimary.left;
if (m_vc.RightToLeft)
left += 8;
return new Point(left, rcPrimary.top);
}
示例10: HandleClickSelection
/// <summary>
/// Handles a view selection produced by a click. Return true to suppress normal
/// mouse down handling, indicating that an interlinear bundle has been clicked and the Sandbox
/// moved.
/// </summary>
/// <param name="vwselNew"></param>
/// <param name="fBundleOnly"></param>
/// <param name="fSaveGuess">if true, saves guesses; if false, skips guesses but still saves edits.</param>
/// <returns></returns>
protected virtual bool HandleClickSelection(IVwSelection vwselNew, bool fBundleOnly, bool fSaveGuess)
{
if (vwselNew == null)
return false; // couldn't select a bundle!
// The basic idea is to find the level at which we are displaying the TagAnalysis property.
int cvsli = vwselNew.CLevels(false);
cvsli--; // CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
// Out variables for AllTextSelInfo.
int ihvoRoot;
int tagTextProp;
int cpropPrevious;
int ichAnchor;
int ichEnd;
int ws;
bool fAssocPrev;
int ihvoEnd;
ITsTextProps ttpBogus;
// Main array of information retrived from sel that made combo.
SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(vwselNew, cvsli,
out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
if (tagTextProp == SegmentTags.kflidFreeTranslation || tagTextProp == SegmentTags.kflidLiteralTranslation
|| tagTextProp == NoteTags.kflidContent)
{
bool fWasFocusBoxInstalled = IsFocusBoxInstalled;
Rect oldSelLoc = GetPrimarySelRect(vwselNew);
if (!fBundleOnly)
{
if (IsFocusBoxInstalled)
FocusBox.UpdateRealFromSandbox(null, fSaveGuess, null);
TryHideFocusBoxAndUninstall();
}
// If the selection resulting from the click is still valid, and we just closed the focus box, go ahead and install it;
// continuing to process the click may not produce the intended result, because
// removing the focus box can re-arrange things substantially (LT-9220).
// (However, if we didn't change anything it is necesary to process it normally, otherwise, dragging
// and shift-clicking in the free translation don't work.)
if (!vwselNew.IsValid || !fWasFocusBoxInstalled)
return false;
// We have destroyed a focus box...but we may not have moved the free translation we clicked enough
// to cause problems. If not, we'd rather do a normal click, because installing a selection that
// the root box doesn't think is from mouse down does not allow dragging.
Rect selLoc = GetPrimarySelRect(vwselNew);
if (selLoc.top == oldSelLoc.top)
return false;
//The following line could quite possibly invalidate the selection as in the case where it creates
//a translation prompt.
vwselNew.Install();
//scroll the current selection into view (don't use vwselNew, it might be invalid now)
ScrollSelectionIntoView(this.RootBox.Selection, VwScrollSelOpts.kssoDefault);
return true;
}
// Identify the analysis, and the position in m_rgvsli of the property holding it.
// It is also possible that the analysis is the root object.
// This is important because although we are currently displaying just an StTxtPara,
// eventually it might be part of a higher level structure. We want to be able to
// reproduce everything that gets us down to the analysis.
int itagAnalysis = -1;
for (int i = rgvsli.Length; --i >= 0; )
{
if (rgvsli[i].tag == SegmentTags.kflidAnalyses)
{
itagAnalysis = i;
break;
}
}
if (itagAnalysis < 0)
{
if (!fBundleOnly)
{
if (IsFocusBoxInstalled)
FocusBox.UpdateRealFromSandbox(null, fSaveGuess, null);
TryHideFocusBoxAndUninstall();
}
return false; // Selection is somewhere we can't handle.
}
int ianalysis = rgvsli[itagAnalysis].ihvo;
Debug.Assert(itagAnalysis < rgvsli.Length - 1); // Need different approach if the analysis is the root.
int hvoSeg = rgvsli[itagAnalysis + 1].hvo;
var seg = Cache.ServiceLocator.GetObject(hvoSeg) as ISegment;
Debug.Assert(seg != null);
// If the mouse click lands on a punctuation form, move to the preceding
// wordform (if any). See FWR-815.
while (seg.AnalysesRS[ianalysis] is IPunctuationForm && ianalysis > 0)
--ianalysis;
if (ianalysis == 0 && seg.AnalysesRS[0] is IPunctuationForm)
//.........这里部分代码省略.........
示例11: GetTagAndObjForOnePropSelection
/// <summary>
/// Answer true if the indicated selection is within a single note we can delete. Also obtain
/// the object and property.
/// </summary>
private bool GetTagAndObjForOnePropSelection(IVwSelection sel, out int hvoObj, out int tagAnchor)
{
hvoObj = tagAnchor = 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, 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
hvoObj = hvoAnchor;
return true;
}
示例12: DeleteNote
private void DeleteNote(IVwSelection sel)
{
int hvoNote;
if (!CanDeleteNote(sel, out hvoNote))
return;
var note = Cache.ServiceLocator.GetInstance<INoteRepository>().GetObject(hvoNote);
var segment = (ISegment)note.Owner;
segment.NotesOS.Remove(note);
}
示例13: HandleClickSelection
/// <summary>
/// Suppress the special behavior that produces a Sandbox when a click happens.
/// </summary>
/// <param name="vwselNew"></param>
/// <param name="fBundleOnly"></param>
/// <param name="fConfirm"></param>
protected override bool HandleClickSelection(IVwSelection vwselNew, bool fBundleOnly, bool fConfirm)
{
return false;
}
示例14: GetSelLevInfoFromSelection
/// <summary>
/// Gets the sel lev info from selection.
/// </summary>
/// <param name="vwsel">The vwsel.</param>
/// <returns></returns>
private SelLevInfo[] GetSelLevInfoFromSelection(IVwSelection vwsel)
{
SelectionHelper helper = SelectionHelper.Create(vwsel, this);
if (helper == null)
return null;
return helper.LevelInfo;
}
示例15: SelectionChanged
public override void SelectionChanged(IVwRootBox rootb, IVwSelection vwselNew)
{
CheckDisposed();
if (vwselNew == null)
return;
bool hasFoc = Focused;
base.SelectionChanged(rootb, vwselNew);
ITsString tss;
int ichAnchor;
bool fAssocPrev;
int hvoObj;
int tag;
int ws; // NB: This will be 0 after each call, since the string does
// not have alternatives. Ws would be the WS of an alternative,
// if there were any.
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)
{
CheckHeight();
return;
}
if (m_hvoOldSelection > 0 && hvoObj != m_hvoOldSelection)
{
// Try to validate previously selected string rep.
if (m_silCache.get_StringProp(m_hvoOldSelection, kEnvStringRep).Length==0)
{
// Remove it from the dummy cache, since its length is 0.
int limit = m_silCache.get_VecSize(m_rootObj.Hvo, kMainObjEnvironments);
for (int i = 0; i < limit; ++i)
{
if (m_hvoOldSelection ==
m_silCache.get_VecItem(m_rootObj.Hvo, kMainObjEnvironments, i))
{
RemoveFromDummyCache(i);
break;
}
}
}
else // Validate previously selected string rep.
{
ValidateStringRep(m_hvoOldSelection);
}
}
if (hvoObj != kDummyPhoneEnvID)
{
m_hvoOldSelection = hvoObj;
CheckHeight();
return;
}
if (tss.Length == 0)
{
CheckHeight();
return;
}
// Create a new object, and recreate a new empty object. Make this part of the Undo
// Task with the character we typed.
m_silCache.GetActionHandler().ContinueUndoTask();
int count = m_silCache.get_VecSize(m_rootObj.Hvo, kMainObjEnvironments);
int hvoNew = InsertNewEnv(count - 1);
m_silCache.SetString(hvoNew, kEnvStringRep, tss);
m_silCache.SetString(kDummyPhoneEnvID, kEnvStringRep, DummyString);
m_silCache.EndUndoTask();
// Refresh
m_silCache.PropChanged(null, (int)PropChangeType.kpctNotifyAll,
m_rootObj.Hvo, kMainObjEnvironments, count - 1, 2, 1);
// Reset selection.
SelLevInfo[] rgvsli = new SelLevInfo[1];
rgvsli[0].cpropPrevious = 0;
rgvsli[0].tag = kMainObjEnvironments;
rgvsli[0].ihvo = count - 1;
m_rootb.MakeTextSelection(0, rgvsli.Length, rgvsli, tag, 0, ichAnchor, ichEnd, ws,
fAssocPrev, -1, null, true);
m_hvoOldSelection = hvoNew;
CheckHeight();
}