2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Diagnostics;
20 namespace ElmSharp.Wearable
24 /// The Circle Spinner is a widget to display and handle spinner value by rotary event
25 /// Inherits <see cref="Spinner"/>.
27 public class CircleSpinner : Spinner, IRotaryActionWidget
30 double _angleRatio = 1.0;
31 CircleSurface _surface;
34 /// Creates and initializes a new instance of the Circle Spinner class.
36 /// <param name="parent">The parent of new Circle Spinner instance</param>
37 /// <param name="surface">The surface for drawing circle features for this widget.</param>
38 public CircleSpinner(EvasObject parent, CircleSurface surface) : base()
40 Debug.Assert(parent == null || surface == null || parent.IsRealized);
46 /// Gets the handle for Circle Widget.
48 public virtual IntPtr CircleHandle => RealHandle;
51 /// Gets the handle for Circle Surface used in this widget
53 public virtual CircleSurface CircleSurface => _surface;
56 /// Sets or gets the circle spinner angle per each spinner value.
58 public double AngleRatio
67 Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
72 /// Sets or gets the state of the widget, which might be enabled or disabled.
74 public override bool IsEnabled
78 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
82 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
87 /// Sets or gets the line width of the marker
89 public int MarkerLineWidth
93 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
97 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
102 /// Sets or gets the color of the marker
104 public Color MarkerColor
109 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "default", out r, out g, out b, out a);
110 return new Color(r, g, b, a);
114 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "default", value.R, value.G, value.B, value.A);
119 /// Sets or gets the radius at which the center of the marker lies
121 public double MarkerRadius
125 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
129 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
134 /// Creates a widget handle.
136 /// <param name="parent">Parent EvasObject</param>
137 /// <returns>Handle IntPtr</returns>
138 protected override IntPtr CreateHandle(EvasObject parent)
140 IntPtr handle = base.CreateHandle(parent);
141 _circleHandle = Interop.Eext.eext_circle_object_spinner_add(RealHandle == IntPtr.Zero ? Handle : RealHandle, CircleSurface.Handle);