Release 4.0.0-preview1-00201
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Badge / Tizen.Applications / Badge.cs
1 /*
2  * Copyright (c) 2016 - 2017 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 namespace Tizen.Applications
18 {
19     /// <summary>
20     /// The class containing common properties of the Badge.
21     /// </summary>
22     public class Badge
23     {
24         private int count = 0;
25
26         /// <summary>
27         /// Initializes a new instance of the Badge class.
28         /// </summary>
29         /// <since_tizen> 3 </since_tizen>
30         /// <param name="appId">Application ID</param>
31         /// <param name="count">Count value</param>
32         /// <param name="visible">True if it should be displayed</param>
33         /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
34         public Badge(string appId, int count = 1, bool visible = true)
35         {
36             if (IsNegativeNumber(count))
37             {
38                 throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
39             }
40             AppId = appId;
41             this.count = count;
42             Visible = visible;
43         }
44
45         /// <summary>
46         /// Property for the count value of the badge.
47         /// </summary>
48         /// <since_tizen> 3 </since_tizen>
49         /// <exception cref="ArgumentException">Thrown when set negative number</exception>
50         public int Count
51         {
52             get
53             {
54                 return count;
55             }
56             set
57             {
58                 if (IsNegativeNumber(value))
59                 {
60                     throw BadgeErrorFactory.GetException(BadgeError.InvalidParameter, "The count must be positive number");
61                 }
62
63                 count = value;
64             }
65         }
66
67         /// <summary>
68         /// Property for the application ID of the badge.
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         public string AppId { get; set; }
72
73         /// <summary>
74         /// Property for display visibility. True if the badge display visible, otherwise false..
75         /// </summary>
76         /// <since_tizen> 3 </since_tizen>
77         public bool Visible{ get; set; }
78
79         private bool IsNegativeNumber(int number)
80         {
81             return number < 0;
82         }
83     }
84 }