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