summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-07-10 06:40:00 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-07-10 06:40:00 (GMT)
commit509e6f117c9966e5503deb8ff1c5135b41eb2a3e (patch)
tree4289d7d9305c646b6bc6e7201170721219e2c851
parentbfce37a60e9793cb1a1808833a149a1b8d248993 (diff)
downloadxamarin-forms-509e6f117c9966e5503deb8ff1c5135b41eb2a3e.zip
xamarin-forms-509e6f117c9966e5503deb8ff1c5135b41eb2a3e.tar.gz
xamarin-forms-509e6f117c9966e5503deb8ff1c5135b41eb2a3e.tar.bz2
Move registration of property handles to static constructorsrefs/changes/49/133249/4
Property handlers are registered once per class instead of once per instance. Solves the issue with UpdateAllProperties and Distinct. Change-Id: I41b3f6c0a055c7aa76300bf7a55683b0b25a21fd
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs16
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs11
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs16
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs28
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs19
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs18
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs15
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs25
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs9
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs11
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs4
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs10
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs74
19 files changed, 147 insertions, 151 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
index fdad3c7..cb72bcd 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ActivityIndicatorRenderer.cs
@@ -7,10 +7,10 @@ namespace Xamarin.Forms.Platform.Tizen
{
static readonly EColor s_defaultColor = new EColor(129, 198, 255);
- public ActivityIndicatorRenderer()
+ static ActivityIndicatorRenderer()
{
- RegisterPropertyHandler(ActivityIndicator.ColorProperty, UpdateColor);
- RegisterPropertyHandler(ActivityIndicator.IsRunningProperty, UpdateIsRunning);
+ RegisterPropertyHandler(ActivityIndicator.ColorProperty, (r, i) => (r as ActivityIndicatorRenderer).UpdateColor(i));
+ RegisterPropertyHandler(ActivityIndicator.IsRunningProperty, (r) => (r as ActivityIndicatorRenderer).UpdateIsRunning());
}
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
index 0125cfe..4de9604 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
@@ -6,14 +6,14 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class ButtonRenderer : ViewRenderer<Button, Native.Button>
{
- public ButtonRenderer()
+ static ButtonRenderer()
{
- RegisterPropertyHandler(Button.TextProperty, UpdateText);
- RegisterPropertyHandler(Button.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(Button.FontSizeProperty, UpdateFontSize);
- RegisterPropertyHandler(Button.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(Button.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(Button.ImageProperty, UpdateBitmap);
+ RegisterPropertyHandler(Button.TextProperty, (r) => (r as ButtonRenderer).UpdateText());
+ RegisterPropertyHandler(Button.FontFamilyProperty, (r) => (r as ButtonRenderer).UpdateFontFamily());
+ RegisterPropertyHandler(Button.FontSizeProperty, (r) => (r as ButtonRenderer).UpdateFontSize());
+ RegisterPropertyHandler(Button.FontAttributesProperty, (r) => (r as ButtonRenderer).UpdateFontAttributes());
+ RegisterPropertyHandler(Button.TextColorProperty, (r) => (r as ButtonRenderer).UpdateTextColor());
+ RegisterPropertyHandler(Button.ImageProperty, (r) => (r as ButtonRenderer).UpdateBitmap());
RegisterPropertyHandler(Button.BorderColorProperty, UpdateBorder);
RegisterPropertyHandler(Button.BorderRadiusProperty, UpdateBorder);
RegisterPropertyHandler(Button.BorderWidthProperty, UpdateBorder);
@@ -102,7 +102,7 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- void UpdateBorder()
+ static void UpdateBorder(VisualElementRenderer<Button> r)
{
/* The simpler way is to create some specialized theme for button in
* tizen-theme
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
index 714f41b..1380b77 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ContentPageRenderer.cs
@@ -13,13 +13,10 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
Native.ContentPage _page;
- /// <summary>
- /// Default constructor.
- /// </summary>
- public ContentPageRenderer()
+ static ContentPageRenderer()
{
- RegisterPropertyHandler(Page.BackgroundImageProperty, UpdateBackgroundImage);
- RegisterPropertyHandler(Page.TitleProperty, UpdateTitle);
+ RegisterPropertyHandler(Page.BackgroundImageProperty, (r, i) => (r as ContentPageRenderer).UpdateBackgroundImage(i));
+ RegisterPropertyHandler(Page.TitleProperty, (r) => (r as ContentPageRenderer).UpdateTitle());
}
protected override void OnElementChanged(ElementChangedEventArgs<ContentPage> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
index 39a2529..c4b88e8 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/DatePickerRenderer.cs
@@ -7,11 +7,11 @@ namespace Xamarin.Forms.Platform.Tizen
//TODO need to add internationalization support
const string DialogTitle = "Choose Date";
- public DatePickerRenderer()
+ static DatePickerRenderer()
{
RegisterPropertyHandler(DatePicker.DateProperty, UpdateDate);
RegisterPropertyHandler(DatePicker.FormatProperty, UpdateDate);
- RegisterPropertyHandler(DatePicker.TextColorProperty, UpdateTextColor);
+ RegisterPropertyHandler(DatePicker.TextColorProperty, (r) => (r as DatePickerRenderer).UpdateTextColor());
}
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
@@ -75,6 +75,11 @@ namespace Xamarin.Forms.Platform.Tizen
dialog.Dismissed -= OnDialogDismissed;
}
+ static void UpdateDate(VisualElementRenderer<DatePicker> renderer)
+ {
+ (renderer as DatePickerRenderer).UpdateDate();
+ }
+
void UpdateDate()
{
Control.Text = Element.Date.ToString(Element.Format);
@@ -85,4 +90,4 @@ namespace Xamarin.Forms.Platform.Tizen
Control.TextColor = Element.TextColor.ToNative();
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
index 39e018c..f8a1045 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
@@ -6,14 +6,14 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class EditorRenderer : ViewRenderer<Editor, Native.Entry>
{
- public EditorRenderer()
+ static EditorRenderer()
{
- RegisterPropertyHandler(Editor.TextProperty, UpdateText);
- RegisterPropertyHandler(Editor.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(Editor.FontSizeProperty, UpdateFontSize);
- RegisterPropertyHandler(Editor.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(Editor.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(Editor.KeyboardProperty, UpdateKeyboard);
+ RegisterPropertyHandler(Editor.TextProperty, (r) => (r as EditorRenderer).UpdateText());
+ RegisterPropertyHandler(Editor.TextColorProperty, (r) => (r as EditorRenderer).UpdateTextColor());
+ RegisterPropertyHandler(Editor.FontSizeProperty, (r) => (r as EditorRenderer).UpdateFontSize());
+ RegisterPropertyHandler(Editor.FontFamilyProperty, (r) => (r as EditorRenderer).UpdateFontFamily());
+ RegisterPropertyHandler(Editor.FontAttributesProperty, (r) => (r as EditorRenderer).UpdateFontAttributes());
+ RegisterPropertyHandler(Editor.KeyboardProperty, (r, i) => (r as EditorRenderer).UpdateKeyboard(i));
}
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
@@ -93,4 +93,4 @@ namespace Xamarin.Forms.Platform.Tizen
Control.Keyboard = Element.Keyboard.ToNative();
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
index 842aae8..b240b8d 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
@@ -6,21 +6,21 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class EntryRenderer : ViewRenderer<Entry, Native.Entry>, IDisposable
{
- public EntryRenderer()
- {
- RegisterPropertyHandler(Entry.IsPasswordProperty, UpdateIsPassword);
- RegisterPropertyHandler(Entry.TextProperty, UpdateText);
- RegisterPropertyHandler(Entry.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(Entry.FontSizeProperty, UpdateFontSize);
- RegisterPropertyHandler(Entry.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(Entry.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(Entry.HorizontalTextAlignmentProperty, UpdateHorizontalTextAlignment);
- RegisterPropertyHandler(Entry.KeyboardProperty, UpdateKeyboard);
- RegisterPropertyHandler(Entry.PlaceholderProperty, UpdatePlaceholder);
- RegisterPropertyHandler(Entry.PlaceholderColorProperty, UpdatePlaceholderColor);
+ static EntryRenderer()
+ {
+ RegisterPropertyHandler(Entry.IsPasswordProperty, (r) => (r as EntryRenderer).UpdateIsPassword());
+ RegisterPropertyHandler(Entry.TextProperty, (r) => (r as EntryRenderer).UpdateText());
+ RegisterPropertyHandler(Entry.TextColorProperty, (r) => (r as EntryRenderer).UpdateTextColor());
+ RegisterPropertyHandler(Entry.FontSizeProperty, (r) => (r as EntryRenderer).UpdateFontSize());
+ RegisterPropertyHandler(Entry.FontFamilyProperty, (r) => (r as EntryRenderer).UpdateFontFamily());
+ RegisterPropertyHandler(Entry.FontAttributesProperty, (r) => (r as EntryRenderer).UpdateFontAttributes());
+ RegisterPropertyHandler(Entry.HorizontalTextAlignmentProperty, (r) => (r as EntryRenderer).UpdateHorizontalTextAlignment());
+ RegisterPropertyHandler(Entry.KeyboardProperty, (r, i) => (r as EntryRenderer).UpdateKeyboard(i));
+ RegisterPropertyHandler(Entry.PlaceholderProperty, (r) => (r as EntryRenderer).UpdatePlaceholder());
+ RegisterPropertyHandler(Entry.PlaceholderColorProperty, (r) => (r as EntryRenderer).UpdatePlaceholderColor());
if (TizenPlatformServices.AppDomain.IsTizenSpecificAvailable)
{
- RegisterPropertyHandler("FontWeight", UpdateFontWeight);
+ RegisterPropertyHandler("FontWeight", (r) => (r as EntryRenderer).UpdateFontWeight());
}
}
@@ -131,4 +131,4 @@ namespace Xamarin.Forms.Platform.Tizen
Control.FontWeight = Specific.GetFontWeight(Element);
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
index 47bc703..414553f 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/FrameRenderer.cs
@@ -15,10 +15,10 @@ namespace Xamarin.Forms.Platform.Tizen
Polygon _shadow = null;
Polygon _frame = null;
- public FrameRenderer()
+ static FrameRenderer()
{
- RegisterPropertyHandler(Frame.OutlineColorProperty, UpdateColor);
- RegisterPropertyHandler(Frame.HasShadowProperty, UpdateShadowVisibility);
+ RegisterPropertyHandler(Frame.OutlineColorProperty, (r) => (r as FrameRenderer).UpdateColor());
+ RegisterPropertyHandler(Frame.HasShadowProperty, (r) => (r as FrameRenderer).UpdateShadowVisibility());
}
protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
index 42e8a15..16c36ec 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs
@@ -7,20 +7,19 @@ namespace Xamarin.Forms.Platform.Tizen
public class LabelRenderer : ViewRenderer<Label, Native.Label>
{
-
- public LabelRenderer()
+ static LabelRenderer()
{
- RegisterPropertyHandler(Label.TextProperty, UpdateText);
- RegisterPropertyHandler(Label.TextColorProperty, UpdateTextColor);
+ RegisterPropertyHandler(Label.TextProperty, (r) => (r as LabelRenderer).UpdateText());
+ RegisterPropertyHandler(Label.TextColorProperty, (r) => (r as LabelRenderer).UpdateTextColor());
// FontProperty change is called also for FontSizeProperty, FontFamilyProperty and FontAttributesProperty change
- RegisterPropertyHandler(Label.FontProperty, UpdateFontProperties);
- RegisterPropertyHandler(Label.LineBreakModeProperty, UpdateLineBreakMode);
- RegisterPropertyHandler(Label.HorizontalTextAlignmentProperty, UpdateHorizontalTextAlignment);
- RegisterPropertyHandler(Label.VerticalTextAlignmentProperty, UpdateVerticalTextAlignment);
- RegisterPropertyHandler(Label.FormattedTextProperty, UpdateFormattedText);
+ RegisterPropertyHandler(Label.FontProperty, (r) => (r as LabelRenderer).UpdateFontProperties());
+ RegisterPropertyHandler(Label.LineBreakModeProperty, (r) => (r as LabelRenderer).UpdateLineBreakMode());
+ RegisterPropertyHandler(Label.HorizontalTextAlignmentProperty, (r) => (r as LabelRenderer).UpdateHorizontalTextAlignment());
+ RegisterPropertyHandler(Label.VerticalTextAlignmentProperty, (r) => (r as LabelRenderer).UpdateVerticalTextAlignment());
+ RegisterPropertyHandler(Label.FormattedTextProperty, (r) => (r as LabelRenderer).UpdateFormattedText());
if (TizenPlatformServices.AppDomain.IsTizenSpecificAvailable)
{
- RegisterPropertyHandler("FontWeight", UpdateFontWeight);
+ RegisterPropertyHandler("FontWeight", (r) => (r as LabelRenderer).UpdateFontWeight());
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
index 1141afb..de86a25 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ListViewRenderer.cs
@@ -35,15 +35,15 @@ namespace Xamarin.Forms.Platform.Tizen
/// Note that at this stage of construction renderer dose not have required native element. This should
/// only be used with xamarin engine.
/// </summary>
- public ListViewRenderer()
+ static ListViewRenderer()
{
- RegisterPropertyHandler(ListView.IsGroupingEnabledProperty, UpdateIsGroupingEnabled);
- RegisterPropertyHandler(ListView.HasUnevenRowsProperty, UpdateHasUnevenRows);
- RegisterPropertyHandler(ListView.RowHeightProperty, UpdateRowHeight);
- RegisterPropertyHandler(ListView.SelectedItemProperty, UpdateSelectedItem);
- RegisterPropertyHandler(ListView.ItemsSourceProperty, UpdateSource);
- RegisterPropertyHandler("HeaderElement", UpdateHeader);
- RegisterPropertyHandler("FooterElement", UpdateFooter);
+ RegisterPropertyHandler(ListView.IsGroupingEnabledProperty, (r, i) => (r as ListViewRenderer).UpdateIsGroupingEnabled(i));
+ RegisterPropertyHandler(ListView.HasUnevenRowsProperty, (r) => (r as ListViewRenderer).UpdateHasUnevenRows());
+ RegisterPropertyHandler(ListView.RowHeightProperty, (r, i) => (r as ListViewRenderer).UpdateRowHeight(i));
+ RegisterPropertyHandler(ListView.SelectedItemProperty, (r) => (r as ListViewRenderer).UpdateSelectedItem());
+ RegisterPropertyHandler(ListView.ItemsSourceProperty, (r) => (r as ListViewRenderer).UpdateSource());
+ RegisterPropertyHandler("HeaderElement", (r) => (r as ListViewRenderer).UpdateHeader());
+ RegisterPropertyHandler("FooterElement", (r) => (r as ListViewRenderer).UpdateFooter());
}
/// <summary>
@@ -382,4 +382,4 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
index 0608039..2acfb3a 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailPageRenderer.cs
@@ -6,19 +6,16 @@ namespace Xamarin.Forms.Platform.Tizen
{
Native.MasterDetailPage _mdpage;
- /// <summary>
- /// Default constructor.
- /// </summary>
- public MasterDetailPageRenderer()
+ static MasterDetailPageRenderer()
{
- RegisterPropertyHandler("Master", UpdateMasterPage);
- RegisterPropertyHandler("Detail", UpdateDetailPage);
+ RegisterPropertyHandler("Master", (r) => (r as MasterDetailPageRenderer).UpdateMasterPage());
+ RegisterPropertyHandler("Detail", (r) => (r as MasterDetailPageRenderer).UpdateDetailPage());
RegisterPropertyHandler(MasterDetailPage.IsPresentedProperty,
- UpdateIsPresented);
+ (r) => (r as MasterDetailPageRenderer).UpdateIsPresented());
RegisterPropertyHandler(MasterDetailPage.MasterBehaviorProperty,
- UpdateMasterBehavior);
+ (r) => (r as MasterDetailPageRenderer).UpdateMasterBehavior());
RegisterPropertyHandler(MasterDetailPage.IsGestureEnabledProperty,
- UpdateIsGestureEnabled);
+ (r) => (r as MasterDetailPageRenderer).UpdateIsGestureEnabled());
}
protected override void OnElementChanged(ElementChangedEventArgs<MasterDetailPage> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
index 0168d2d..9f94f20 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
@@ -11,12 +11,9 @@ namespace Xamarin.Forms.Platform.Tizen
{
EvasObject _content;
- /// <summary>
- /// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.ScrollViewRenderer"/> class.
- /// </summary>
- public ScrollViewRenderer()
+ static ScrollViewRenderer()
{
- RegisterPropertyHandler("Content", FillContent);
+ RegisterPropertyHandler("Content", (r) => (r as ScrollViewRenderer).FillContent());
}
/// <summary>
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
index 3e3344f..339bd00 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
@@ -13,21 +13,18 @@ namespace Xamarin.Forms.Platform.Tizen
//TODO: read default platform color
static readonly EColor s_defaultPlaceholderColor = EColor.Gray;
static readonly EColor s_defaultTextColor = EColor.Black;
- /// <summary>
- /// Creates a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.SearchBarRenderer"/> class.
- /// Registers handlers for various properties of the SearchBar widget.
- /// </summary>
- public SearchBarRenderer()
+
+ static SearchBarRenderer()
{
- RegisterPropertyHandler(SearchBar.CancelButtonColorProperty, CancelButtonColorPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontAttributesProperty, FontAttributesPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontFamilyProperty, FontFamilyPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontSizeProperty, FontSizePropertyHandler);
- RegisterPropertyHandler(SearchBar.HorizontalTextAlignmentProperty, HorizontalTextAlignmentPropertyHandler);
- RegisterPropertyHandler(SearchBar.PlaceholderProperty, PlaceholderPropertyHandler);
- RegisterPropertyHandler(SearchBar.PlaceholderColorProperty, PlaceholderColorPropertyHandler);
- RegisterPropertyHandler(SearchBar.TextProperty, TextPropertyHandler);
- RegisterPropertyHandler(SearchBar.TextColorProperty, TextColorPropertyHandler);
+ RegisterPropertyHandler(SearchBar.CancelButtonColorProperty, (r) => (r as SearchBarRenderer).CancelButtonColorPropertyHandler());
+ RegisterPropertyHandler(SearchBar.FontAttributesProperty, (r) => (r as SearchBarRenderer).FontAttributesPropertyHandler());
+ RegisterPropertyHandler(SearchBar.FontFamilyProperty, (r) => (r as SearchBarRenderer).FontFamilyPropertyHandler());
+ RegisterPropertyHandler(SearchBar.FontSizeProperty, (r) => (r as SearchBarRenderer).FontSizePropertyHandler());
+ RegisterPropertyHandler(SearchBar.HorizontalTextAlignmentProperty, (r) => (r as SearchBarRenderer).HorizontalTextAlignmentPropertyHandler());
+ RegisterPropertyHandler(SearchBar.PlaceholderProperty, (r) => (r as SearchBarRenderer).PlaceholderPropertyHandler());
+ RegisterPropertyHandler(SearchBar.PlaceholderColorProperty, (r) => (r as SearchBarRenderer).PlaceholderColorPropertyHandler());
+ RegisterPropertyHandler(SearchBar.TextProperty, (r) => (r as SearchBarRenderer).TextPropertyHandler());
+ RegisterPropertyHandler(SearchBar.TextColorProperty, (r) => (r as SearchBarRenderer).TextColorPropertyHandler());
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
index db72583..cf20ff9 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SliderRenderer.cs
@@ -6,12 +6,11 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class SliderRenderer : ViewRenderer<Slider, ESlider>
{
-
- public SliderRenderer()
+ static SliderRenderer()
{
- RegisterPropertyHandler(Slider.ValueProperty, UpdateValue);
- RegisterPropertyHandler(Slider.MinimumProperty, UpdateMinimum);
- RegisterPropertyHandler(Slider.MaximumProperty, UpdateMaximum);
+ RegisterPropertyHandler(Slider.ValueProperty, (r) => (r as SliderRenderer).UpdateValue());
+ RegisterPropertyHandler(Slider.MinimumProperty, (r) => (r as SliderRenderer).UpdateMinimum());
+ RegisterPropertyHandler(Slider.MaximumProperty, (r) => (r as SliderRenderer).UpdateMaximum());
}
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
index a1cf311..40133d7 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/StepperRenderer.cs
@@ -5,13 +5,12 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class StepperRenderer : ViewRenderer<Stepper, Spinner>
{
-
- public StepperRenderer()
+ static StepperRenderer()
{
- RegisterPropertyHandler(Stepper.ValueProperty, UpdateValue);
- RegisterPropertyHandler(Stepper.MinimumProperty, UpdateMinimum);
- RegisterPropertyHandler(Stepper.MaximumProperty, UpdateMaximum);
- RegisterPropertyHandler(Stepper.IncrementProperty, UpdateStep);
+ RegisterPropertyHandler(Stepper.ValueProperty, (r) => (r as StepperRenderer).UpdateValue());
+ RegisterPropertyHandler(Stepper.MinimumProperty, (r) => (r as StepperRenderer).UpdateMinimum());
+ RegisterPropertyHandler(Stepper.MaximumProperty, (r) => (r as StepperRenderer).UpdateMaximum());
+ RegisterPropertyHandler(Stepper.IncrementProperty, (r) => (r as StepperRenderer).UpdateStep());
}
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
index 5c6814a..5a74872 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
@@ -8,9 +8,9 @@ namespace Xamarin.Forms.Platform.Tizen
{
public class SwitchRenderer : ViewRenderer<Switch, Check>
{
- public SwitchRenderer()
+ static SwitchRenderer()
{
- RegisterPropertyHandler(Switch.IsToggledProperty, HandleToggled);
+ RegisterPropertyHandler(Switch.IsToggledProperty, (r) => (r as SwitchRenderer).HandleToggled());
}
protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
index 3af1b34..9a9aa0f 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TabbedPageRenderer.cs
@@ -18,11 +18,11 @@ namespace Xamarin.Forms.Platform.Tizen
Toolbar _toolbar;
Dictionary<EToolbarItem, Page> _itemToItemPage = new Dictionary<EToolbarItem, Page>();
- public TabbedPageRenderer()
+ static TabbedPageRenderer()
{
- RegisterPropertyHandler(TabbedPage.TitleProperty, UpdateTitle);
- RegisterPropertyHandler("CurrentPage", CurrentPageChanged);
- RegisterPropertyHandler(TabbedPage.BarBackgroundColorProperty, UpdateBarBackgroundColor);
+ RegisterPropertyHandler(TabbedPage.TitleProperty, (r) => (r as TabbedPageRenderer).UpdateTitle());
+ RegisterPropertyHandler("CurrentPage", (r) => (r as TabbedPageRenderer).CurrentPageChanged());
+ RegisterPropertyHandler(TabbedPage.BarBackgroundColorProperty, (r) => (r as TabbedPageRenderer).UpdateBarBackgroundColor());
}
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
index 58b17a4..76539a6 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TableViewRenderer.cs
@@ -7,10 +7,10 @@ namespace Xamarin.Forms.Platform.Tizen
{
internal static BindableProperty PresentationProperty = BindableProperty.Create("Presentation", typeof(View), typeof(TableSectionBase), null, BindingMode.OneWay, null, null, null, null, null as BindableProperty.CreateDefaultValueDelegate);
- public TableViewRenderer()
+ static TableViewRenderer()
{
- RegisterPropertyHandler(TableView.HasUnevenRowsProperty, UpdateHasUnevenRows);
- RegisterPropertyHandler(TableView.RowHeightProperty, UpdateRowHeight);
+ RegisterPropertyHandler(TableView.HasUnevenRowsProperty, (r) => (r as TableViewRenderer).UpdateHasUnevenRows());
+ RegisterPropertyHandler(TableView.RowHeightProperty, (r) => (r as TableViewRenderer).UpdateRowHeight());
}
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
index 211ccf3..0e46ae9 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/TimePickerRenderer.cs
@@ -12,11 +12,11 @@ namespace Xamarin.Forms.Platform.Tizen
TimeSpan _time = DateTime.Now.TimeOfDay;
- public TimePickerRenderer()
+ static TimePickerRenderer()
{
- RegisterPropertyHandler(TimePicker.FormatProperty, UpdateFormat);
- RegisterPropertyHandler(TimePicker.TimeProperty, UpdateTime);
- RegisterPropertyHandler(TimePicker.TextColorProperty, UpdateTextColor);
+ RegisterPropertyHandler(TimePicker.FormatProperty, (r) => (r as TimePickerRenderer).UpdateFormat());
+ RegisterPropertyHandler(TimePicker.TimeProperty, (r) => (r as TimePickerRenderer).UpdateTime());
+ RegisterPropertyHandler(TimePicker.TextColorProperty, (r) => (r as TimePickerRenderer).UpdateTextColor());
}
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
@@ -102,4 +102,4 @@ namespace Xamarin.Forms.Platform.Tizen
Control.Text = new DateTime(_time.Ticks).ToString(Element.Format ?? s_defaultFormat);
}
}
-} \ No newline at end of file
+}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
index a6c1c3a..5b80bd0 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
@@ -33,37 +33,38 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
EvasObject _view;
- Dictionary<string, Action<bool>> _propertyHandlersWithInit = new Dictionary<string, Action<bool>>();
+ static Dictionary<string, Action<VisualElementRenderer<TElement>, bool>> s_propertyHandlersWithInit = new Dictionary<string, Action<VisualElementRenderer<TElement>, bool>>();
- Dictionary<string, Action> _propertyHandlers = new Dictionary<string, Action>();
+ static Dictionary<string, Action<VisualElementRenderer<TElement>>> s_propertyHandlers = new Dictionary<string, Action<VisualElementRenderer<TElement>>>();
HashSet<string> _batchedProperties = new HashSet<string>();
bool _movedCallbackEnabled = false;
+
/// <summary>
/// Default constructor.
/// </summary>
- protected VisualElementRenderer()
+ static VisualElementRenderer()
{
- RegisterPropertyHandler(VisualElement.IsVisibleProperty, UpdateIsVisible);
- RegisterPropertyHandler(VisualElement.OpacityProperty, UpdateOpacity);
- RegisterPropertyHandler(VisualElement.IsEnabledProperty, UpdateIsEnabled);
- RegisterPropertyHandler(VisualElement.InputTransparentProperty, UpdateInputTransparent);
- RegisterPropertyHandler(VisualElement.BackgroundColorProperty, UpdateBackgroundColor);
+ RegisterPropertyHandler(VisualElement.IsVisibleProperty, (r) => r.UpdateIsVisible());
+ RegisterPropertyHandler(VisualElement.OpacityProperty, (r, i) => r.UpdateOpacity(i));
+ RegisterPropertyHandler(VisualElement.IsEnabledProperty, (r, i) => r.UpdateIsEnabled(i));
+ RegisterPropertyHandler(VisualElement.InputTransparentProperty, (r, i) => r.UpdateInputTransparent(i));
+ RegisterPropertyHandler(VisualElement.BackgroundColorProperty, (r, i) => r.UpdateBackgroundColor(i));
// Use TizenSpecific APIs only if available
if (TizenPlatformServices.AppDomain.IsTizenSpecificAvailable)
{
- RegisterPropertyHandler("ThemeStyle", UpdateThemeStyle);
- RegisterPropertyHandler("IsFocusAllowed", UpdateFocusAllowed);
- RegisterPropertyHandler("NextFocusDirection", UpdateFocusDirection);
- RegisterPropertyHandler("NextFocusUpView", UpdateFocusUpView);
- RegisterPropertyHandler("NextFocusDownView", UpdateFocusDownView);
- RegisterPropertyHandler("NextFocusLeftView", UpdateFocusLeftView);
- RegisterPropertyHandler("NextFocusRightView", UpdateFocusRightView);
- RegisterPropertyHandler("NextFocusBackView", UpdateFocusBackView);
- RegisterPropertyHandler("NextFocusForwardView", UpdateFocusForwardView);
- RegisterPropertyHandler("ToolTip", UpdateToolTip);
+ RegisterPropertyHandler("ThemeStyle", (r) => r.UpdateThemeStyle());
+ RegisterPropertyHandler("IsFocusAllowed", (r, i) => r.UpdateFocusAllowed(i));
+ RegisterPropertyHandler("NextFocusDirection", (r, i) => r.UpdateFocusDirection(i));
+ RegisterPropertyHandler("NextFocusUpView", (r, i) => r.UpdateFocusUpView(i));
+ RegisterPropertyHandler("NextFocusDownView", (r, i) => r.UpdateFocusDownView(i));
+ RegisterPropertyHandler("NextFocusLeftView", (r, i) => r.UpdateFocusLeftView(i));
+ RegisterPropertyHandler("NextFocusRightView", (r, i) => r.UpdateFocusRightView(i));
+ RegisterPropertyHandler("NextFocusBackView", (r, i) => r.UpdateFocusBackView(i));
+ RegisterPropertyHandler("NextFocusForwardView", (r, i) => r.UpdateFocusForwardView(i));
+ RegisterPropertyHandler("ToolTip", (r, i) => r.UpdateToolTip(i));
}
RegisterPropertyHandler(VisualElement.AnchorXProperty, ApplyTransformation);
@@ -381,17 +382,17 @@ namespace Xamarin.Forms.Platform.Tizen
return;
}
- Action<bool> init;
- if (_propertyHandlersWithInit.TryGetValue(e.PropertyName, out init))
+ Action<VisualElementRenderer<TElement>, bool> init;
+ if (s_propertyHandlersWithInit.TryGetValue(e.PropertyName, out init))
{
- init(false);
+ init(this, false);
}
else
{
- Action handler;
- if (_propertyHandlers.TryGetValue(e.PropertyName, out handler))
+ Action<VisualElementRenderer<TElement>> handler;
+ if (s_propertyHandlers.TryGetValue(e.PropertyName, out handler))
{
- handler();
+ handler(this);
}
}
}
@@ -480,7 +481,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="property">Handled property.</param>
/// <param name="handler">Action to be executed when property changes.</param>
- protected void RegisterPropertyHandler(BindableProperty property, Action<bool> handler)
+ protected static void RegisterPropertyHandler(BindableProperty property, Action<VisualElementRenderer<TElement>, bool> handler)
{
RegisterPropertyHandler(property.PropertyName, handler);
}
@@ -490,9 +491,9 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="name">Name of the handled property.</param>
/// <param name="handler">Action to be executed when property changes.</param>
- protected void RegisterPropertyHandler(string name, Action<bool> handler)
+ protected static void RegisterPropertyHandler(string name, Action<VisualElementRenderer<TElement>, bool> handler)
{
- _propertyHandlersWithInit.Add(name, handler);
+ s_propertyHandlersWithInit.Add(name, handler);
}
/// <summary>
@@ -500,7 +501,7 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="property">Handled property.</param>
/// <param name="handler">Action to be executed when property changes.</param>
- protected void RegisterPropertyHandler(BindableProperty property, Action handler)
+ protected static void RegisterPropertyHandler(BindableProperty property, Action<VisualElementRenderer<TElement>> handler)
{
RegisterPropertyHandler(property.PropertyName, handler);
}
@@ -510,9 +511,9 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
/// <param name="name">Name of the handled property.</param>
/// <param name="handler">Action to be executed when property changes.</param>
- protected void RegisterPropertyHandler(string name, Action handler)
+ protected static void RegisterPropertyHandler(string name, Action<VisualElementRenderer<TElement>> handler)
{
- _propertyHandlers.Add(name, handler);
+ s_propertyHandlers.Add(name, handler);
}
/// <summary>
@@ -521,14 +522,14 @@ namespace Xamarin.Forms.Platform.Tizen
/// <param name="initialization">If set to <c>true</c> the method is called for an uninitialized object.</param>
protected void UpdateAllProperties(bool initialization)
{
- foreach (var action in _propertyHandlersWithInit.Values.Distinct())
+ foreach (var action in s_propertyHandlersWithInit.Values.Distinct())
{
- action(initialization);
+ action(this, initialization);
}
- foreach (var action in _propertyHandlers.Values.Distinct())
+ foreach (var action in s_propertyHandlers.Values.Distinct())
{
- action();
+ action(this);
}
}
@@ -988,6 +989,11 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
+ private static void ApplyTransformation(VisualElementRenderer<TElement> renderer)
+ {
+ renderer.ApplyTransformation();
+ }
+
protected virtual void ApplyTransformation()
{
if (null == NativeView)