[HELP]DigitalRune Code Completion

Posts 1–2 of 2 · Page 1 of 1
[HELP]DigitalRune Code Completion
Well, I want to make a Completion window using DigitalRune's superb package Text Editor.

Here is the Main Class of the CompletionDataProvider:
Code:
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports DigitalRune.Windows.TextEditor
Imports DigitalRune.Windows.TextEditor.Completion


Namespace DRUNE
    Class CodeCompletionDataProvider
        Inherits AbstractCompletionDataProvider
        Private ReadOnly _imageList As ImageList

        Public Overrides ReadOnly Property ImageList() As ImageList
            Get
                Return _imageList
            End Get
        End Property


        Public Sub New()
            _imageList = New ImageList()
            Dim img1 As String = Application.StartupPath & "\data\com\tmp.ico"
            Dim img2 As String = Application.StartupPath & "\data\com\fie.png"
            Dim img3 As String = Application.StartupPath & "\data\com\me.png"
            _imageList.Images.Add(Image.FromFile(img1))
            '_imageList.Images.Add(Image.FromFile(img2))
            '_imageList.Images.Add(Image.FromFile(img3))
        End Sub


        Public Overrides Function GenerateCompletionData(ByVal fileName As String, ByVal textArea As TextArea, ByVal charTyped As Char) As ICompletionData()
            Dim completionData As New List(Of ICompletionData)() From { _
             New DefaultCompletionData("a", "A local variable", 1), _
             New DefaultCompletionData("b", "A local variable", 1), _
             New DefaultCompletionData("variableX", "A local variable", 1), _
             New DefaultCompletionData("variableY", "A local variable", 1), _
             New DefaultCompletionData("MethodA", "A simple method.", 2), _
             New DefaultCompletionData("MethodB", "A simple method.", 2), _
             New DefaultCompletionData("MethodC", "A simple method.", 2) _
            }

            Dim snippets As New List(Of Snippet)() From { _
             New Snippet("for", "for (|;;)" & vbNewLine & "{" & vbNewLine & "}", "for loop"), _
             New Snippet("if", "if (|)" & vbNewLine & "{" & vbNewLine & "}", "if statement"), _
             New Snippet("ifel", "if (|)" & vbNewLine & "{" & vbNewLine & "}" & vbLf & "else" & vbNewLine & "{" & vbNewLine & "}", "if-else statement"), _
             New Snippet("while", "while (|)" & vbNewLine & "{" & vbNewLine & "}", "while loop") _
            }

            For Each snippet As Snippet In snippets
                completionData.Add(New SnippetCompletionData(snippet, 0))
            Next

            Return completionData.ToArray()
        End Function
    End Class
End Namespace
I didn't edited anything from the main sample, only the image list thingy...

Now when I add this to my Form1:
Code:
    Private Sub Intellisense_CompletionRequest(ByVal sender As Object, ByVal e As DigitalRune.Windows.TextEditor.Completion.CompletionEventArgs) Handles Intellisense.CompletionRequest
        If e.Key = vbNullChar Then
            Intellisense.ShowCompletionWindow(New CodeCompletionDataProvider(), e.Key, False)
        End If
        If Char.IsLetter(e.Key) Then
            Try
                Intellisense.ShowCompletionWindow(New CodeCompletionDataProvider(), e.Key, True)
            Catch ex As Exception

            End Try
        End If
    End Sub
It says:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
What to do please help me
Dude, what the heck is wrong with you ? You just learned simple string manipulation and you are going to do this stuff ? FFS learn the language first.
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us