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 mode of ColorSelector
24 public enum ColorSelectorMode
27 /// Only color palette is displayed, default
31 /// Only color selector is displayed
33 [Obsolete("Components is obsolete as of version 1.2.3 and is no longer supported.")]
36 /// Both Palette and selector is displayed
38 [Obsolete("Both is obsolete as of version 1.2.3 and is no longer supported.")]
41 /// Only color picker is displayed
43 [Obsolete("Picker is obsolete as of version 1.2.3 and is no longer supported.")]
46 /// This mode is not supported. If you use this, nothing will be shown
48 [Obsolete("Plane is obsolete as of version 1.2.3 and is no longer supported.")]
51 /// This mode is not supported. If you use this, it will be shown same with Palette mode
53 [Obsolete("PallettePlane is obsolete as of version 1.2.3 and is no longer supported.")]
56 /// This mode is not supported. If you use this, it will be shown same with Palette mode
58 [Obsolete("All is obsolete as of version 1.2.3 and is no longer supported.")]
63 /// The ColorSelector is a widget to set a series of colors.
64 /// It also allows to load/save colors from/to config with a unique identifier.
67 /// By default, the colors are loaded/saved from/to config using "default" identifier.
68 /// The colors can be picked by user from the color set by clicking on individual
69 /// color item on the palette or by selecting it from selector.
71 public class ColorSelector : Layout
73 private readonly SmartEvent<ColorChangedEventArgs> _changed;
74 private Color _currentColor;
77 /// Creates and initializes a new instance of the ColorSelector class.
79 /// <param name="parent"></param>
80 public ColorSelector(EvasObject parent) : base(parent)
82 _changed = new SmartEvent<ColorChangedEventArgs>(this, "changed", (data, obj, info) =>
84 return new ColorChangedEventArgs(_currentColor, SelectedColor);
89 /// ColorChanged will be triggered when the SelectedColor changed.
91 public event EventHandler<ColorChangedEventArgs> ColorChanged
93 add { _changed.On += value; }
94 remove { _changed.On -= value; }
98 /// Gets or sets color of colorselector.
100 public Color SelectedColor
105 Interop.Elementary.elm_colorselector_color_get(Handle, out r, out g, out b, out a);
106 _currentColor = new Color(r, g, b, a);
107 return _currentColor;
111 Interop.Elementary.elm_colorselector_color_set(Handle, value.R, value.G, value.B, value.A);
112 _currentColor = new Color(value.R, value.G, value.B, value.A);
117 /// Gets Alpha of a default Color Class(Value is -1).
119 public override int Opacity
123 return Color.Default.A;
128 Console.WriteLine("ColorSelector instance doesn't support to set Opacity.");
133 /// Gets or sets Colorselector's mode.
135 public ColorSelectorMode Mode
139 return (ColorSelectorMode)Interop.Elementary.elm_colorselector_mode_get(Handle);
143 if (ColorSelectorMode.Palette == value)
145 Interop.Elementary.elm_colorselector_mode_set(Handle, (Interop.Elementary.Elm_Colorselector_Mode)value);
151 /// Get or set current palette's name.
153 public string PaletteName
157 return Interop.Elementary.elm_colorselector_palette_name_get(Handle);
161 Interop.Elementary.elm_colorselector_palette_name_set(Handle, value);
166 /// Adds a new color item to palette.
168 /// <param name="color">Color item to add</param>
169 /// <returns>A new color palette Item.</returns>
170 public ColorSelectorItem AddPaletteColor(Color color)
172 ColorSelectorItem item = new ColorSelectorItem();
173 item.Handle = Interop.Elementary.elm_colorselector_palette_color_add(Handle, color.R, color.G, color.B, color.A);
178 /// Clear the palette items.
180 public void ClearPalette()
182 Interop.Elementary.elm_colorselector_palette_clear(Handle);
185 protected override IntPtr CreateHandle(EvasObject parent)
187 return Interop.Elementary.elm_colorselector_add(parent.Handle);