--- /dev/null
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+using Xamarin.Forms.Material.Tizen;
+using Tizen.NET.MaterialComponents;
+using TForms = Xamarin.Forms.Platform.Tizen.Forms;
+
+[assembly: ExportRenderer(typeof(CheckBox), typeof(MaterialCheckBoxRenderer), new[] { typeof(VisualMarker.MaterialVisual) })]
+namespace Xamarin.Forms.Material.Tizen
+{
+ public class MaterialCheckBoxRenderer : CheckBoxRenderer
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<CheckBox> e)
+ {
+ if (Control == null)
+ {
+ SetNativeControl(new MCheckBox(TForms.NativeParent));
+ }
+ base.OnElementChanged(e);
+ }
+ }
+}
}
}
+ public static Color WithAlpha(this Color color, double alpha)
+ {
+ return new Color(color.R, color.G, color.B, (int)(255 * alpha));
+ }
+
+ public static Color WithPremultiplied(this Color color, double alpha)
+ {
+ return new Color((int)(color.R * alpha), (int)(color.G * alpha), (int)(color.B * alpha), color.A);
+ }
+
/// <summary>
/// Returns a string representing the provided ElmSharp.Color instance in a hexagonal notation
/// </summary>
[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);
+ }
+ }
+ }
+ }
+}