PageRenderTime 17ms CodeModel.GetById 7ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/AddIns/Misc/PackageManagement/Packages/ICSharpCode.TextEditor.Sample/Content/TextEditorSample/CompletionDataProvider.cs.pp

https://github.com/ajadex/SharpDevelop
Puppet | 55 lines | 45 code | 10 blank | 0 comment | 1 complexity | 12a108011b1d49debb4254002186432a MD5 | raw file
 1
 2using System;
 3using System.Collections.Generic;
 4using System.Windows.Forms;
 5using ICSharpCode.TextEditor;
 6using ICSharpCode.TextEditor.Gui.CompletionWindow;
 7
 8namespace $rootnamespace$.TextEditorSample
 9{
10	public class CompletionDataProvider : ICompletionDataProvider
11	{
12		ImageList imageList = new ImageList();
13		
14		List<DefaultCompletionData> completionData = new List<DefaultCompletionData>();
15		
16		public CompletionDataProvider()
17		{
18			completionData.Add(new DefaultCompletionData("Item1", 0));
19			completionData.Add(new DefaultCompletionData("Item2", 0));
20			completionData.Add(new DefaultCompletionData("Item3", 0));
21			completionData.Add(new DefaultCompletionData("Another item", 0));
22		}
23		
24		public ImageList ImageList {
25			get { return imageList; }
26		}
27		
28		public string PreSelection {
29			get { return null; }
30		}
31		
32		public int DefaultIndex {
33			get { return 0; }
34		}
35		
36		public CompletionDataProviderKeyResult ProcessKey(char key)
37		{
38			if (char.IsLetterOrDigit(key)) {
39				return CompletionDataProviderKeyResult.NormalKey;
40			}
41			return CompletionDataProviderKeyResult.InsertionKey;
42		}
43		
44		public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
45		{
46			textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
47			return data.InsertAction(textArea, key);
48		}
49		
50		public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
51		{
52			return completionData.ToArray();
53		}
54	}
55}