本文整理汇总了C#中IVwRootBox.MakeTextSelection方法的典型用法代码示例。如果您正苦于以下问题:C# IVwRootBox.MakeTextSelection方法的具体用法?C# IVwRootBox.MakeTextSelection怎么用?C# IVwRootBox.MakeTextSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwRootBox
的用法示例。
在下文中一共展示了IVwRootBox.MakeTextSelection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelAtStartOfWs
internal static IVwSelection GetSelAtStartOfWs(IVwRootBox rootBox, int flid, int wsIndex, IWritingSystem ws)
{
try
{
return rootBox.MakeTextSelection(0, 0, null, flid, wsIndex, 0, 0, (ws == null) ? 0 : ws.Handle, false, -1, null, false);
}
catch (COMException)
{
return null; // can fail if we are hiding an empty WS.
}
}
示例2: SwitchTagAndFixSel
// Regenerate the display of object m_ihvo of property m_virtualTagObj of object m_hvoParent,
// assuming that the current selection is within it and that it will be displayed using
// newTagName.
private void SwitchTagAndFixSel(int newTagName, IVwRootBox rootb)
{
IVwSelection sel = rootb.Selection;
int cvsli = 0;
// Get selection information to determine where the user is typing.
int ihvoRoot = 0;
int tagTextProp = 0;
int cpropPrevious = 0;
int ichAnchor = 0;
int ichEnd = 0;
int ihvoEnd = 0;
int ws = 0;
ITsTextProps ttp = null;
bool fAssocPrev = false;
SelLevInfo[] rgvsli = null;
if (sel != null)
{
// Next step will destroy selection. Save info to install new one.
cvsli = sel.CLevels(false) - 1;
// Get selection information to determine where the user is typing.
rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
out ws, out fAssocPrev, out ihvoEnd, out ttp);
}
// This needs to be done even if we don't have a selection.
m_sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvoParent, m_virtualTagObj, m_ihvoTa, 1, 1);
if (sel != null) // nb old sel is now invalid, but should be OK to compare to null.
{
// Make a new selection. The critical difference is that, whereas tagTextProp was the other name property,
// now that this is the active object the property displayed for its name is newTagName.
try
{
rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, newTagName, cpropPrevious, ichAnchor, ichEnd, ws,
fAssocPrev, ihvoEnd, null, true);
}
catch
{
// Eat any exceptions.
}
}
}
示例3: InsertOptionalItem
/// <summary>
/// Insert "()" into the rootbox at the current selection, then back up the selection
/// to be between the parentheses.
/// </summary>
/// <param name="rootb"></param>
public static void InsertOptionalItem(IVwRootBox rootb)
{
rootb.OnChar((int)'(');
rootb.OnChar((int)')');
// Adjust the selection to be between the parentheses.
IVwSelection vwsel = rootb.Selection;
int cvsli = vwsel.CLevels(false);
// CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
cvsli--;
int ihvoRoot;
int tagTextProp;
int cpropPrevious;
int ichAnchor;
int ichEnd;
int ws;
bool fAssocPrev;
int ihvoEnd;
ITsTextProps ttp;
SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli,
out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
out ws, out fAssocPrev, out ihvoEnd, out ttp);
Debug.Assert(ichAnchor == ichEnd);
Debug.Assert(ichAnchor > 0);
--ichEnd;
--ichAnchor;
rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious,
ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttp, true);
}
示例4: MakeRangeSelection
/// -----------------------------------------------------------------------------------
/// <summary>
/// Make a range selection based upon our saved selection info.
/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
/// Callers should check to make sure the selection is still valid before using it.
/// </summary>
/// <param name="rootBox"></param>
/// <param name="fInstall"></param>
/// <exception cref="Exception">throws if unable to make an end selection</exception>
/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
/// -----------------------------------------------------------------------------------
public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
{
int iAnchor = 0;
int iEnd = 1;
if (!m_fEndSet)
{ // No end information set, so use iAnchor as end
iEnd = iAnchor;
}
if (m_selInfo[iEnd] == null)
{
m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
}
// This change was proposed in change set 37331 but it's not clear what crash sometimes happens if it's not done.
// Apparently it doesn't always crash because some TeDllTests fail if we do this.
// Don't make a selection if the property indicates not to: see comment about -2 in InterlinDocForAnalysis.HandleSelectionChange
//if (m_selInfo[iAnchor].tagTextProp == -2)
// return null; // crashes if allowed to continue
// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
// the RootSite of the selection change.
IVwSelection vwSelAnchor;
try
{
vwSelAnchor = rootBox.MakeTextSelection(
m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
null, false);
}
catch (Exception e)
{
Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
"Making the anchor selection failed, this is probably an empty editable field.");
throw;
}
IVwSelection vwSelEnd;
try
{
vwSelEnd = rootBox.MakeTextSelection(
m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
null, false);
}
catch (Exception)
{
Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
"The anchor has rgvsli but the end does not; since making the end selection failed, this is probably a mistake.");
throw;
}
return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
}
示例5: HandleSelectionChange
/// ------------------------------------------------------------------------------------
/// <summary>
/// We override this method to make a selection in all of the views that are in a
/// synced group. This fixes problems where the user changes the selection in one of
/// the slaves, but the master is not updated. Thus the view is not scrolled as the
/// groups scroll position only scrolls the master's selection into view. (TE-3380)
/// </summary>
/// <param name="rootb">The rootbox whose selection changed</param>
/// <param name="vwselNew">The new selection</param>
/// ------------------------------------------------------------------------------------
protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew)
{
CheckDisposed();
// Guard against recursive calls, typically caused by the MakeTextSelection call below.
if (m_fInSelectionChanged)
return;
try
{
m_fInSelectionChanged = true;
// Make sure we're not handling MouseDown since it
// handles SelectionChanged and DoSelectionSideEffects.
// No need to do it again.
if (!ReadOnlySelect && !m_fHandlingMouseUp)
{
if (vwselNew == null)
return;
// The selection can apparently be invalid on rare occasions, and will lead
// to a crash below trying to call CLevels. See LT-10301. Treat it the
// same as a null selection.
if (!vwselNew.IsValid)
return;
base.HandleSelectionChange(rootb, vwselNew);
m_wantScrollIntoView = false; // It should already be visible here.
// Collect all the information we can about the selection.
int ihvoRoot = 0;
int tagTextProp = 0;
int cpropPrevious = 0;
int ichAnchor = 0;
int ichEnd = 0;
int ws = 0;
bool fAssocPrev = false;
int ihvoEnd = 0;
ITsTextProps ttpBogus = null;
SelLevInfo[] rgvsli = new SelLevInfo[0];
int cvsli = vwselNew.CLevels(false) - 1;
if (cvsli < 0)
return;// Nothing useful we can do.
// Main array of information retrived from sel that made combo.
rgvsli = SelLevInfo.AllTextSelInfo(vwselNew, cvsli,
out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
//for (int i = 0; i < cvsli; ++i)
//{
// Debug.Write(String.Format("XmlBrowseView.SelectionChanged(): rgvsli[{0}].hvo={1}, ivho={2}, tag={3}, cpropPrevious={4}, ich={5}, ws={6}",
// i, rgvsli[i].hvo, rgvsli[i].ihvo, rgvsli[i].tag, rgvsli[i].cpropPrevious, rgvsli[i].ich, rgvsli[i].ws));
// Debug.WriteLine(String.Format("; ihvoRoot={0}, ihvoEnd={1}, ichEnd={2}",
// ihvoRoot, ihvoEnd, ichEnd));
//}
// The call to the base implementation can invalidate the selection. It's rare, but quite
// possible. (See the comment in EditingHelper.SelectionChanged() following
// Commit().) This test fixes LT-4731.
if (vwselNew.IsValid)
{
DoSelectionSideEffects(vwselNew);
}
else
{
// But if the selection is invalid, and we do nothing about it, then we can
// type only one character at a time in a browse cell because we no longer
// have a valid selection. See LT-6443.
rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious,
ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttpBogus, true);
DoSelectionSideEffects(rootb.Selection);
}
m_wantScrollIntoView = true;
}
}
finally
{
m_fInSelectionChanged = false;
}
}
示例6: MakeTextSelection
/// <summary>
/// Makes a text selection out of the given locationInfo.
/// </summary>
/// <param name="rootb">The rootb.</param>
/// <param name="li">The selection path info</param>
/// <param name="fInstall">if true, install the selection</param>
/// <returns></returns>
public static IVwSelection MakeTextSelection(IVwRootBox rootb, CollectorEnv.LocationInfo li, bool fInstall)
{
if (rootb == null || li == null)
return null;
return rootb.MakeTextSelection(0, li.m_location.Length, li.m_location, li.m_tag,
li.m_cpropPrev, li.m_ichMin, li.m_ichMin, li.m_ws, false, -1, null, fInstall);
}
示例7: MakeRangeSelection
/// -----------------------------------------------------------------------------------
/// <summary>
/// Make a range selection based upon our saved selection info.
/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
/// Callers should check to make sure the selection is still valid before using it.
/// </summary>
/// <param name="rootBox"></param>
/// <param name="fInstall"></param>
/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
/// -----------------------------------------------------------------------------------
public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
{
int iAnchor = 0;
int iEnd = 1;
if (!m_fEndSet)
{ // No end information set, so use iAnchor as end
iEnd = iAnchor;
}
if (m_selInfo[iEnd] == null)
{
m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
}
// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
// the RootSite of the selection change.
IVwSelection vwSelAnchor = rootBox.MakeTextSelection(
m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
null, false);
IVwSelection vwSelEnd = rootBox.MakeTextSelection(
m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
null, false);
return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
}