forked from DebugST/STTextBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrmInvisableChar.cs
More file actions
57 lines (54 loc) · 1.83 KB
/
FrmInvisableChar.cs
File metadata and controls
57 lines (54 loc) · 1.83 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ST.Library.UI.STTextBox;
namespace STTextBoxTest.Demos
{
public partial class FrmInvisableChar : Form
{
public FrmInvisableChar() {
InitializeComponent();
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
STTextBoxGDIPRender render = new STTextBoxGDIPRender();
render.ShowInVisableChar = true;
render.InVisableCharColor = Color.Red;
STTextBox tbx = new STTextBox();
tbx.SetTextBoxRender(render);
tbx.Dock = DockStyle.Fill;
tbx.Font = new System.Drawing.Font("Consolas", 10);
tbx.SetTextStyleMonitors( // use the monitor
new CSharpStyleMonitor(),
new SelectionStyleMonitor()
);
this.Controls.Add(tbx);
string strCode = @"
//tab: ,space: ,newline:
STTextBoxGDIPRender render = new STTextBoxGDIPRender();
render.ShowInVisableChar = true; //default: false
render.InVisableCharColor = Color.Red;
STTextBox tbx = new STTextBox();
tbx.SetTextBoxRender(render);
tbx.Dock = DockStyle.Fill;
tbx.Font = new System.Drawing.Font(""Consolas"", 10);
tbx.SetTextStyleMonitors( // use the monitor
new CSharpStyleMonitor(),
new SelectionStyleMonitor()
);
this.Controls.Add(tbx);
// ====
// STTextBoxGDIPRender is build-in class use gdip render the textbox
// There are some method:
// protected virtual void OnDrawNewLineChar(Rectangle rect);
// protected virtual void OnDrawSpaceChar(Rectangle rect);
// protected virtual void OnDrawTabChar(Rectangle rect);";
tbx.SetText(strCode.Trim());
}
}
}