Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using ScintillaNET;
- using AutocompleteMenuNS;
- using System.Runtime.InteropServices;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool AllocConsole();
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool FreeConsole();
- string[] snippets = { "public", "class", "namespace", "maurice" };
- public Form1()
- {
- AllocConsole();
- InitializeComponent();
- autocompleteMenu1.TargetControlWrapper = new ScintillaWrapper(scintilla);
- autocompleteMenu1.ToolTipDuration = 1;
- // = New ScintillaWrapper(scintilla1);
- scintilla.Text = "";
- // Configuring the default style with properties
- // we have common to every lexer style saves time.
- scintilla.StyleResetDefault();
- scintilla.Styles[Style.Default].Font = "Consolas";
- scintilla.Styles[Style.Default].Size = 10;
- scintilla.Styles[Style.Default].BackColor = Color.Black;
- scintilla.Styles[Style.Default].ForeColor = Color.White;
- scintilla.CaretForeColor = Color.Yellow;
- scintilla.StyleClearAll();
- // Configure the CPP (C#) lexer styles
- scintilla.Styles[Style.Cpp.Default].ForeColor = Color.Silver;
- scintilla.Styles[Style.Cpp.Comment].ForeColor = Color.FromArgb(0, 128, 0); // Green
- scintilla.Styles[Style.Cpp.CommentLine].ForeColor = Color.FromArgb(0, 128, 0); // Green
- scintilla.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
- scintilla.Styles[Style.Cpp.Number].ForeColor = Color.Olive;
- scintilla.Styles[Style.Cpp.Word].ForeColor = Color.Red;
- scintilla.Styles[Style.Cpp.Word2].ForeColor = Color.Blue;
- scintilla.Styles[Style.Cpp.String].ForeColor = Color.FromArgb(163, 21, 21); // Red
- scintilla.Styles[Style.Cpp.Character].ForeColor = Color.FromArgb(163, 21, 21); // Red
- scintilla.Styles[Style.Cpp.Verbatim].ForeColor = Color.FromArgb(163, 21, 21); // Red
- scintilla.Styles[Style.Cpp.StringEol].BackColor = Color.Pink;
- scintilla.Styles[Style.Cpp.Operator].ForeColor = Color.Purple;
- scintilla.Styles[Style.Cpp.Preprocessor].ForeColor = Color.Maroon;
- scintilla.Lexer = Lexer.Cpp;
- // Set the keywords
- scintilla.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while");
- scintilla.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");
- scintilla.KeyDown += scintilla_KeyDown;
- BuildAutocompleteMenu();
- }
- public void scintilla_TextChanged(object sender, EventArgs e)
- {
- }
- private void scintilla_KeyDown(object sender, KeyEventArgs e)
- {
- //forcibly shows menu
- if (e.KeyCode != Keys.Return && e.KeyCode != Keys.Back)
- autocompleteMenu1.Show(scintilla, false);
- else
- {
- Console.WriteLine("OH?");
- }
- }
- private void scintilla_Click(object sender, EventArgs e)
- {
- }
- private void BuildAutocompleteMenu()
- {
- var items = new List<AutocompleteItem>();
- foreach (var item in snippets)
- items.Add(new SnippetAutocompleteItem(item) { ImageIndex = 1 });
- //set as autocomplete source
- autocompleteMenu1.SetAutocompleteItems(items);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement