blob: c8beebd283812f8cc711896ab803f4b19215870f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using Tango.Scripting.Editors.Document;
using Tango.Scripting.Editors.Editing;
namespace Tango.Scripting.Editors.Intellisense
{
public abstract class CompletionItem : DependencyObject, ICompletionItem
{
public abstract string Text { get; }
public object Description { get; set; }
public double Priority { get; set; }
public abstract CompletionItemPopupControl PopupControl { get; }
public bool IsSelected
{
get { return (bool)GetValue(IsSelectedProperty); }
set { SetValue(IsSelectedProperty, value); }
}
public static readonly DependencyProperty IsSelectedProperty =
DependencyProperty.Register("IsSelected", typeof(bool), typeof(CompletionItem), new PropertyMetadata(false));
public virtual void Complete(ScriptEditor editor)
{
var word = editor.GetCurrentWord();
int index = editor.GetCurrentWordStartIndex();
int max = editor.GetCurrentLine().EndOffset;
editor.Document.Replace(index, word.Length,Text);
}
public abstract BitmapSource Image { get; }
protected static BitmapSource GetImage(String name)
{
return new BitmapImage(new Uri($"pack://application:,,,/Tango.Scripting.Editors;component/Images/{name}", UriKind.Absolute));
}
public override string ToString()
{
return Text;
}
}
}
|