Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CompositeEntry.cs
1using System.Windows.Input;
2using Microsoft.Maui.Controls;
3using Microsoft.Maui.Controls.Shapes;
4using Waher.Events;
5using Path = Microsoft.Maui.Controls.Shapes.Path;
6
8{
13 {
14 #region Bindable Properties
15
19 public static readonly BindableProperty EntryDataProperty = BindableProperty.Create(
20 nameof(EntryData),
21 typeof(string),
22 typeof(CompositeEntry),
23 default(string),
24 BindingMode.TwoWay);
25
29 public string EntryData
30 {
31 get => (string)this.GetValue(EntryDataProperty);
32 set => this.SetValue(EntryDataProperty, value);
33 }
34
38 public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create(
39 nameof(Placeholder),
40 typeof(string),
41 typeof(CompositeEntry),
42 default(string));
43
47 public string Placeholder
48 {
49 get => (string)this.GetValue(PlaceholderProperty);
50 set => this.SetValue(PlaceholderProperty, value);
51 }
52
56 public static readonly BindableProperty IsPasswordProperty = BindableProperty.Create(
57 nameof(IsPassword),
58 typeof(bool),
59 typeof(CompositeEntry),
60 false);
61
65 public bool IsPassword
66 {
67 get => (bool)this.GetValue(IsPasswordProperty);
68 set => this.SetValue(IsPasswordProperty, value);
69 }
70
74 public static readonly BindableProperty EntryStyleProperty = BindableProperty.Create(
75 nameof(EntryStyle),
76 typeof(Style),
77 typeof(CompositeEntry));
78
82 public Style EntryStyle
83 {
84 get => (Style)this.GetValue(EntryStyleProperty);
85 set => this.SetValue(EntryStyleProperty, value);
86 }
87
91 public static readonly BindableProperty KeyboardProperty = BindableProperty.Create(
92 nameof(Keyboard),
93 typeof(Keyboard),
94 typeof(CompositeEntry),
95 Keyboard.Default);
96
101 {
102 get => (Keyboard)this.GetValue(KeyboardProperty);
103 set => this.SetValue(KeyboardProperty, value);
104 }
105
109 public static readonly BindableProperty TextColorProperty = BindableProperty.Create(
110 nameof(TextColor),
111 typeof(Color),
112 typeof(CompositeEntry),
113 Colors.Black);
114
118 public Color TextColor
119 {
120 get => (Color)this.GetValue(TextColorProperty);
121 set => this.SetValue(TextColorProperty, value);
122 }
123
124
125
126
130 public static readonly BindableProperty IsSpellCheckEnabledProperty = BindableProperty.Create(
131 nameof(IsSpellCheckEnabled),
132 typeof(bool),
133 typeof(CompositeEntry),
134 true);
135
140 {
141 get => (bool)this.GetValue(IsSpellCheckEnabledProperty);
142 set => this.SetValue(IsSpellCheckEnabledProperty, value);
143 }
144
148 public static readonly BindableProperty IsTextPredictionEnabledProperty = BindableProperty.Create(
150 typeof(bool),
151 typeof(CompositeEntry),
152 true);
153
158 {
159 get => (bool)this.GetValue(IsTextPredictionEnabledProperty);
160 set => this.SetValue(IsTextPredictionEnabledProperty, value);
161 }
162
166 public static readonly BindableProperty IsReadOnlyProperty = BindableProperty.Create(
167 nameof(IsReadOnly),
168 typeof(bool),
169 typeof(CompositeEntry),
170 false);
171
175 public bool IsReadOnly
176 {
177 get => (bool)this.GetValue(IsReadOnlyProperty);
178 set => this.SetValue(IsReadOnlyProperty, value);
179 }
180
181 // Define the new BackgroundColor property
182 public static new readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
183 nameof(BackgroundColor),
184 typeof(Color),
185 typeof(CompositeEntry),
186 Colors.Transparent);
187
188 public new Color BackgroundColor
189 {
190 get => (Color)this.GetValue(BackgroundColorProperty);
191 set => this.SetValue(BackgroundColorProperty, value);
192 }
193
194 #endregion
195
196 #region Fields
197
198 private readonly Entry innerEntry;
199
200 #endregion
201
202 #region Events
203
207 public event EventHandler? Completed;
208
212 public event EventHandler<TextChangedEventArgs>? TextChanged;
213
217 public new event EventHandler<FocusEventArgs>? Focused;
218
222 public new event EventHandler<FocusEventArgs>? Unfocused;
223
224 #endregion
225
226 #region Constructor
227
232 {
233 // Initialize the inner Entry
234 this.innerEntry = new Entry
235 {
236 VerticalOptions = LayoutOptions.Center,
237 HorizontalOptions = LayoutOptions.Fill,
238 BackgroundColor = Colors.Transparent
239 };
240
241 // Set up bindings for the Entry
242 this.innerEntry.SetBinding(Entry.TextProperty, new Binding(nameof(this.EntryData), source: this));
243 this.innerEntry.SetBinding(Entry.PlaceholderProperty, new Binding(nameof(this.Placeholder), source: this));
244 this.innerEntry.SetBinding(Entry.IsPasswordProperty, new Binding(nameof(this.IsPassword), source: this));
245 this.innerEntry.SetBinding(Entry.KeyboardProperty, new Binding(nameof(this.Keyboard), source: this));
246 this.innerEntry.SetBinding(Entry.StyleProperty, new Binding(nameof(this.EntryStyle), source: this));
247 this.innerEntry.SetBinding(Entry.TextColorProperty, new Binding(nameof(this.TextColor), source: this));
248 this.innerEntry.SetBinding(InputView.IsSpellCheckEnabledProperty, new Binding(nameof(this.IsSpellCheckEnabled), source: this));
249 this.innerEntry.SetBinding(InputView.IsTextPredictionEnabledProperty, new Binding(nameof(this.IsTextPredictionEnabled), source: this));
250 this.innerEntry.SetBinding(Entry.IsReadOnlyProperty, new Binding(nameof(this.IsReadOnly), source: this));
251
252 // Handle events
253 this.innerEntry.Completed += this.OnEntryCompleted;
254 this.innerEntry.TextChanged += this.OnEntryTextChanged;
255 this.innerEntry.Focused += this.OnEntryFocused;
256 this.innerEntry.Unfocused += this.OnEntryUnfocused;
257
258 // Initialize the top label
259 this.CenterView = this.innerEntry;
260 }
261
262 #endregion
263
264 #region Property Overrides
265
270 public new string StyleId
271 {
272 get => this.innerEntry.StyleId;
273 set => this.innerEntry.StyleId = value;
274 }
275
276 public new string AutomationId
277 {
278 get => this.innerEntry.AutomationId;
279 set => this.innerEntry.AutomationId = value;
280 }
281
282 #endregion
283
284 #region Methods
285
289 public new bool Focus()
290 {
291 return this.innerEntry.Focus();
292 }
293
297 public new void Unfocus()
298 {
299 this.innerEntry.Unfocus();
300 }
301
302 #endregion
303
304 #region Property Changed Callbacks
305
306 #endregion
307
308 #region Event Handlers
309
310 private void OnEntryTextChanged(object? sender, TextChangedEventArgs e)
311 {
312 TextChanged.Raise(this, e);
313 }
314
319 private void OnEntryCompleted(object? sender, EventArgs e)
320 {
321 Completed.Raise(this, e);
322 }
323
328 private void OnEntryFocused(object? sender, FocusEventArgs e)
329 {
330 Focused.Raise(this, e);
331
332 }
333
338 private void OnEntryUnfocused(object? sender, FocusEventArgs e)
339 {
340 Unfocused.Raise(this, e);
341 }
342
343 #endregion
344 }
345}
A customizable entry control that allows setting views on the left and right sides of the entry.
string EntryData
Gets or sets the text displayed in the entry.
Keyboard Keyboard
Gets or sets the keyboard type used by the entry.
bool IsReadOnly
Gets or sets a value indicating whether text prediction is enabled.
new? EventHandler< FocusEventArgs > Unfocused
Occurs when the entry loses focus.
string Placeholder
Gets or sets the placeholder text displayed when the entry is empty.
bool IsSpellCheckEnabled
Gets or sets a value indicating whether spell check is enabled.
static readonly BindableProperty EntryDataProperty
Bindable property for the text displayed in the entry.
static readonly BindableProperty IsPasswordProperty
Bindable property indicating whether the entry is used for password input.
new void Unfocus()
Unfocuses the Entry.
static readonly BindableProperty IsSpellCheckEnabledProperty
Bindable property indicating whether spell check is enabled.
Style EntryStyle
Gets or sets the style applied to the entry.
static readonly BindableProperty EntryStyleProperty
Bindable property for the style applied to the entry.
CompositeEntry()
Initializes a new instance of the CompositeEntry class.
Color TextColor
Gets or sets the text color of the entry.
static readonly BindableProperty PlaceholderProperty
Bindable property for the placeholder text displayed when the entry is empty.
EventHandler< TextChangedEventArgs >? TextChanged
Occurs when the text of the entry changes.
new? EventHandler< FocusEventArgs > Focused
Occurs when the entry gains focus.
new bool Focus()
Focuses the Entry.
new string StyleId
Gets or sets a user-defined value to uniquely identify the element. This is forwarded to the inner En...
EventHandler? Completed
Occurs when the user finalizes the text in an entry with the return key.
bool IsPassword
Gets or sets a value indicating whether the entry is used for password input.
bool IsTextPredictionEnabled
Gets or sets a value indicating whether text prediction is enabled.
static readonly BindableProperty IsReadOnlyProperty
Bindable property indicating whether Read Only is enabled.
static readonly BindableProperty KeyboardProperty
Bindable property for the keyboard type used by the entry.
static readonly BindableProperty TextColorProperty
Bindable property for the text color of the entry.
static readonly BindableProperty IsTextPredictionEnabledProperty
Bindable property indicating whether text prediction is enabled.