Add WatchfaceComplication.dll and fix some bugs (#703)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.WatchfaceComplication / Tizen.Applications / RangedValueData.cs
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20
21 namespace Tizen.Applications.WatchfaceComplication
22 {
23     /// <summary>
24     /// Represents the RangedValueData class for the RangedValue type complication.
25     /// </summary>
26     /// <since_tizen> 6 </since_tizen>
27     public class RangedValueData : ComplicationData
28     {
29         /// <summary>
30         /// Initializes the RangedValueData class.
31         /// </summary>
32         /// <param name="currentValue">The current value.</param>
33         /// <param name="minValue">The minimum value.</param>
34         /// <param name="maxValue">The max value.</param>
35         /// <param name="shortText">The short text.</param>
36         /// <param name="iconPath">The icon path.</param>
37         /// <param name="title">The title.</param>
38         /// <param name="extraData">The extra data.</param>
39         /// <exception cref="ArgumentException">Thrown when parameter is invalid.</exception>
40         /// <example>
41         /// <code>
42         ///     protected override ComplicationData OnDataUpdateRequested(string reqestAppId, ComplicationTypes type, Bundle contextData)
43         ///     {
44         ///         if (type == ComplicationTypes.RangedValue)
45         ///         {
46         ///             return new RangedValueData(50, 0, 100, "short", "icon path", "title", "extra");
47         ///         }
48         ///         else if (type == ComplicationTypes.LongText)
49         ///         {
50         ///             return new LongTextData("longlong", "icon path", "title", null);
51         ///         }
52         ///     }
53         /// </code>
54         /// </example>
55         /// <since_tizen> 6 </since_tizen>
56         public RangedValueData(double currentValue, double minValue, double maxValue, string shortText, string iconPath, string title, string extraData)
57         {
58             if (minValue > maxValue || currentValue < minValue || currentValue > maxValue)
59                 ErrorFactory.ThrowException(ComplicationError.InvalidParam, "Invalid value range min(" + minValue + "), cur(" + currentValue + "), max(" + maxValue + ")");
60             Type = ComplicationTypes.RangedValue;
61             base.RangeMin = minValue;
62             base.RangeMax = maxValue;
63             base.RangeCurrent = currentValue;
64             ShortText = shortText;
65             IconPath = iconPath;
66             Title = title;
67             ExtraData = extraData;
68         }
69
70         /// <summary>
71         /// The information about the current range value of complication data.
72         /// </summary>
73         /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
74         /// <since_tizen> 6 </since_tizen>
75         public new double RangeCurrent
76         {
77             get
78             {
79                 return base.RangeCurrent;
80             }
81             set
82             {
83                 if (value > base.RangeMax)
84                     ErrorFactory.ThrowException(ComplicationError.InvalidParam,
85                         "invalid min(" + value + "), current value can not bigger than max(" + base.RangeMax + ")");
86                 if (value < base.RangeMin)
87                     ErrorFactory.ThrowException(ComplicationError.InvalidParam,
88                         "invalid min(" + value + "), min value can not smaller than min(" + base.RangeMin + ")");
89                 base.RangeCurrent = value;
90             }
91         }
92
93         /// <summary>
94         /// The information about the min range value of complication data.
95         /// </summary>
96         /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
97         /// <since_tizen> 6 </since_tizen>
98         public new double RangeMin
99         {
100             get
101             {
102                 return base.RangeMin;
103             }
104             set
105             {
106                 if (value > base.RangeCurrent)
107                     ErrorFactory.ThrowException(ComplicationError.InvalidParam,
108                         "invalid min(" + value + "), min value can not bigger than current(" + base.RangeCurrent + ")");
109                 base.RangeMin = value;
110             }
111         }
112
113         /// <summary>
114         /// The information about the max range value of complication data.
115         /// </summary>
116         /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
117         /// <since_tizen> 6 </since_tizen>
118         public new double RangeMax
119         {
120             get
121             {
122                 return base.RangeMax;
123             }
124             set
125             {
126                 if (value < base.RangeCurrent)
127                     ErrorFactory.ThrowException(ComplicationError.InvalidParam,
128                         "invalid min(" + value + "), min value can not smaller than current(" + base.RangeCurrent + ")");
129                 base.RangeMax = value;
130             }
131         }
132
133         /// <summary>
134         /// The short text data.
135         /// </summary>
136         /// <exception cref="ArgumentException">Thrown when try to set invalid value.</exception>
137         /// <since_tizen> 6 </since_tizen>
138         public new string ShortText
139         {
140             get
141             {
142                 return base.ShortText;
143             }
144             set
145             {
146                 if (value == null)
147                     ErrorFactory.ThrowException(ComplicationError.InvalidParam, "fail to create short text");
148                 base.ShortText = value;
149             }
150         }
151
152         /// <summary>
153         /// The icon path data.
154         /// </summary>
155         /// <since_tizen> 6 </since_tizen>
156         public new string IconPath
157         {
158             get
159             {
160                 return base.IconPath;
161             }
162             set
163             {
164                 base.IconPath = value;
165             }
166         }
167
168         /// <summary>
169         /// The title data.
170         /// </summary>
171         /// <since_tizen> 6 </since_tizen>
172         public new string Title
173         {
174             get
175             {
176                 return base.Title;
177             }
178             set
179             {
180                 base.Title = value;
181             }
182         }
183
184         /// <summary>
185         /// The extra data.
186         /// </summary>
187         /// <since_tizen> 6 </since_tizen>
188         public new string ExtraData
189         {
190             get
191             {
192                 return base.ExtraData;
193             }
194             set
195             {
196                 base.ExtraData = value;
197             }
198         }
199
200         /// <summary>
201         /// The information about the screen reader text of complication data.
202         /// </summary>
203         /// <since_tizen> 6 </since_tizen>
204         public new string ScreenReaderText
205         {
206             get
207             {
208                 return base.ScreenReaderText;
209             }
210             set
211             {
212                 base.ScreenReaderText = value;
213             }
214         }
215     }
216 }