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.
22 /// Enumeration for the modes of ColorSelector.
24 /// <since_tizen> preview </since_tizen>
25 public enum ColorSelectorMode
28 /// Only the color palette is displayed, by default.
32 /// Only the color selector is displayed.
34 [Obsolete("Components is obsolete as of version 1.2.3 and is no longer supported.")]
37 /// Both the palette and the selector is displayed.
39 [Obsolete("Both is obsolete as of version 1.2.3 and is no longer supported.")]
42 /// Only the color picker is displayed.
44 [Obsolete("Picker is obsolete as of version 1.2.3 and is no longer supported.")]
47 /// This mode is not supported. If you use this, nothing will be shown.
49 [Obsolete("Plane is obsolete as of version 1.2.3 and is no longer supported.")]
52 /// This mode is not supported. If you use this, it will be shown same with the Palette mode.
54 [Obsolete("PallettePlane is obsolete as of version 1.2.3 and is no longer supported.")]
57 /// This mode is not supported. If you use this, it will be shown same with the Palette mode.
59 [Obsolete("All is obsolete as of version 1.2.3 and is no longer supported.")]
64 /// The ColorSelector is a widget to set a series of colors.
65 /// It also allows to load/save colors from/to the configuration with a unique identifier.
68 /// By default, the colors are loaded/saved from/to configuration using the "default" identifier.
69 /// The colors can be picked by the user from the color set by clicking on individual
70 /// color items on the palette, or by selecting it from the selector.
72 /// <since_tizen> preview </since_tizen>
73 public class ColorSelector : Layout
75 private readonly SmartEvent<ColorChangedEventArgs> _changed;
76 private Color _currentColor;
79 /// Creates and initializes a new instance of the ColorSelector class.
81 /// <param name="parent"></param>
82 /// <since_tizen> preview </since_tizen>
83 public ColorSelector(EvasObject parent) : base(parent)
85 _changed = new SmartEvent<ColorChangedEventArgs>(this, "changed", (data, obj, info) =>
87 return new ColorChangedEventArgs(_currentColor, SelectedColor);
92 /// ColorChanged will be triggered when the SelectedColor is changed.
94 /// <since_tizen> preview </since_tizen>
95 public event EventHandler<ColorChangedEventArgs> ColorChanged
97 add { _changed.On += value; }
98 remove { _changed.On -= value; }
102 /// Gets or sets the color of colorselector.
104 /// <since_tizen> preview </since_tizen>
105 public Color SelectedColor
110 Interop.Elementary.elm_colorselector_color_get(Handle, out r, out g, out b, out a);
111 _currentColor = new Color(r, g, b, a);
112 return _currentColor;
116 Interop.Elementary.elm_colorselector_color_set(Handle, value.R, value.G, value.B, value.A);
117 _currentColor = new Color(value.R, value.G, value.B, value.A);
122 /// Gets the Alpha of a default Color class (value is -1).
124 /// <since_tizen> preview </since_tizen>
125 public override int Opacity
129 return Color.Default.A;
133 Console.WriteLine("ColorSelector instance doesn't support to set Opacity.");
138 /// Gets or sets the Colorselector's mode.
140 /// <since_tizen> preview </since_tizen>
141 public ColorSelectorMode Mode
145 return (ColorSelectorMode)Interop.Elementary.elm_colorselector_mode_get(Handle);
149 if (ColorSelectorMode.Palette == value)
151 Interop.Elementary.elm_colorselector_mode_set(Handle, (Interop.Elementary.Elm_Colorselector_Mode)value);
157 /// Gets or sets the current palette's name.
159 /// <since_tizen> preview </since_tizen>
160 public string PaletteName
164 return Interop.Elementary.elm_colorselector_palette_name_get(Handle);
168 Interop.Elementary.elm_colorselector_palette_name_set(Handle, value);
173 /// Adds a new color item to the palette.
175 /// <param name="color">The color item to add.</param>
176 /// <returns>A new color palette Item.</returns>
177 /// <since_tizen> preview </since_tizen>
178 public ColorSelectorItem AddPaletteColor(Color color)
180 ColorSelectorItem item = new ColorSelectorItem(this);
181 item.Handle = Interop.Elementary.elm_colorselector_palette_color_add(Handle, color.R, color.G, color.B, color.A);
186 /// Clears the palette items.
188 /// <since_tizen> preview </since_tizen>
189 public void ClearPalette()
191 Interop.Elementary.elm_colorselector_palette_clear(Handle);
195 /// Creates a widget handle.
197 /// <param name="parent">Parent EvasObject.</param>
198 /// <returns>Handle IntPtr.</returns>
199 /// <since_tizen> preview </since_tizen>
200 protected override IntPtr CreateHandle(EvasObject parent)
202 return Interop.Elementary.elm_colorselector_add(parent.Handle);