+++ /dev/null
-using System;
-using Xamarin.Forms.Platform;
-
-namespace Xamarin.Forms
-{
- [RenderWith(typeof(_CheckBoxRenderer))]
- public class CheckBox : View, IElementConfiguration<CheckBox>, IBorderElement, IColorElement
- {
- readonly Lazy<PlatformConfigurationRegistry<CheckBox>> _platformConfigurationRegistry;
- public const string IsCheckedVisualState = "IsChecked";
-
- public static readonly BindableProperty IsCheckedProperty =
- BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), false,
- propertyChanged: (bindable, oldValue, newValue) => {
- ((CheckBox)bindable).CheckedChanged?.Invoke(bindable, new CheckedChangedEventArgs((bool)newValue));
- ((CheckBox)bindable).ChangeVisualState();
- }, defaultBindingMode: BindingMode.TwoWay);
-
- public static readonly BindableProperty ColorProperty = ColorElement.ColorProperty;
-
- public Color Color
- {
- get => (Color)GetValue(ColorProperty);
- set => SetValue(ColorProperty, value);
- }
-
-
- public CheckBox() => _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<CheckBox>>(() => new PlatformConfigurationRegistry<CheckBox>(this));
-
- public bool IsChecked
- {
- get => (bool)GetValue(IsCheckedProperty);
- set => SetValue(IsCheckedProperty, value);
- }
-
- protected internal override void ChangeVisualState()
- {
- if (IsEnabled && IsChecked)
- VisualStateManager.GoToState(this, IsCheckedVisualState);
- else
- base.ChangeVisualState();
- }
-
- public event EventHandler<CheckedChangedEventArgs> CheckedChanged;
-
- public IPlatformElementConfiguration<T, CheckBox> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- void IBorderElement.OnBorderColorPropertyChanged(Color oldValue, Color newValue)
- {
- }
-
- Color IBorderElement.BorderColor => Color.Transparent;
- int IBorderElement.CornerRadius => 0;
- double IBorderElement.BorderWidth => 0;
- int IBorderElement.CornerRadiusDefaultValue => 0;
- Color IBorderElement.BorderColorDefaultValue => Color.Transparent;
- double IBorderElement.BorderWidthDefaultValue => 0;
- bool IBorderElement.IsCornerRadiusSet() => false;
- bool IBorderElement.IsBackgroundColorSet() => IsSet(BackgroundColorProperty);
- bool IBorderElement.IsBorderColorSet() => false;
- bool IBorderElement.IsBorderWidthSet() => false;
- }
-}
\ No newline at end of file
typeof(BoxView),
typeof(Button),
typeof(ImageButton),
- typeof(CheckBox),
typeof(Slider),
typeof(Stepper),
typeof(Switch),
[assembly: ExportRenderer(typeof(TimePicker), typeof(TimePickerRenderer))]
[assembly: ExportRenderer(typeof(ProgressBar), typeof(ProgressBarRenderer))]
[assembly: ExportRenderer(typeof(Switch), typeof(SwitchRenderer))]
-[assembly: ExportRenderer(typeof(CheckBox), typeof(CheckBoxRenderer))]
[assembly: ExportRenderer(typeof(ListView), typeof(ListViewRenderer))]
[assembly: ExportRenderer(typeof(BoxView), typeof(BoxViewRenderer))]
[assembly: ExportRenderer(typeof(ActivityIndicator), typeof(ActivityIndicatorRenderer))]
+++ /dev/null
-using System;
-using ElmSharp;
-using EColor = ElmSharp.Color;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
- public class CheckBoxRenderer : ViewRenderer<CheckBox, Check>
- {
- readonly string[] _onColorParts;
- readonly string[] _onColorEdjeParts;
-
- public CheckBoxRenderer()
- {
- _onColorParts = Device.Idiom == TargetIdiom.Watch ? new string[] {"outer_bg_on", "outer_bg_on_pressed", "check_on", "check_on_pressed"} : new string[] {"bg_on", "stroke"};
- _onColorEdjeParts = new string[_onColorParts.Length];
- RegisterPropertyHandler(CheckBox.IsCheckedProperty, UpdateIsChecked);
- RegisterPropertyHandler(CheckBox.ColorProperty, UpdateOnColor);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<CheckBox> e)
- {
- if (Control == null)
- {
- SetNativeControl(new Check(Forms.NativeParent));
- Control.StateChanged += OnStateChanged;
- for (int i=0; i<_onColorParts.Length; i++)
- {
- _onColorEdjeParts[i] = Control.ClassName.ToLower().Replace("elm_", "") + "/" + _onColorParts[i];
- }
- }
- base.OnElementChanged(e);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.StateChanged -= OnStateChanged;
- }
- }
- base.Dispose(disposing);
- }
-
- void OnStateChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(CheckBox.IsCheckedProperty, Control.IsChecked);
- }
-
- void UpdateIsChecked()
- {
- Control.IsChecked = Element.IsChecked;
- }
-
- void UpdateOnColor(bool initialize)
- {
- if (initialize && Element.Color.IsDefault)
- return;
-
- if (Element.Color.IsDefault)
- {
- foreach(string s in _onColorEdjeParts)
- {
- Control.EdjeObject.DeleteColorClass(s);
- }
- }
- else
- {
- EColor color = Element.Color.ToNative();
- foreach (string s in _onColorParts)
- {
- Control.SetPartColor(s, color);
- }
- }
- }
- }
-}
Registered.Register(typeof(TimePicker), () => new TimePickerRenderer());
Registered.Register(typeof(ProgressBar), () => new ProgressBarRenderer());
Registered.Register(typeof(Switch), () => new SwitchRenderer());
- Registered.Register(typeof(CheckBox), () => new CheckBoxRenderer());
Registered.Register(typeof(ListView), () => new ListViewRenderer());
Registered.Register(typeof(BoxView), () => new BoxViewRenderer());
Registered.Register(typeof(ActivityIndicator), () => new ActivityIndicatorRenderer());
{
}
- internal class _CheckBoxRenderer
- {
- }
-
internal class _IndicatorViewRenderer
{
}
internal class _SwipeViewRenderer
{
}
-}
\ No newline at end of file
+}