-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Span.cs
199 lines (160 loc) · 7.79 KB
/
Span.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#nullable disable
using System;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="Type[@FullName='Microsoft.Maui.Controls.Span']/Docs/*" />
[ContentProperty("Text")]
public class Span : GestureElement, IFontElement, IStyleElement, ITextElement, ILineHeightElement, IDecorableTextElement
{
internal readonly MergedStyle _mergedStyle;
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='.ctor']/Docs/*" />
public Span()
{
_mergedStyle = new MergedStyle(GetType(), this);
}
/// <summary>Bindable property for <see cref="Style"/>.</summary>
public static readonly BindableProperty StyleProperty = BindableProperty.Create(nameof(Style), typeof(Style), typeof(Span), default(Style),
propertyChanged: (bindable, oldvalue, newvalue) => ((Span)bindable)._mergedStyle.Style = (Style)newvalue, defaultBindingMode: BindingMode.OneWay);
/// <summary>Bindable property for <see cref="TextDecorations"/>.</summary>
public static readonly BindableProperty TextDecorationsProperty = DecorableTextElement.TextDecorationsProperty;
/// <summary>Bindable property for <see cref="TextTransform"/>.</summary>
public static readonly BindableProperty TextTransformProperty = TextElement.TextTransformProperty;
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='Style']/Docs/*" />
public Style Style
{
get { return (Style)GetValue(StyleProperty); }
set { SetValue(StyleProperty, value); }
}
/// <summary>Bindable property for <see cref="BackgroundColor"/>.</summary>
public static readonly BindableProperty BackgroundColorProperty
= BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(Span), default(Color), defaultBindingMode: BindingMode.OneWay);
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='BackgroundColor']/Docs/*" />
public Color BackgroundColor
{
get { return (Color)GetValue(BackgroundColorProperty); }
set { SetValue(BackgroundColorProperty, value); }
}
/// <summary>Bindable property for <see cref="TextColor"/>.</summary>
public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='TextColor']/Docs/*" />
public Color TextColor
{
get { return (Color)GetValue(TextElement.TextColorProperty); }
set { SetValue(TextElement.TextColorProperty, value); }
}
/// <summary>Bindable property for <see cref="CharacterSpacing"/>.</summary>
public static readonly BindableProperty CharacterSpacingProperty = TextElement.CharacterSpacingProperty;
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='CharacterSpacing']/Docs/*" />
public double CharacterSpacing
{
get { return (double)GetValue(TextElement.CharacterSpacingProperty); }
set { SetValue(TextElement.CharacterSpacingProperty, value); }
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='TextTransform']/Docs/*" />
public TextTransform TextTransform
{
get => (TextTransform)GetValue(TextTransformProperty);
set => SetValue(TextTransformProperty, value);
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='UpdateFormsText']/Docs/*" />
public virtual string UpdateFormsText(string source, TextTransform textTransform)
=> TextTransformUtilites.GetTransformedText(source, textTransform);
/// <summary>Bindable property for <see cref="Text"/>.</summary>
public static readonly BindableProperty TextProperty
= BindableProperty.Create(nameof(Text), typeof(string), typeof(Span), "", defaultBindingMode: BindingMode.OneWay);
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='Text']/Docs/*" />
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
/// <summary>Bindable property for <see cref="FontFamily"/>.</summary>
public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
/// <summary>Bindable property for <see cref="FontSize"/>.</summary>
public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
/// <summary>Bindable property for <see cref="FontAttributes"/>.</summary>
public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
/// <summary>Bindable property for <see cref="FontAutoScalingEnabled"/>.</summary>
public static readonly BindableProperty FontAutoScalingEnabledProperty = FontElement.FontAutoScalingEnabledProperty;
/// <summary>Bindable property for <see cref="LineHeight"/>.</summary>
public static readonly BindableProperty LineHeightProperty = LineHeightElement.LineHeightProperty;
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='FontAttributes']/Docs/*" />
public FontAttributes FontAttributes
{
get { return (FontAttributes)GetValue(FontElement.FontAttributesProperty); }
set { SetValue(FontElement.FontAttributesProperty, value); }
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='FontFamily']/Docs/*" />
public string FontFamily
{
get { return (string)GetValue(FontElement.FontFamilyProperty); }
set { SetValue(FontElement.FontFamilyProperty, value); }
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='FontSize']/Docs/*" />
[System.ComponentModel.TypeConverter(typeof(FontSizeConverter))]
public double FontSize
{
get { return (double)GetValue(FontElement.FontSizeProperty); }
set { SetValue(FontElement.FontSizeProperty, value); }
}
public bool FontAutoScalingEnabled
{
get => (bool)GetValue(FontAutoScalingEnabledProperty);
set => SetValue(FontAutoScalingEnabledProperty, value);
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='TextDecorations']/Docs/*" />
public TextDecorations TextDecorations
{
get { return (TextDecorations)GetValue(TextDecorationsProperty); }
set { SetValue(TextDecorationsProperty, value); }
}
/// <include file="../../docs/Microsoft.Maui.Controls/Span.xml" path="//Member[@MemberName='LineHeight']/Docs/*" />
public double LineHeight
{
get { return (double)GetValue(LineHeightElement.LineHeightProperty); }
set { SetValue(LineHeightElement.LineHeightProperty, value); }
}
protected override void OnBindingContextChanged()
{
this.PropagateBindingContext(GestureRecognizers);
base.OnBindingContextChanged();
}
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue)
{
}
void IFontElement.OnFontSizeChanged(double oldValue, double newValue)
{
}
double IFontElement.FontSizeDefaultValueCreator() =>
double.NaN;
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue)
{
}
void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
{
}
void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newValue)
{
}
void ITextElement.OnTextTransformChanged(TextTransform oldValue, TextTransform newValue)
{
}
void IFontElement.OnFontAutoScalingEnabledChanged(bool oldValue, bool newValue) { }
internal override void ValidateGesture(IGestureRecognizer gesture)
{
switch (gesture)
{
case TapGestureRecognizer tap:
case null:
break;
default:
throw new InvalidOperationException($"{gesture.GetType().Name} is not supported on a {nameof(Span)}");
}
}
void ILineHeightElement.OnLineHeightChanged(double oldValue, double newValue)
{
}
}
}