Merge pull request #12 from dotnet/entry-more-properties
Implement more Entry properties
This commit is contained in:
Коммит
f9b8472e84
|
@ -143,9 +143,9 @@ Here you find a list of all controls with their (public) APIs and their status.
|
|||
| CharacterSpacing | ⚠️ | ⚠️ | ⚠️ |
|
||||
| Completed | ⚠️ | ⚠️ | ⚠️ |
|
||||
| CursorPosition | ⚠️ | ⚠️ | ⚠️ |
|
||||
| FontAttributes | ⚠️ | ⚠️ | ⚠️ |
|
||||
| FontFamily | ⚠️ | ⚠️ | ⚠️ |
|
||||
| FontSize | ⚠️ | ⚠️ | ⚠️ |
|
||||
| FontAttributes | ✅ | ✅ | ✅ |
|
||||
| FontFamily | ✅ | ✅ | ✅ |
|
||||
| FontSize | ✅ | ✅ | ✅ |
|
||||
| HorizontalTextAlignment | ⚠️ | ⚠️ | ⚠️ |
|
||||
| IsTextPredictionEnabled | ⚠️ | ⚠️ | ⚠️ |
|
||||
| IsPassword | ⚠️ | ⚠️ | ⚠️ |
|
||||
|
|
|
@ -66,6 +66,15 @@ namespace GraphicsControls
|
|||
|
||||
public static readonly BindableProperty PlaceholderColorProperty = InputElement.PlaceholderColorProperty;
|
||||
|
||||
public static readonly BindableProperty FontAttributesProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontAttributes), typeof(FontAttributes), typeof(IFont), FontAttributes.None);
|
||||
|
||||
public static readonly BindableProperty FontFamilyProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontFamily), typeof(string), typeof(IFont), string.Empty);
|
||||
|
||||
public static readonly BindableProperty FontSizeProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontSize), typeof(double), typeof(IInput), Device.GetNamedSize(NamedSize.Medium, typeof(Label)));
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
|
@ -96,6 +105,24 @@ namespace GraphicsControls
|
|||
set { SetValue(PlaceholderColorProperty, value); }
|
||||
}
|
||||
|
||||
public FontAttributes FontAttributes
|
||||
{
|
||||
get { return (FontAttributes)GetValue(FontAttributesProperty); }
|
||||
set { SetValue(FontAttributesProperty, value); }
|
||||
}
|
||||
|
||||
public string FontFamily
|
||||
{
|
||||
get { return (string)GetValue(FontFamilyProperty); }
|
||||
set { SetValue(FontFamilyProperty, value); }
|
||||
}
|
||||
|
||||
public double FontSize
|
||||
{
|
||||
get { return (double)GetValue(FontSizeProperty); }
|
||||
set { SetValue(FontSizeProperty, value); }
|
||||
}
|
||||
|
||||
public event EventHandler Completed;
|
||||
|
||||
public List<string> EditorLayers = new List<string>
|
||||
|
|
|
@ -72,6 +72,33 @@ namespace GraphicsControls
|
|||
|
||||
public static readonly BindableProperty PlaceholderColorProperty = InputElement.PlaceholderColorProperty;
|
||||
|
||||
public static readonly BindableProperty FontAttributesProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontAttributes), typeof(FontAttributes), typeof(IFont), FontAttributes.None,
|
||||
propertyChanged: OnFontAttributesChanged);
|
||||
|
||||
private static void OnFontAttributesChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
(bindable as Entry)?.UpdateFontAttributes();
|
||||
}
|
||||
|
||||
public static readonly BindableProperty FontFamilyProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontFamily), typeof(string), typeof(IFont), string.Empty,
|
||||
propertyChanged: OnFontFamilyChanged);
|
||||
|
||||
private static void OnFontFamilyChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
(bindable as Entry)?.UpdateFontFamily();
|
||||
}
|
||||
|
||||
public static readonly BindableProperty FontSizeProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontSize), typeof(double), typeof(IInput), Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
|
||||
propertyChanged: OnFontSizeChanged);
|
||||
|
||||
private static void OnFontSizeChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
(bindable as Entry)?.UpdateFontSize();
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
|
@ -102,6 +129,24 @@ namespace GraphicsControls
|
|||
set { SetValue(PlaceholderColorProperty, value); }
|
||||
}
|
||||
|
||||
public FontAttributes FontAttributes
|
||||
{
|
||||
get { return (FontAttributes)GetValue(FontAttributesProperty); }
|
||||
set { SetValue(FontAttributesProperty, value); }
|
||||
}
|
||||
|
||||
public string FontFamily
|
||||
{
|
||||
get { return (string)GetValue(FontFamilyProperty); }
|
||||
set { SetValue(FontFamilyProperty, value); }
|
||||
}
|
||||
|
||||
public double FontSize
|
||||
{
|
||||
get { return (double)GetValue(FontSizeProperty); }
|
||||
set { SetValue(FontSizeProperty, value); }
|
||||
}
|
||||
|
||||
public List<string> EntryLayers = new List<string>
|
||||
{
|
||||
Layers.Background,
|
||||
|
@ -140,6 +185,10 @@ namespace GraphicsControls
|
|||
UpdateTextColor();
|
||||
UpdateCharacterSpacing();
|
||||
UpdateFlowDirection();
|
||||
UpdateFontAttributes();
|
||||
UpdateFontFamily();
|
||||
UpdateFontSize();
|
||||
|
||||
}
|
||||
|
||||
public override void Unload()
|
||||
|
@ -351,5 +400,20 @@ namespace GraphicsControls
|
|||
{
|
||||
_entry.FlowDirection = FlowDirection;
|
||||
}
|
||||
|
||||
void UpdateFontAttributes()
|
||||
{
|
||||
_entry.FontAttributes = FontAttributes;
|
||||
}
|
||||
|
||||
void UpdateFontFamily()
|
||||
{
|
||||
_entry.FontFamily = FontFamily;
|
||||
}
|
||||
|
||||
void UpdateFontSize()
|
||||
{
|
||||
_entry.FontSize = FontSize;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace GraphicsControls
|
||||
{
|
||||
public interface IFont : IText
|
||||
{
|
||||
FontAttributes FontAttributes { get; }
|
||||
string FontFamily { get; }
|
||||
double FontSize { get; }
|
||||
}
|
||||
|
||||
public static class FontElement
|
||||
{
|
||||
public static readonly BindableProperty FontAttributesProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontAttributes), typeof(FontAttributes), typeof(IFont), FontAttributes.None);
|
||||
|
||||
public static readonly BindableProperty FontFamilyProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontFamily), typeof(string), typeof(IFont), string.Empty);
|
||||
|
||||
public static readonly BindableProperty FontSizeProperty =
|
||||
BindableProperty.Create(nameof(IFont.FontSize), typeof(double), typeof(IFont),
|
||||
Device.GetNamedSize(NamedSize.Medium, typeof(Label)));
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace GraphicsControls
|
||||
{
|
||||
public interface IInput : IText, IPlaceholder
|
||||
public interface IInput : IText, IPlaceholder, IFont
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче