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