mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Meta - Replace WPF projects with Avalonia projects
This commit is contained in:
1 parent
fcf0376a9a
commit
d7f3ee1190
1110 files changed
+10872
-52240
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Artemis.UI.Shared.AttachedProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Helper properties for working with TextBoxes.
|
||||
/// </summary>
|
||||
public class TextBoxAssist : AvaloniaObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <seealso cref="SuffixTextProperty" /> Avalonia attached property.
|
||||
/// </summary>
|
||||
/// <value>Provide an <see cref="ICommand" /> derived object or binding.</value>
|
||||
public static readonly AttachedProperty<string> SuffixTextProperty = AvaloniaProperty.RegisterAttached<TextBoxAssist, string>("SuffixText", typeof(TextBox));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <seealso cref="PrefixTextProperty" /> Avalonia attached property.
|
||||
/// </summary>
|
||||
/// <value>Provide an <see cref="ICommand" /> derived object or binding.</value>
|
||||
public static readonly AttachedProperty<string> PrefixTextProperty = AvaloniaProperty.RegisterAttached<TextBoxAssist, string>("PrefixText", typeof(TextBox));
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for Attached property <see cref="SuffixTextProperty" />.
|
||||
/// </summary>
|
||||
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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for Attached property <see cref="SuffixTextProperty" />.
|
||||
/// </summary>
|
||||
public static string GetSuffixText(AvaloniaObject element)
|
||||
{
|
||||
return element.GetValue(SuffixTextProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for Attached property <see cref="PrefixTextProperty" />.
|
||||
/// </summary>
|
||||
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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for Attached property <see cref="PrefixTextProperty" />.
|
||||
/// </summary>
|
||||
public static string GetPrefixText(AvaloniaObject element)
|
||||
{
|
||||
return element.GetValue(PrefixTextProperty);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user