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