summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-03-06 10:35:17 +0100
committerGitHub <noreply@github.com>2017-03-06 10:35:17 +0100
commit8bc7ba3faade6e7396347f20dd8968fd35491671 (patch)
treeb7427708c6771d38fb7bcc0b099eb492f4b4b93c /Xamarin.Forms.Core
parentbc53ebe2bfb1bfc1b3e4c8f098691670337b3412 (diff)
downloadxamarin-forms-8bc7ba3faade6e7396347f20dd8968fd35491671.tar.gz
xamarin-forms-8bc7ba3faade6e7396347f20dd8968fd35491671.tar.bz2
xamarin-forms-8bc7ba3faade6e7396347f20dd8968fd35491671.zip
[C] ITextElement and TextElement (#789)
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/Button.cs15
-rw-r--r--Xamarin.Forms.Core/DatePicker.cs12
-rw-r--r--Xamarin.Forms.Core/Editor.cs13
-rw-r--r--Xamarin.Forms.Core/Entry.cs12
-rw-r--r--Xamarin.Forms.Core/ITextElement.cs13
-rw-r--r--Xamarin.Forms.Core/Label.cs12
-rw-r--r--Xamarin.Forms.Core/Picker.cs13
-rw-r--r--Xamarin.Forms.Core/SearchBar.cs12
-rw-r--r--Xamarin.Forms.Core/TextElement.cs14
-rw-r--r--Xamarin.Forms.Core/TimePicker.cs12
-rw-r--r--Xamarin.Forms.Core/Xamarin.Forms.Core.csproj4
11 files changed, 96 insertions, 36 deletions
diff --git a/Xamarin.Forms.Core/Button.cs b/Xamarin.Forms.Core/Button.cs
index 9db917bc..32366f77 100644
--- a/Xamarin.Forms.Core/Button.cs
+++ b/Xamarin.Forms.Core/Button.cs
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
-using System.Globalization;
using System.Windows.Input;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform;
@@ -8,7 +7,7 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_ButtonRenderer))]
- public class Button : View, IFontElement, IButtonController, IElementConfiguration<Button>
+ public class Button : View, IFontElement, ITextElement, IButtonController, IElementConfiguration<Button>
{
public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(Button), null, propertyChanged: (bo, o, n) => ((Button)bo).OnCommandChanged());
@@ -21,7 +20,7 @@ namespace Xamarin.Forms
public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Button), null,
propertyChanged: (bindable, oldVal, newVal) => ((Button)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged));
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Button), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty FontProperty = FontElement.FontProperty;
@@ -101,8 +100,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
bool IsEnabledCore
@@ -237,6 +236,10 @@ namespace Xamarin.Forms
oldvalue.SourceChanged -= OnSourceChanged;
}
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
+
[DebuggerDisplay("Image Position = {Position}, Spacing = {Spacing}")]
[TypeConverter(typeof(ButtonContentTypeConverter))]
public sealed class ButtonContentLayout
@@ -304,4 +307,4 @@ namespace Xamarin.Forms
}
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Core/DatePicker.cs b/Xamarin.Forms.Core/DatePicker.cs
index 9ef7a7eb..ed16a870 100644
--- a/Xamarin.Forms.Core/DatePicker.cs
+++ b/Xamarin.Forms.Core/DatePicker.cs
@@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_DatePickerRenderer))]
- public class DatePicker : View, IElementConfiguration<DatePicker>
+ public class DatePicker : View, ITextElement,IElementConfiguration<DatePicker>
{
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(DatePicker), "d");
@@ -17,7 +17,7 @@ namespace Xamarin.Forms
public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(nameof(MaximumDate), typeof(DateTime), typeof(DatePicker), new DateTime(2100, 12, 31),
validateValue: ValidateMaximumDate, coerceValue: CoerceMaximumDate);
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(DatePicker), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
readonly Lazy<PlatformConfigurationRegistry<DatePicker>> _platformConfigurationRegistry;
@@ -52,8 +52,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public event EventHandler<DateChangedEventArgs> DateSelected;
@@ -115,5 +115,9 @@ namespace Xamarin.Forms
{
return _platformConfigurationRegistry.Value.On<T>();
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Editor.cs b/Xamarin.Forms.Core/Editor.cs
index ee9d4422..35aaf43f 100644
--- a/Xamarin.Forms.Core/Editor.cs
+++ b/Xamarin.Forms.Core/Editor.cs
@@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_EditorRenderer))]
- public class Editor : InputView, IEditorController, IFontElement, IElementConfiguration<Editor>
+ public class Editor : InputView, IEditorController, IFontElement, ITextElement, IElementConfiguration<Editor>
{
public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Editor), null, BindingMode.TwoWay, propertyChanged: (bindable, oldValue, newValue) =>
{
@@ -19,7 +19,8 @@ namespace Xamarin.Forms
public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Editor), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
+
readonly Lazy<PlatformConfigurationRegistry<Editor>> _platformConfigurationRegistry;
public string Text
@@ -30,8 +31,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public FontAttributes FontAttributes
@@ -92,5 +93,9 @@ namespace Xamarin.Forms
if (handler != null)
handler(this, EventArgs.Empty);
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Entry.cs b/Xamarin.Forms.Core/Entry.cs
index 610a30d8..3c63c13b 100644
--- a/Xamarin.Forms.Core/Entry.cs
+++ b/Xamarin.Forms.Core/Entry.cs
@@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_EntryRenderer))]
- public class Entry : InputView, IFontElement, IEntryController, IElementConfiguration<Entry>
+ public class Entry : InputView, IFontElement, ITextElement, IEntryController, IElementConfiguration<Entry>
{
public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create("Placeholder", typeof(string), typeof(Entry), default(string));
@@ -12,7 +12,7 @@ namespace Xamarin.Forms
public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Entry), null, BindingMode.TwoWay, propertyChanged: OnTextChanged);
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Entry), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty HorizontalTextAlignmentProperty = BindableProperty.Create("HorizontalTextAlignment", typeof(TextAlignment), typeof(Entry), TextAlignment.Start);
@@ -63,8 +63,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public FontAttributes FontAttributes
@@ -125,5 +125,9 @@ namespace Xamarin.Forms
{
return _platformConfigurationRegistry.Value.On<T>();
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/ITextElement.cs b/Xamarin.Forms.Core/ITextElement.cs
new file mode 100644
index 00000000..8ba4e9bd
--- /dev/null
+++ b/Xamarin.Forms.Core/ITextElement.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Xamarin.Forms
+{
+ interface ITextElement
+ {
+ //note to implementor: implement the properties publicly
+ Color TextColor { get; }
+
+ //note to implementor: but implement the methods explicitly
+ void OnTextColorPropertyChanged(Color oldValue, Color newValue);
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Label.cs b/Xamarin.Forms.Core/Label.cs
index 052289b6..b9794118 100644
--- a/Xamarin.Forms.Core/Label.cs
+++ b/Xamarin.Forms.Core/Label.cs
@@ -7,7 +7,7 @@ namespace Xamarin.Forms
{
[ContentProperty("Text")]
[RenderWith(typeof(_LabelRenderer))]
- public class Label : View, IFontElement, IElementConfiguration<Label>
+ public class Label : View, IFontElement, ITextElement, IElementConfiguration<Label>
{
public static readonly BindableProperty HorizontalTextAlignmentProperty = BindableProperty.Create("HorizontalTextAlignment", typeof(TextAlignment), typeof(Label), TextAlignment.Start,
propertyChanged: OnHorizontalTextAlignmentPropertyChanged);
@@ -21,7 +21,7 @@ namespace Xamarin.Forms
[Obsolete("YAlignProperty is obsolete. Please use VerticalTextAlignmentProperty instead.")]
public static readonly BindableProperty YAlignProperty = VerticalTextAlignmentProperty;
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Label), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty FontProperty = FontElement.FontProperty;
@@ -90,8 +90,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public TextAlignment VerticalTextAlignment
@@ -186,5 +186,9 @@ namespace Xamarin.Forms
{
return _platformConfigurationRegistry.Value.On<T>();
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Picker.cs b/Xamarin.Forms.Core/Picker.cs
index ad85f489..0d85ea5c 100644
--- a/Xamarin.Forms.Core/Picker.cs
+++ b/Xamarin.Forms.Core/Picker.cs
@@ -10,10 +10,9 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_PickerRenderer))]
- public class Picker : View, IElementConfiguration<Picker>
+ public class Picker : View, ITextElement, IElementConfiguration<Picker>
{
- public static readonly BindableProperty TextColorProperty =
- BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(Picker), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty TitleProperty =
BindableProperty.Create(nameof(Title), typeof(string), typeof(Picker), default(string));
@@ -59,8 +58,8 @@ namespace Xamarin.Forms
}
public Color TextColor {
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public string Title {
@@ -220,6 +219,10 @@ namespace Xamarin.Forms
return _platformConfigurationRegistry.Value.On<T>();
}
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
+
internal class LockableObservableListWrapper : IList<string>, ICollection<string>, INotifyCollectionChanged, INotifyPropertyChanged, IReadOnlyList<string>, IReadOnlyCollection<string>, IEnumerable<string>, IEnumerable
{
internal readonly ObservableCollection<string> _list = new ObservableCollection<string>();
diff --git a/Xamarin.Forms.Core/SearchBar.cs b/Xamarin.Forms.Core/SearchBar.cs
index a7d01b67..614671b1 100644
--- a/Xamarin.Forms.Core/SearchBar.cs
+++ b/Xamarin.Forms.Core/SearchBar.cs
@@ -5,7 +5,7 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_SearchBarRenderer))]
- public class SearchBar : View, IFontElement, ISearchBarController, IElementConfiguration<SearchBar>
+ public class SearchBar : View, IFontElement, ITextElement, ISearchBarController, IElementConfiguration<SearchBar>
{
public static readonly BindableProperty SearchCommandProperty = BindableProperty.Create("SearchCommand", typeof(ICommand), typeof(SearchBar), null, propertyChanged: OnCommandChanged);
@@ -32,7 +32,7 @@ namespace Xamarin.Forms
public static readonly BindableProperty HorizontalTextAlignmentProperty = BindableProperty.Create("HorizontalTextAlignment", typeof(TextAlignment), typeof(SearchBar), TextAlignment.Start);
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(SearchBar), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty PlaceholderColorProperty = BindableProperty.Create("PlaceholderColor", typeof(Color), typeof(SearchBar), Color.Default);
@@ -82,8 +82,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
bool IsEnabledCore
@@ -182,5 +182,9 @@ namespace Xamarin.Forms
{
return _platformConfigurationRegistry.Value.On<T>();
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/TextElement.cs b/Xamarin.Forms.Core/TextElement.cs
new file mode 100644
index 00000000..d64024a6
--- /dev/null
+++ b/Xamarin.Forms.Core/TextElement.cs
@@ -0,0 +1,14 @@
+namespace Xamarin.Forms
+{
+ static class TextElement
+ {
+ public static readonly BindableProperty TextColorProperty =
+ BindableProperty.Create("TextColor", typeof(Color), typeof(Button), Color.Default,
+ propertyChanged: OnTextColorPropertyChanged);
+
+ static void OnTextColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ ((ITextElement)bindable).OnTextColorPropertyChanged((Color)oldValue, (Color)newValue);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/TimePicker.cs b/Xamarin.Forms.Core/TimePicker.cs
index a90b378e..4ac50939 100644
--- a/Xamarin.Forms.Core/TimePicker.cs
+++ b/Xamarin.Forms.Core/TimePicker.cs
@@ -4,11 +4,11 @@ using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_TimePickerRenderer))]
- public class TimePicker : View, IElementConfiguration<TimePicker>
+ public class TimePicker : View, ITextElement, IElementConfiguration<TimePicker>
{
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(TimePicker), "t");
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(TimePicker), Color.Default);
+ public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
public static readonly BindableProperty TimeProperty = BindableProperty.Create(nameof(Time), typeof(TimeSpan), typeof(TimePicker), new TimeSpan(0), BindingMode.TwoWay, (bindable, value) =>
{
@@ -31,8 +31,8 @@ namespace Xamarin.Forms
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get { return (Color)GetValue(TextElement.TextColorProperty); }
+ set { SetValue(TextElement.TextColorProperty, value); }
}
public TimeSpan Time
@@ -45,5 +45,9 @@ namespace Xamarin.Forms
{
return _platformConfigurationRegistry.Value.On<T>();
}
+
+ void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
+ {
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
index 71df2602..5436be5a 100644
--- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
+++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
@@ -450,6 +450,8 @@
<Compile Include="PlatformConfiguration\macOSSpecific\TabbedPage.cs" />
<Compile Include="PlatformConfiguration\macOSSpecific\TabsStyle.cs" />
<Compile Include="FontElement.cs" />
+ <Compile Include="ITextElement.cs" />
+ <Compile Include="TextElement.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ItemGroup>
@@ -467,4 +469,4 @@
<ItemGroup>
<Folder Include="PlatformConfiguration\macOSSpecific\" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>