[MediaVision] Add APIs for Design QR feature (#5104)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Vision / MediaVision / QrConfiguration.cs
1 /*
2  * Copyright (c) 2016 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
19 namespace Tizen.Multimedia.Vision
20 {
21     /// <summary>
22     /// Represents a QR configuration of <see cref="BarcodeGenerator"/>.
23     /// </summary>
24     /// <since_tizen> 4 </since_tizen>
25     public class QrConfiguration
26     {
27         private string _embedImagePath;
28         private QrShape _dataShape = QrShape.Rectangular;
29         private QrShape _finderShape = QrShape.Rectangular;
30
31         /// <summary>
32         /// Initializes a new instance of the <see cref="QrConfiguration"/> class.
33         /// </summary>
34         /// <param name="qrMode">Encoding mode for the message.</param>
35         /// <param name="ecc">Error correction level.</param>
36         /// <param name="version">QR code version. From 1 to 40 inclusive.</param>
37         /// <exception cref="ArgumentOutOfRangeException">
38         ///     <paramref name="version"/> is less than 1.<br/>
39         ///     -or-<br/>
40         ///     <paramref name="version"/> is greater than 40.
41         /// </exception>
42         /// <exception cref="ArgumentException">
43         ///     <paramref name="qrMode"/> is invalid.<br/>
44         ///     -or-<br/>
45         ///     <paramref name="ecc"/> is invalid.
46         /// </exception>
47         /// <example>
48         /// <code>
49         /// var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 30);
50         /// </code>
51         /// </example>
52         /// <since_tizen> 4 </since_tizen>
53         public QrConfiguration(QrMode qrMode, ErrorCorrectionLevel ecc, int version)
54         {
55             if (version < 1 || version > 40)
56             {
57                 throw new ArgumentOutOfRangeException(nameof(version), version,
58                     "Valid version range is 1 to 40 inclusive.");
59             }
60             ValidationUtil.ValidateEnum(typeof(QrMode), qrMode, nameof(qrMode));
61             ValidationUtil.ValidateEnum(typeof(ErrorCorrectionLevel), ecc, nameof(ecc));
62
63             Mode = qrMode;
64             ErrorCorrectionLevel = ecc;
65             Version = version;
66         }
67
68         /// <summary>
69         /// Gets the encoding mode for the message.
70         /// </summary>
71         /// <since_tizen> 4 </since_tizen>
72         public QrMode Mode { get; }
73
74         /// <summary>
75         /// Gets the error correction level.
76         /// </summary>
77         /// <since_tizen> 4 </since_tizen>
78         public ErrorCorrectionLevel ErrorCorrectionLevel { get; }
79
80         /// <summary>
81         /// Gets the QR code version.
82         /// </summary>
83         /// <since_tizen> 4 </since_tizen>
84         public int Version { get; }
85
86         /// <summary>
87         /// Gets or sets the embed image absolute path of the Design QR code.
88         /// </summary>
89         /// <remarks>
90         /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.<br/>
91         /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage.
92         /// </remarks>
93         /// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
94         /// <exception cref="ArgumentException"><paramref name="value"/> is zero-length string.</exception>
95         /// <since_tizen> 11 </since_tizen>
96         public string EmbedImagePath
97         {
98             get
99             {
100                 return _embedImagePath;
101             }
102             set
103             {
104                 ValidationUtil.ValidateIsNullOrEmpty(value, nameof(value));
105
106                 _embedImagePath = value;
107             }
108         }
109
110         /// <summary>
111         /// Gets or sets the data shape of the Design QR code.
112         /// </summary>
113         /// <remarks>The default value is <see cref="QrShape.Rectangular"/>.</remarks>
114         /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
115         /// <since_tizen> 11 </since_tizen>
116         public QrShape DataShape
117         {
118             get
119             {
120                 return _dataShape;
121             }
122             set
123             {
124                 ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value));
125
126                 _dataShape = value;
127             }
128         }
129
130         /// <summary>
131         /// Gets or sets the finder shape of the Design QR code.
132         /// </summary>
133         /// <remarks>The default value is <see cref="QrShape.Rectangular"/>.</remarks>
134         /// <exception cref="ArgumentException"><paramref name="value"/> is not valid.</exception>
135         /// <since_tizen> 11 </since_tizen>
136         public QrShape FinderShape
137         {
138             get
139             {
140                 return _finderShape;
141             }
142             set
143             {
144                 ValidationUtil.ValidateEnum(typeof(QrShape), value, nameof(value));
145
146                 _finderShape = value;
147             }
148         }
149     }
150 }