FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
STTextBox/ST.Library.UI.STTextBox/DataType/TextStyle.cs at main · lingsg/STTextBox · GitHub
lingsg
/
STTextBox
Public
forked from
DebugST/STTextBox
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
STTextBox
/
ST.Library.UI.STTextBox
/
DataType
/
TextStyle.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
130 lines (113 loc) · 4.59 KB
Breadcrumbs
STTextBox
/
ST.Library.UI.STTextBox
/
DataType
/
TextStyle.cs
Copy path
File metadata and controls
130 lines (113 loc) · 4.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Text
;
using
System
.
Drawing
;
namespace
ST
.
Library
.
UI
.
STTextBox
{
public
struct
TextStyle
{
private
string
EmptyGUID
{
get
;
set
;
}
public
string
Name
;
public
Color
ForeColor
;
public
Color
BackColor
;
public
Color
UnderLineColor
;
public
Color
StrikeOutColor
;
public
FontStyle
FontStyle
;
public
bool
RejectMix
;
public
static
TextStyle
Empty
=
new
TextStyle
(
)
{
EmptyGUID
=
Guid
.
NewGuid
(
)
.
ToString
(
)
}
;
public
void
Mix
(
TextStyle
style
)
{
//this.ForeColor = _ColorMix(this.ForeColor, style.ForeColor);
//this.BackColor = _ColorMix(this.BackColor, style.BackColor);
//this.UnderLineColor = _ColorMix(this.UnderLineColor, style.UnderLineColor);
//this.StrikeOutColor = _ColorMix(this.StrikeOutColor, style.StrikeOutColor);
//this.FontStyle |= style.FontStyle;
if
(
this
.
ForeColor
.
A
==
0
)
this
.
ForeColor
=
style
.
ForeColor
;
if
(
this
.
BackColor
.
A
==
0
)
this
.
BackColor
=
style
.
BackColor
;
if
(
this
.
UnderLineColor
.
A
==
0
)
this
.
UnderLineColor
=
style
.
UnderLineColor
;
if
(
this
.
StrikeOutColor
.
A
==
0
)
this
.
StrikeOutColor
=
style
.
StrikeOutColor
;
this
.
FontStyle
|=
style
.
FontStyle
;
}
private
static
Color
_ColorMix
(
Color
a
,
Color
b
)
{
// T = Foreground, B = Background, F = Mixed
// alphaF = alphaT + alphaB * (1 - alphaT);
// colorF = (colorT * alphaT + colorB * alphaB * (1 - alphaT)) / alphaF;
if
(
a
.
A
==
255
)
return
a
;
float
aT
=
(
float
)
a
.
A
/
255
;
float
aB
=
(
float
)
b
.
A
/
255
;
float
aF
=
aT
+
aB
*
(
1
-
aT
)
;
float
temp
=
aB
*
(
1
-
aT
)
;
;
int
nA
,
nR
,
nG
,
nB
;
nA
=
(
int
)
(
255
*
aF
)
;
nR
=
(
int
)
(
(
a
.
R
*
aT
+
b
.
R
*
temp
)
/
aF
)
;
nG
=
(
int
)
(
(
a
.
G
*
aT
+
b
.
G
*
temp
)
/
aF
)
;
nB
=
(
int
)
(
(
a
.
B
*
aT
+
b
.
B
*
temp
)
/
aF
)
;
return
Color
.
FromArgb
(
_Range
(
nA
,
0
,
255
)
,
_Range
(
nR
,
0
,
255
)
,
_Range
(
nG
,
0
,
255
)
,
_Range
(
nB
,
0
,
255
)
)
;
}
private
static
int
_Range
(
int
num
,
int
nMin
,
int
nMax
)
{
if
(
num
<
nMin
)
{
num
=
nMin
;
}
else
if
(
num
>
nMax
)
{
num
=
nMax
;
}
return
num
;
}
// [override] ==============================================================
public
override
string
ToString
(
)
{
return
"["
+
this
.
Name
+
"]{"
+
this
.
ForeColor
+
","
+
this
.
BackColor
+
"}"
;
}
public
static
bool
operator
==
(
TextStyle
a
,
TextStyle
b
)
{
if
(
a
.
EmptyGUID
!=
a
.
EmptyGUID
)
return
false
;
if
(
a
.
RejectMix
!=
b
.
RejectMix
)
return
false
;
if
(
a
.
ForeColor
!=
b
.
ForeColor
)
return
false
;
if
(
a
.
BackColor
!=
b
.
BackColor
)
return
false
;
if
(
a
.
UnderLineColor
!=
b
.
UnderLineColor
)
return
false
;
if
(
a
.
StrikeOutColor
!=
b
.
StrikeOutColor
)
return
false
;
if
(
a
.
FontStyle
!=
b
.
FontStyle
)
return
false
;
return
true
;
}
public
static
bool
operator
!=
(
TextStyle
a
,
TextStyle
b
)
{
return
!
(
a
==
b
)
;
}
public
override
bool
Equals
(
object
obj
)
{
return
base
.
Equals
(
obj
)
;
}
public
override
int
GetHashCode
(
)
{
return
base
.
GetHashCode
(
)
;
}
}
public
struct
TextStyleRange
:
IComparable
{
private
string
EmptyGUID
{
get
;
set
;
}
public
int
Index
;
public
int
Length
;
public
TextStyle
Style
;
public
static
TextStyleRange
Empty
=
new
TextStyleRange
(
)
{
EmptyGUID
=
Guid
.
NewGuid
(
)
.
ToString
(
)
}
;
public
static
bool
operator
==
(
TextStyleRange
a
,
TextStyleRange
b
)
{
if
(
a
.
EmptyGUID
!=
b
.
EmptyGUID
)
return
false
;
if
(
a
.
Index
!=
b
.
Index
)
return
false
;
if
(
a
.
Length
!=
b
.
Length
)
return
false
;
if
(
a
.
Style
!=
b
.
Style
)
return
false
;
return
true
;
}
public
static
bool
operator
!=
(
TextStyleRange
a
,
TextStyleRange
b
)
{
return
!
(
a
==
b
)
;
}
public
override
bool
Equals
(
object
obj
)
{
return
base
.
Equals
(
obj
)
;
}
public
override
int
GetHashCode
(
)
{
return
base
.
GetHashCode
(
)
;
}
public
override
string
ToString
(
)
{
return
"("
+
this
.
Index
+
","
+
this
.
Length
+
")"
+
this
.
Style
;
}
public
int
CompareTo
(
object
obj
)
{
return
this
.
Index
-
(
(
TextStyleRange
)
obj
)
.
Index
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL