2019-04-15 14:30:00 +02:00

50 lines
3.6 KiB
VB.net

Imports DigitalData.GUIs.ClientSuite.Controls.Editors
Imports ScintillaNET
Public Class frmDatasourceEditor
Public Value As DatasourceType
Private _Editor As Scintilla
Private Sub frmDatasourceEditor_Load(sender As Object, e As EventArgs) Handles MyBase.Load
_Editor = New Scintilla() With {
.Dock = DockStyle.Fill,
.BorderStyle = BorderStyle.None,
.Text = Value.SQLCommand
}
_Editor.StyleResetDefault()
With _Editor.Styles(Style.Default)
.Font = "Consolas"
.Size = 10
End With
_Editor.StyleClearAll()
_Editor.Lexer = Lexer.Sql
_Editor.Styles(Style.LineNumber).ForeColor = Color.FromArgb(255, 128, 128, 128)
_Editor.Styles(Style.LineNumber).BackColor = Color.FromArgb(255, 228, 228, 228)
_Editor.Styles(Style.Sql.Comment).ForeColor = Color.Green
_Editor.Styles(Style.Sql.CommentLine).ForeColor = Color.Green
_Editor.Styles(Style.Sql.CommentLineDoc).ForeColor = Color.Green
_Editor.Styles(Style.Sql.Number).ForeColor = Color.Maroon
_Editor.Styles(Style.Sql.Word).ForeColor = Color.Blue
_Editor.Styles(Style.Sql.Word2).ForeColor = Color.Fuchsia
_Editor.Styles(Style.Sql.User1).ForeColor = Color.Gray
_Editor.Styles(Style.Sql.User2).ForeColor = Color.FromArgb(255, 0, 128, 192)
_Editor.Styles(Style.Sql.String).ForeColor = Color.Red
_Editor.Styles(Style.Sql.Character).ForeColor = Color.Red
_Editor.Styles(Style.Sql.[Operator]).ForeColor = Color.Black
_Editor.SetKeywords(0, "add alter as authorization backup begin bigint binary bit break browse bulk by cascade case catch check checkpoint close clustered column commit compute constraint containstable continue create current cursor cursor database date datetime datetime2 datetimeoffset dbcc deallocate decimal declare default delete deny desc disk distinct distributed double drop dump else end errlvl escape except exec execute exit external fetch file fillfactor float for foreign freetext freetexttable from full function goto grant group having hierarchyid holdlock identity identity_insert identitycol if image index insert int intersect into key kill lineno load merge money national nchar nocheck nocount nolock nonclustered ntext numeric nvarchar of off offsets on open opendatasource openquery openrowset openxml option order over percent plan precision primary print proc procedure public raiserror read readtext real reconfigure references replication restore restrict return revert revoke rollback rowcount rowguidcol rule save schema securityaudit select set setuser shutdown smalldatetime smallint smallmoney sql_variant statistics table table tablesample text textsize then time timestamp tinyint to top tran transaction trigger truncate try union unique uniqueidentifier update updatetext use user values varbinary varchar varying view waitfor when where while with writetext xml go ")
_Editor.SetKeywords(1, "ascii cast char charindex ceiling coalesce collate contains convert current_date current_time current_timestamp current_user floor isnull max min nullif object_id session_user substring system_user tsequal ")
_Editor.SetKeywords(4, "all and any between cross exists in inner is join left like not null or outer pivot right some unpivot ( ) * ")
_Editor.SetKeywords(5, "sys objects sysobjects ")
PanelEditor.Controls.Add(_Editor)
End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Value.SQLCommand = _Editor.Text
End Sub
End Class