private void buttonSyncTo_Click(object sender, RoutedEventArgs e) { if (sbDocument != mainWindow.GetActiveDocument()) { return; } int iLine = -1; if (null != lastHighlight && lastHighlight.lines.Count > 0) { iLine = lastHighlight.lines[0]; } if (iLine < 0 && null != lastHighlight && null != lastHighlight.rootLine && lastHighlight.rootLine.lines.Count > 0) { iLine = lastHighlight.rootLine.lines[0]; } if (iLine >= 0 && iLine < sbDocument.TextArea.Lines.Count) { ScintillaNET.Line line = sbDocument.TextArea.Lines[iLine]; sbDocument.TextArea.ClearSelections(); sbDocument.TextArea.SelectionStart = line.Position; sbDocument.TextArea.SelectionEnd = line.EndPosition; sbDocument.TextArea.FirstVisibleLine = iLine; } }
void Scintilla_FoldChanged(object sender, ScintillaNET.FoldChangedEventArgs e) { if ((e.NewFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) != 0) { if ((e.PreviousFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) == 0) { // Adding a fold point. this.Lines[e.Line].FoldExpanded = true; if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) { Expand(e.Line, true, false, 0, e.PreviousFoldLevel); } } } else if ((e.PreviousFoldLevel & 0x2000 /*SC_FOLDLEVELHEADERFLAG*/) != 0) { if (!this.Lines[e.Line].FoldExpanded) { // Removing the fold from one that has been contracted so should expand // otherwise lines are left invisible with no way to make them visible this.Lines[e.Line].FoldExpanded = true; if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) { Expand(e.Line, true, false, 0, e.PreviousFoldLevel); } } } if ((e.NewFoldLevel & 0x1000 /*SC_FOLDLEVELWHITEFLAG*/) == 0 && ((e.PreviousFoldLevel & 0x0FFF /*SC_FOLDLEVELNUMBERMASK*/) > (e.NewFoldLevel & 0x0FFF /*SC_FOLDLEVELNUMBERMASK*/))) { if (this.NativeInterface.SendMessageDirect(2236 /*SCI_GETALLLINESVISIBLE*/) == 0) { // See if should still be hidden ScintillaNET.Line parentLine = this.Lines[e.Line].FoldParent; if (parentLine == null) { this.Lines[e.Line].IsVisible = true; } else if (parentLine.FoldExpanded && parentLine.IsVisible) { this.Lines[e.Line].IsVisible = true; } } } }