[Multimedia] Added paramName to every ValidateEnum call. (#83)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Camera / Camera / CameraDisplaySettings.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 using Native = Interop.CameraDisplay;
19
20 namespace Tizen.Multimedia
21 {
22     /// <summary>
23     /// The CameraDisplay class allows you to manage display for the camera.
24     /// It allows to set and get various display properties, such as
25     /// rotation, display visibility, and display mode.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class CameraDisplaySettings
29     {
30         internal readonly Camera _camera;
31
32         internal CameraDisplaySettings(Camera camera)
33         {
34             _camera = camera;
35         }
36
37         /// <summary>
38         /// The display mode.
39         /// </summary>
40         /// <since_tizen> 3 </since_tizen>
41         /// <remarks>
42         /// This property is meaningful only in overlay or EVAS surface display type.
43         /// </remarks>
44         /// <value>A <see cref="CameraDisplayMode"/> that specifies the display mode.</value>
45         /// <exception cref="InvalidOperationException">Display type is incorrect.</exception>
46         /// <exception cref="ObjectDisposedException" > The camera already has been disposed of.</exception>
47         public CameraDisplayMode Mode
48         {
49             get
50             {
51                 CameraErrorFactory.ThrowIfError(Native.GetMode(_camera.GetHandle(), out var val),
52                     "Failed to get camera display mode");
53
54                 return val;
55             }
56
57             set
58             {
59                 ValidationUtil.ValidateEnum(typeof(CameraDisplayMode), value, nameof(value));
60
61                 CameraErrorFactory.ThrowIfError(Native.SetMode(_camera.GetHandle(), value),
62                     "Failed to set camera display mode.");
63             }
64         }
65
66         /// <summary>
67         /// The display visibility.
68         /// </summary>
69         /// <value>true if camera display is visible, otherwise false.</value>
70         /// <since_tizen> 3 </since_tizen>
71         /// <remarks>
72         /// This property is meaningful only in overlay or EVAS surface display type.
73         /// </remarks>
74         /// <exception cref="InvalidOperationException">Display type is incorrect.</exception>
75         /// <exception cref="ObjectDisposedException" > The camera already has been disposed of.</exception>
76         public bool Visible
77         {
78             get
79             {
80                 CameraErrorFactory.ThrowIfError(Native.GetVisible(_camera.GetHandle(), out bool val),
81                     "Failed to get visible value");
82
83                 return val;
84             }
85
86             set
87             {
88                 CameraErrorFactory.ThrowIfError(Native.SetVisible(_camera.GetHandle(), value),
89                     "Failed to set display visible.");
90             }
91         }
92
93         /// <summary>
94         /// The display rotation.
95         /// </summary>
96         /// <since_tizen> 3 </since_tizen>
97         /// <remarks>
98         /// This property is meaningful only in overlay or EVAS surface display type.
99         /// </remarks>
100         /// <value>A <see cref="Rotation"/> that specifies the rotation of the camera device.</value>
101         /// <exception cref="InvalidOperationException">Display type is incorrect.</exception>
102         /// <exception cref="ObjectDisposedException" > The camera already has been disposed of.</exception>
103         public Rotation Rotation
104         {
105             get
106             {
107                 CameraErrorFactory.ThrowIfError(Native.GetRotation(_camera.GetHandle(), out var val),
108                     "Failed to get display rotation");
109
110                 return val;
111             }
112
113             set
114             {
115                 ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
116
117                 CameraErrorFactory.ThrowIfError(Native.SetRotation(_camera.GetHandle(), value),
118                     "Failed to set display rotation.");
119             }
120         }
121
122         /// <summary>
123         /// The display flip.
124         /// </summary>
125         /// <since_tizen> 3 </since_tizen>
126         /// <remarks>
127         /// This property is meaningful only in overlay or EVAS surface display type.
128         /// </remarks>
129         /// <value>A <see cref="Flips"/> that specifies the camera flip type.</value>
130         /// <exception cref="InvalidOperationException">Display type is incorrect.</exception>
131         /// <exception cref="ObjectDisposedException" > The camera already has been disposed of.</exception>
132         public Flips Flip
133         {
134             get
135             {
136                 CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
137                     "Failed to get display flip");
138
139                 return val;
140             }
141
142             set
143             {
144                 ValidationUtil.ValidateFlagsEnum(value, Flips.Horizontal | Flips.Vertical, nameof(Flips));
145
146                 CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
147                     "Failed to set display flip.");
148             }
149         }
150
151         /// <summary>
152         /// the ROI(Region Of Interest) area of display.
153         /// </summary>
154         /// <since_tizen> 3 </since_tizen>
155         /// <remarks>
156         /// This property is meaningful only in overlay or EVAS surface display type.
157         /// </remarks>
158         /// <exception cref="InvalidOperationException">Display type is incorrect.</exception>
159         /// <exception cref="ObjectDisposedException" > The camera already has been disposed of.</exception>
160         public Rectangle RoiArea
161         {
162             get
163             {
164                 CameraErrorFactory.ThrowIfError(Native.GetRoiArea(_camera.GetHandle(),
165                     out int x, out int y, out int width, out int height), "Failed to get display roi area");
166
167                 return new Rectangle(x, y, width, height);
168             }
169
170             set
171             {
172                 CameraErrorFactory.ThrowIfError(Native.SetRoiArea(_camera.GetHandle(),
173                     value.X, value.Y, value.Width, value.Height), "Failed to set display roi area.");
174             }
175         }
176     }
177 }