本文整理汇总了C#中IVwSelection.Install方法的典型用法代码示例。如果您正苦于以下问题:C# IVwSelection.Install方法的具体用法?C# IVwSelection.Install怎么用?C# IVwSelection.Install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwSelection
的用法示例。
在下文中一共展示了IVwSelection.Install方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
//.........这里部分代码省略.........
示例2: 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 == (int)CmAnnotation.CmAnnotationTags.kflidComment)
{
bool fWasFocusBoxInstalled = IsFocusBoxInstalled;
Rect oldSelLoc = GetPrimarySelRect(vwselNew);
if (!fBundleOnly)
DestroyFocusBoxAndSetFocus(fSaveGuess);
// 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;
vwselNew.Install();
return true;
}
// Identify the twfic, and the position in m_rgvsli of the property holding it.
// It is also possible that the twfic 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 twfic.
int itagAnalysis = -1;
for (int i = rgvsli.Length; --i >= 0; )
{
if (rgvsli[i].tag == TagAnalysis)
{
itagAnalysis = i;
break;
}
}
if (itagAnalysis < 0)
{
// Go ahead and hide the focus box, since it could try to still the selection back (cf. LT-7968)
if (!fBundleOnly)
DestroyFocusBoxAndSetFocus(fSaveGuess);
return false; // Selection is somewhere we can't handle.
}
int hvoAnalysis = rgvsli[itagAnalysis].hvo; // The current analyis object.
Debug.Assert(itagAnalysis < rgvsli.Length - 1); // Need different approach if the twfic is the root.
int hvoAnnotation = rgvsli[itagAnalysis + 1].hvo;
// Launch a combo on the base line.
// if (tagTextProp == (int)WfiWordform.WfiWordformTags.kflidForm)
// {
// // First line: display the in-place combo.
// analysisHandler = new ChooseAnalysisHandler(m_fdoCache, hvoSrc, hvoAnalysis);
// analysisHandler.AnalysisChosen += analysisChosenDelegate;
// analysisHandler.SetupCombo();
// analysisHandler.Show(m_site, m_vwselNew);
// return;
// }
// Enhance JohnT: if click was on word gloss line, put cursor there instead of default.
TriggerAnnotationSelected(hvoAnnotation, hvoAnalysis, fSaveGuess);
// new HandleSelectionChangeMethod(vwselNew, this)
// .Run(ref m_analysisHandler, m_vc.ListManager,
// new EventHandler(m_analysisHandler_AnalysisChosen), new AdvanceWordEventHandler(scope_AdvanceWord));
return true;
}