/* * 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 ProgressBar is a widget for visually representing the progress status of a given job or task with the circular design. /// /// preview public class CircleProgressBar : Widget, ICircleWidget { CircleSurface _surface; /// /// Creates and initializes a new instance of the Circle Progressbar class. /// /// The parent of the new Circle Progressbar instance. /// The surface for drawing circle features for this widget. /// preview public CircleProgressBar(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 Progressbar class. /// /// The parent of the new Circle Progressbar 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 CircleProgressBar(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent)) { } /// /// Gets the handle for the Circle widget. /// /// preview public virtual IntPtr CircleHandle => Handle; /// /// Gets the handle for the circle surface used in this widget. /// /// preview public virtual CircleSurface CircleSurface => _surface; /// /// 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 value of the ProgressBar. /// /// preview public double Value { get { return Interop.Eext.eext_circle_object_value_get(CircleHandle); } set { Interop.Eext.eext_circle_object_value_set(CircleHandle, value); } } /// /// Sets or gets the maximum value of the ProgressBar. /// /// preview public double Maximum { get { double max = 0; double min = 0; Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max); return max; } set { double min = Minimum; Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, min, value); } } /// /// Sets or gets the minimum value of the ProgressBar. /// /// preview public double Minimum { get { double max = 0; double min = 0; Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max); return min; } set { double max = Maximum; Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, value, max); } } /// /// Sets or gets the angle value of the ProgressBar. /// /// preview public double BarAngle { get { return Interop.Eext.eext_circle_object_angle_get(CircleHandle); } set { Interop.Eext.eext_circle_object_angle_set(CircleHandle, value); } } /// /// Sets or gets the angle value of the Background ProgressBar. /// /// preview public double BackgroundAngle { get { return Interop.Eext.eext_circle_object_item_angle_get(CircleHandle, "bg"); } set { Interop.Eext.eext_circle_object_item_angle_set(CircleHandle, "bg", value); } } /// /// Sets or gets the angle offset value of the ProgressBar. /// /// preview public double BarAngleOffset { get { return Interop.Eext.eext_circle_object_angle_offset_get(CircleHandle); } set { Interop.Eext.eext_circle_object_angle_offset_set(CircleHandle, value); } } /// /// Sets or gets the angle offset value of the Background ProgressBar. /// /// preview public double BackgroundAngleOffset { get { return Interop.Eext.eext_circle_object_item_angle_offset_get(CircleHandle, "bg"); } set { Interop.Eext.eext_circle_object_item_angle_offset_set(CircleHandle, "bg", value); } } /// /// Sets or gets the maximum angle value of the ProgressBar. /// /// preview public double BarAngleMaximum { get { double max = 0; double min = 0; Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max); return max; } set { double min = BarAngleMinimum; Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, min, value); } } /// /// Sets or gets the minimum angle value of the ProgressBar. /// /// preview public double BarAngleMinimum { get { double max = 0; double min = 0; Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max); return min; } set { double max = BarAngleMaximum; Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, value, max); } } /// /// Sets or gets the color of the ProgressBar. /// /// preview public Color BarColor { get { int r = 0; int g = 0; int b = 0; int a = 0; Interop.Eext.eext_circle_object_color_get(CircleHandle, out r, out g, out b, out a); return Color.FromRgba(r, g, b, a); } set { Interop.Eext.eext_circle_object_color_set(CircleHandle, value.R, value.G, value.B, value.A); } } /// /// Sets or gets the color of the Background ProgressBar. /// /// preview public override Color BackgroundColor { get { int r = 0; int g = 0; int b = 0; int a = 0; Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "bg", out r, out g, out b, out a); return Color.FromRgba(r, g, b, a); } set { Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "bg", value.R, value.G, value.B, value.A); } } /// /// Sets or gets the line width of the ProgressBar. /// /// preview public int BarLineWidth { get { return Interop.Eext.eext_circle_object_line_width_get(CircleHandle); } set { Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value); } } /// /// Sets or gets the line width of the Background ProgressBar. /// /// preview public int BackgroundLineWidth { get { return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "bg"); } set { Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "bg", value); } } /// /// Sets or gets the radius of the ProgressBar. /// /// preview public double BarRadius { get { return Interop.Eext.eext_circle_object_radius_get(CircleHandle); } set { Interop.Eext.eext_circle_object_radius_set(CircleHandle, value); } } /// /// Sets or gets the radius of the Background ProgressBar. /// /// preview public double BackgroundRadius { get { return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "bg"); } set { Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "bg", value); } } /// /// Creates a widget handle. /// /// Parent EvasObject. /// Handle IntPtr. /// preview protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Eext.eext_circle_object_progressbar_add(parent, CircleSurface.Handle); } } }