This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
MyTextEdit.cs
74 lines (60 loc) · 3.15 KB
/
MyTextEdit.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Registrator;
using DevExpress.XtraEditors.ViewInfo;
using DevExpress.XtraEditors.Drawing;
using System.ComponentModel;
using System.Drawing;
using DevExpress.XtraEditors.Repository;
using DevExpress.Utils;
namespace DXSample {
public class MyTextEdit : TextEdit {
static MyTextEdit() { RepositoryItemMyTextEdit.RegisterMyTextEdit(); }
public MyTextEdit() : base() { }
public override string EditorTypeName { get { return RepositoryItemMyTextEdit.MyTextEditName; } }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public new RepositoryItemMyTextEdit Properties { get { return (RepositoryItemMyTextEdit)base.Properties; } }
}
[UserRepositoryItem("RegisterMyTextEdit")]
public class RepositoryItemMyTextEdit : RepositoryItemTextEdit {
static RepositoryItemMyTextEdit() { RegisterMyTextEdit(); }
public RepositoryItemMyTextEdit() : base() { }
internal static string MyTextEditName = "MyTextEdit";
public override string EditorTypeName { get { return MyTextEditName; } }
private Color incrementalBackColor;
public Color IncrementalBackColor {
get { return incrementalBackColor; }
set { incrementalBackColor = value; }
}
private Color incrementalForeColor;
public Color IncrementalForeColor {
get { return incrementalForeColor; }
set { incrementalForeColor = value; }
}
public static void RegisterMyTextEdit() {
EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(MyTextEditName, typeof(MyTextEdit),
typeof(RepositoryItemMyTextEdit), typeof(TextEditViewInfo), new MyTextEditPainter(), true));
}
public override void Assign(RepositoryItem item) {
BeginUpdate();
try {
base.Assign(item);
RepositoryItemMyTextEdit source = item as RepositoryItemMyTextEdit;
if (source == null) return;
IncrementalBackColor = source.IncrementalBackColor;
IncrementalForeColor = source.IncrementalForeColor;
} finally { EndUpdate(); }
}
}
public class MyTextEditPainter :TextEditPainter {
public MyTextEditPainter() : base() { }
protected override void DrawMatchedString(ControlGraphicsInfoArgs info, Rectangle bounds, string text,
string matchedText, AppearanceObject appearance, bool invert, int containsIndex) {
TextEditViewInfo vi = info.ViewInfo as TextEditViewInfo;
if (matchedText.Length > text.Length) matchedText = text;
RepositoryItemMyTextEdit properties = (RepositoryItemMyTextEdit)vi.Item;
AppearanceDefault highlight = new AppearanceDefault(properties.IncrementalForeColor, properties.IncrementalBackColor);
info.Cache.Paint.DrawMultiColorString(info.Cache, bounds, text, matchedText, appearance, appearance.GetTextOptions().GetStringFormat(info.ViewInfo.DefaultTextOptions),
highlight.ForeColor, highlight.BackColor, invert, containsIndex);
}
}
}