/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.ComponentModel; using System.Diagnostics; namespace ElmSharp.Wearable { /// /// The Circle Spinner is a widget to display and handle the spinner value by the Rotary event. /// Inherits . /// /// preview public class CircleSpinner : Spinner, IRotaryActionWidget { IntPtr _circleHandle; double _angleRatio = -1.0; CircleSurface _surface; /// /// Creates and initializes a new instance of the Circle Spinner class. /// /// The parent of the new Circle Spinner instance. /// The surface for drawing circle features for this widget. /// preview public CircleSpinner(EvasObject parent, CircleSurface surface) : base() { Debug.Assert(parent == null || surface == null || parent.IsRealized); _surface = surface; Realize(parent); } /// /// Creates and initializes a new instance of the Circle Spinner class. /// /// The parent of the new Circle Spinner instance. /// preview [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")] [EditorBrowsable(EditorBrowsableState.Never)] public CircleSpinner(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent)) { ((IRotaryActionWidget)this).Activate(); } /// /// Gets the handle for Circle widget. /// /// preview public virtual IntPtr CircleHandle => _circleHandle; /// /// Gets the handle for the circle surface used in this widget. /// /// preview public virtual CircleSurface CircleSurface => _surface; /// /// Sets or gets the circle spinner angle per each spinner value. /// /// preview [Obsolete("Use Step")] [EditorBrowsable(EditorBrowsableState.Never)] public double AngleRatio { get { if(_angleRatio <= 0) { if(Maximum == Minimum) { return 0.0; } else { return 360/(Maximum - Minimum); } } return _angleRatio; } set { if(value > 0) { if (_angleRatio == value) return; _angleRatio = value; Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio); } } } /// /// Sets or gets the disabled state of this widget. /// /// preview [Obsolete("Use IsEnabled")] [EditorBrowsable(EditorBrowsableState.Never)] public bool Disabled { get => !IsEnabled; set => IsEnabled = !value; } /// /// Sets or gets the state of the widget, which might be enabled or disabled. /// /// preview public override bool IsEnabled { get { return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle); } set { Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value); } } /// /// Sets or gets the line width of the marker. /// /// /// MarkerLineWidth is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner. /// /// preview [Obsolete("MarkerLineWidth is obsolete as of version 6.0.0 and is no longer supported")] public int MarkerLineWidth { get { return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default"); } set { Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value); } } /// /// Sets or gets the color of the marker. /// /// /// MarkerColor is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner. /// /// preview [Obsolete("MarkerColor is obsolete as of version 6.0.0 and is no longer supported")] public Color MarkerColor { get { int r, g, b, a; Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a); return new Color(r, g, b, a); } set { Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A); } } /// /// Sets or gets the radius at which the center of the marker lies. /// /// /// MarkerRadius is not supported on device or emulator which does not support marker in CircleDatetimeSelector and CircleSpinner. /// /// preview [Obsolete("MarkerRadius is obsolete as of version 6.0.0 and is no longer supported")] public double MarkerRadius { get { return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default"); } set { Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value); } } /// /// Creates a widget handle. /// /// Parent EvasObject. /// Handle IntPtr. /// preview protected override IntPtr CreateHandle(EvasObject parent) { IntPtr handle = base.CreateHandle(parent); _circleHandle = Interop.Eext.eext_circle_object_spinner_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle); return handle; } } }