using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
namespace Artemis.UI.Shared.AttachedProperties;
///
/// Helper properties for working with TextBoxes.
///
public class TextBoxAssist : AvaloniaObject
{
///
/// Identifies the Avalonia attached property.
///
/// Provide an derived object or binding.
public static readonly AttachedProperty SuffixTextProperty = AvaloniaProperty.RegisterAttached("SuffixText", typeof(TextBox));
///
/// Identifies the Avalonia attached property.
///
/// Provide an derived object or binding.
public static readonly AttachedProperty PrefixTextProperty = AvaloniaProperty.RegisterAttached("PrefixText", typeof(TextBox));
///
/// Accessor for Attached property .
///
public static void SetSuffixText(AvaloniaObject element, string value)
{
element.SetValue(SuffixTextProperty, value);
if (!string.IsNullOrWhiteSpace(value) && !((TextBox) element).Classes.Contains("suffixed"))
((TextBox) element).Classes.Add("suffixed");
else
((TextBox) element).Classes.Remove("suffixed");
}
///
/// Accessor for Attached property .
///
public static string GetSuffixText(AvaloniaObject element)
{
return element.GetValue(SuffixTextProperty);
}
///
/// Accessor for Attached property .
///
public static void SetPrefixText(AvaloniaObject element, string value)
{
element.SetValue(PrefixTextProperty, value);
if (!string.IsNullOrWhiteSpace(value) && !((TextBox) element).Classes.Contains("prefixed"))
((TextBox) element).Classes.Add("prefixed");
else
((TextBox) element).Classes.Remove("prefixed");
}
///
/// Accessor for Attached property .
///
public static string GetPrefixText(AvaloniaObject element)
{
return element.GetValue(PrefixTextProperty);
}
}