_
'/ <summary>
'/ Summary description for SyncfusionEditControlAdapter.
'/ </summary>
Public
Class SyncfusionEditControlAdapterImplements Keyoti.RapidSpell.ISpellCheckableTextComponentPrivate tb As TextBoxPublic Event GotFocus As EventHandler Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.GotFocusPublic Sub New(ByVal tb As TextBox)Me.tb = tbAddHandler Me.tb.Enter, New EventHandler(AddressOf Me.OnGotFocus)End Sub 'New
Protected Overloads Overrides Sub Finalize()
If Not (tb Is Nothing) ThenRemoveHandler Me.tb.Enter, New EventHandler(AddressOf Me.OnGotFocus)End IfMyBase.Finalize()End Sub 'Finalize
Sub OnGotFocus(ByVal s As Object, ByVal e As EventArgs)RaiseEvent GotFocus(Me, e)End Sub 'OnGotFocus
Public Overridable Overloads Sub ScrollToCaret() Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.ScrollToCaretEnd Sub 'ScrollToCaret
Public Property HideSelection() As Boolean Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.HideSelection
GetReturn False 'not implementedEnd GetSet(ByVal Value As Boolean) 'not implementedEnd SetEnd Property
Public Property SelectedText() As String Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectedText
GetReturn tb.SelectedTextEnd GetSet(ByVal Value As String)tb.SelectedText = Value
End SetEnd PropertyPublic Property SelectionStart() As Integer Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectionStart
Get
Return LineAndCharToAbsCharIndex(tb.CurrentColumn, tb.CurrentLine)
End Get
Set
Dim selParams As Integer() = AbsCharIndexToLineAndChar(value)
tb.SetSelection(selParams(1), selParams(0), selParams(1), selParams(0))
tb.CurrentLine = selParams(0)
tb.CurrentColumn = selParams(1)
End Set
End Property
Public Function LineAndCharToAbsCharIndex(column As Integer, line As Integer) As Integer
Dim lines As String() = tb.Lines
Dim totLen As Integer = 0
Dim newlineCharLen As Integer = 1
Dim l As Integer
For l = 0 To
totLen += lines(l).Length + newlineCharLen
Next l
Return totLen += column - 1 'ToDo: Unsupported feature: assignment within expression
End Function 'LineAndCharToAbsCharIndex
'[0] = line
'[1] = col
Public Function AbsCharIndexToLineAndChar(absoluteOffset As Integer) As Integer()
Dim lines As String() = tb.Lines
Dim totLen As Integer = 0
Dim targetLine As Integer = 0
Dim newlineCharLen As Integer = 1
Dim l As Integer
For l = 0 To lines.Length - 1
If lines(l).Length + totLen + newlineCharLen <= absoluteOffset Then
totLen += lines(l).Length + newlineCharLen
Else
targetLine = l
Exit For
End If
Next l
Return New Integer() {targetLine + 1, absoluteOffset - totLen + 1}
End Function 'AbsCharIndexToLineAndChar
Public Property SelectionLength() As Integer
Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.SelectionLength Get
If tb.Selection Is Nothing Then
Return 0
Else
Dim r As Syncfusion.Windows.Forms.Edit.Utils.ITextRange = tb.Selection
Dim [end] As Syncfusion.Windows.Forms.Edit.Utils.CoordinatePoint = r.End
Return LineAndCharToAbsCharIndex([end].VirtualColumn, [end].VirtualLine) - SelectionStart
End If
End Get
Set
Dim [end] As Integer() = AbsCharIndexToLineAndChar((SelectionStart + value))
tb.SetSelection(tb.CurrentColumn, tb.CurrentLine, [end](1), [end](0))
End Set
End Property
Public Property [Text]() As String Implements Keyoti.RapidSpell.ISpellCheckableTextComponent.TextGetReturn tb.TextEnd GetSet(ByVal Value As String)tb.Text = Value
End SetEnd PropertyEnd
Class