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
35 /// Both Palette and selector is displayed
39 /// Only color picker is displayed
43 /// This mode is not supported. If you use this, nothing will be shown
47 /// This mode is not supported. If you use this, it will be shown same with Palette mode
51 /// This mode is not supported. If you use this, it will be shown same with Palette mode
57 /// The ColorSelector is a widget to set a series of colors.
58 /// It also allows to load/save colors from/to config with a unique identifier.
61 /// By default, the colors are loaded/saved from/to config using "default" identifier.
62 /// The colors can be picked by user from the color set by clicking on individual
63 /// color item on the palette or by selecting it from selector.
65 public class ColorSelector : Layout
67 private readonly SmartEvent<ColorChangedEventArgs> _changed;
68 private Color _currentColor;
71 /// Creates and initializes a new instance of the ColorSelector class.
73 /// <param name="parent"></param>
74 public ColorSelector(EvasObject parent) : base(parent)
76 _changed = new SmartEvent<ColorChangedEventArgs>(this, "changed", (data, obj, info) =>
78 return new ColorChangedEventArgs(_currentColor, SelectedColor);
83 /// ColorChanged will be triggered when the SelectedColor changed.
85 public event EventHandler<ColorChangedEventArgs> ColorChanged
87 add { _changed.On += value; }
88 remove { _changed.On -= value; }
92 /// Gets or sets color of colorselector.
94 public Color SelectedColor
99 Interop.Elementary.elm_colorselector_color_get(Handle, out r, out g, out b, out a);
100 _currentColor = new Color(r, g, b, a);
101 return _currentColor;
105 Interop.Elementary.elm_colorselector_color_set(Handle, value.R, value.G, value.B, value.A);
106 _currentColor = new Color(value.R, value.G, value.B, value.A);
111 /// Gets Alpha of a default Color Class.
113 public override int Opacity
117 return Color.Default.A;
122 Console.WriteLine("ColorSelector instance doesn't support to set Opacity.");
127 /// Gets or sets Colorselector's mode.
129 public ColorSelectorMode Mode
133 return (ColorSelectorMode)Interop.Elementary.elm_colorselector_mode_get(Handle);
137 Interop.Elementary.elm_colorselector_mode_set(Handle, (Interop.Elementary.Elm_Colorselector_Mode)value);
142 /// Get or set current palette's name.
144 public string PaletteName
148 return Interop.Elementary.elm_colorselector_palette_name_get(Handle);
152 Interop.Elementary.elm_colorselector_palette_name_set(Handle, value);
157 /// Adds a new color item to palette.
159 /// <param name="color">Color item to add</param>
160 /// <returns>A new color palette Item.</returns>
161 public ColorSelectorItem AddPaletteColor(Color color)
163 ColorSelectorItem item = new ColorSelectorItem();
164 item.Handle = Interop.Elementary.elm_colorselector_palette_color_add(Handle, color.R, color.G, color.B, color.A);
169 /// Clear the palette items.
171 public void ClearPalette()
173 Interop.Elementary.elm_colorselector_palette_clear(Handle);
176 protected override IntPtr CreateHandle(EvasObject parent)
178 return Interop.Elementary.elm_colorselector_add(parent.Handle);