180 lines
5.7 KiB
C#
180 lines
5.7 KiB
C#
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Sarand.Net.Mobile.Maui.Controls.Views
|
|
{
|
|
//=======================================================================
|
|
public class SamEntryPanel : SamControlPanel
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly SamEntry entry = new SamEntry() { HorizontalOptions = LayoutOptions.Fill };
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SamEntryPanel()
|
|
{
|
|
// View configuration.
|
|
HorizontalOptions = LayoutOptions.Start;
|
|
|
|
// Control configuration.
|
|
entry.BackgroundColor = Colors.Transparent;
|
|
|
|
// Entry events.
|
|
entry.Focused += Entry_Focused;
|
|
entry.Unfocused += Entry_Unfocused;
|
|
entry.TextChanged += Entry_TextChanged;
|
|
entry.Completed += Entry_Completed;
|
|
|
|
SetControlActivity();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
protected override View ControlView { get { return entry; } }
|
|
public int MaxLength
|
|
{
|
|
get { return entry.MaxLength; }
|
|
set { entry.MaxLength = value; }
|
|
}
|
|
public SamEntry.TextCaseType TextCase
|
|
{
|
|
get { return entry.TextCase; }
|
|
set { entry.TextCase = value; }
|
|
}
|
|
public bool NumericOnly
|
|
{
|
|
get { return entry.NumericOnly; }
|
|
set { entry.NumericOnly = value; ReadOnlyLabel.HorizontalTextAlignment = entry.HorizontalTextAlignment; }
|
|
}
|
|
public byte Decimals
|
|
{
|
|
get { return entry.Decimals; }
|
|
set { entry.Decimals = value; ReadOnlyLabel.HorizontalTextAlignment = entry.HorizontalTextAlignment; }
|
|
}
|
|
public Keyboard Keyboard
|
|
{
|
|
get { return entry.Keyboard; }
|
|
set { entry.Keyboard = value; }
|
|
}
|
|
public bool IsPassword
|
|
{
|
|
get { return entry.IsPassword; }
|
|
set { entry.IsPassword = value; }
|
|
}
|
|
public String Text
|
|
{
|
|
get { return entry.Text; }
|
|
set { value = StringUtil.EmptyOnNull(value); if (entry.Text != null && entry.Text.Equals(value)) return; entry.Text = value; }
|
|
}
|
|
public new double WidthRequest
|
|
{
|
|
get { return entry.WidthRequest; }
|
|
set { entry.WidthRequest = value; ReadOnlyLabel.WidthRequest = value; }
|
|
}
|
|
public TextAlignment HorizontalTextAlignment
|
|
{
|
|
get { return entry.HorizontalTextAlignment; }
|
|
set { entry.HorizontalTextAlignment = value; ReadOnlyLabel.HorizontalTextAlignment = entry.HorizontalTextAlignment; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n f i g u r e C o m p o n e n t s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Control configuration that can be changed dynamically.</summary>
|
|
public override void ConfigureComponents()
|
|
{
|
|
base.ConfigureComponents();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n t r o l A c t i v i t y
|
|
//-------------------------------------------------------------------
|
|
public override void SetControlActivity()
|
|
{
|
|
base.SetControlActivity();
|
|
SetControlsReadOnly();
|
|
}
|
|
public override void SetControlsReadOnly()
|
|
{
|
|
base.SetControlsReadOnly();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n t r o l E v e n t s
|
|
//-------------------------------------------------------------------
|
|
private void Entry_Focused(object? sender, FocusEventArgs e)
|
|
{
|
|
Control_Focused(sender, e);
|
|
}
|
|
//-------------------------------------------------------------------
|
|
private void Entry_Unfocused(object? sender, FocusEventArgs e)
|
|
{
|
|
Control_Unfocused(sender, e);
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Text changed.
|
|
public event EventHandler<TextChangedEventArgs>? TextChanged;
|
|
private void Entry_TextChanged(object? sender, TextChangedEventArgs e)
|
|
{
|
|
ReadOnlyText = entry.Text;
|
|
if (ReadOnly) return;
|
|
if (TextChanged != null) TextChanged.Invoke(sender, e);
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Completed.
|
|
public event EventHandler? Completed;
|
|
private void Entry_Completed(object? sender, EventArgs e)
|
|
{
|
|
if (ReadOnly) return;
|
|
if (Completed != null) Completed.Invoke(sender, e);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// V i e w E v e n t s
|
|
//-------------------------------------------------------------------
|
|
protected override void OnParentSet()
|
|
{
|
|
base.OnParentSet();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
protected override void OnPropertyChanging([CallerMemberName] string propertyName = "")
|
|
{
|
|
base.OnPropertyChanging(propertyName);
|
|
}
|
|
protected override void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
base.OnPropertyChanged(propertyName);
|
|
//Logger.Debug(GetType().Name + ".OnPropertyChanged Name=" + propertyName);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
protected override void OnChildAdded(Element child)
|
|
{
|
|
base.OnChildAdded(child);
|
|
}
|
|
protected override void OnChildRemoved(Element child, int oldLogicalIndex)
|
|
{
|
|
base.OnChildRemoved(child, oldLogicalIndex);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
protected override void OnSizeAllocated(double width, double height)
|
|
{
|
|
base.OnSizeAllocated(width, height);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|