private void OnCreateHiddenRegion(ExecuteEventArgs ea)
{
IVsHiddenTextSession Session =
GetHiddenTextSession(DXCoreEngine.Source.Active);
TextSpan Span = new TextSpan();
SourceRange Range = DXCoreEngine.Source.Active.Range;
Span.iStartLine = Range.Start.Line - 1;
Span.iStartIndex = Range.Start.Offset - 1;
Span.iEndLine = Range.End.Line - 1;
Span.iEndIndex = Range.End.Offset - 1;
IVsEnumHiddenRegions ExistingRegionsEnumerator = null;
Session.EnumHiddenRegions(0, 0, null, out ExistingRegionsEnumerator);
uint ExistingCount = 0;
ExistingRegionsEnumerator.GetCount(out ExistingCount);
if (ExistingCount > 0)
{
IVsHiddenRegion[] ExistingRegions = new
IVsHiddenRegion[ExistingCount];
uint pcElFetched = 0;
ExistingRegionsEnumerator.Next(ExistingCount, ExistingRegions,
out pcElFetched);
foreach (IVsHiddenRegion Canidate in ExistingRegions)
{
TextSpan[] SpanRetrieverArra1 = new TextSpan[1];
Canidate.GetSpan(SpanRetrieverArra1);
TextSpan SpanCanidate = SpanRetrieverArra1[0];
if ((SpanCanidate.iStartLine == Span.iStartLine) &&
(SpanCanidate.iStartIndex == Span.iStartIndex) &&
(SpanCanidate.iEndLine == Span.iEndLine) &&
(SpanCanidate.iEndIndex == Span.iEndIndex))
{
Canidate.Invalidate(0);
return;
}
}
}
string Banner =
DXCoreEngine.Documents.ActiveTextDocument.GetLine(Range.Start.Line);
Banner = Banner.TrimStart();
Banner = Banner.TrimEnd();
NewHiddenRegion[] NewHiddenRegionArray = new NewHiddenRegion[1];
NewHiddenRegionArray[0].dwBehavior = 1;
NewHiddenRegionArray[0].dwClient = 0x2cff;
NewHiddenRegionArray[0].dwState = 0;
NewHiddenRegionArray[0].iType = 1;
NewHiddenRegionArray[0].pszBanner = Banner;
NewHiddenRegionArray[0].tsHiddenText = Span;
Session.AddHiddenRegions(0, 1, NewHiddenRegionArray, null);
}
{
IVsHiddenTextSession Session =
GetHiddenTextSession(DXCoreEngine.Source.Active);
TextSpan Span = new TextSpan();
SourceRange Range = DXCoreEngine.Source.Active.Range;
Span.iStartLine = Range.Start.Line - 1;
Span.iStartIndex = Range.Start.Offset - 1;
Span.iEndLine = Range.End.Line - 1;
Span.iEndIndex = Range.End.Offset - 1;
IVsEnumHiddenRegions ExistingRegionsEnumerator = null;
Session.EnumHiddenRegions(0, 0, null, out ExistingRegionsEnumerator);
uint ExistingCount = 0;
ExistingRegionsEnumerator.GetCount(out ExistingCount);
if (ExistingCount > 0)
{
IVsHiddenRegion[] ExistingRegions = new
IVsHiddenRegion[ExistingCount];
uint pcElFetched = 0;
ExistingRegionsEnumerator.Next(ExistingCount, ExistingRegions,
out pcElFetched);
foreach (IVsHiddenRegion Canidate in ExistingRegions)
{
TextSpan[] SpanRetrieverArra1 = new TextSpan[1];
Canidate.GetSpan(SpanRetrieverArra1);
TextSpan SpanCanidate = SpanRetrieverArra1[0];
if ((SpanCanidate.iStartLine == Span.iStartLine) &&
(SpanCanidate.iStartIndex == Span.iStartIndex) &&
(SpanCanidate.iEndLine == Span.iEndLine) &&
(SpanCanidate.iEndIndex == Span.iEndIndex))
{
Canidate.Invalidate(0);
return;
}
}
}
string Banner =
DXCoreEngine.Documents.ActiveTextDocument.GetLine(Range.Start.Line);
Banner = Banner.TrimStart();
Banner = Banner.TrimEnd();
NewHiddenRegion[] NewHiddenRegionArray = new NewHiddenRegion[1];
NewHiddenRegionArray[0].dwBehavior = 1;
NewHiddenRegionArray[0].dwClient = 0x2cff;
NewHiddenRegionArray[0].dwState = 0;
NewHiddenRegionArray[0].iType = 1;
NewHiddenRegionArray[0].pszBanner = Banner;
NewHiddenRegionArray[0].tsHiddenText = Span;
Session.AddHiddenRegions(0, 1, NewHiddenRegionArray, null);
}