8149f559b3891feed9d6b08a5303cf974b04f9bd
[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         /// <value>A <see cref="CameraDisplayMode"/> that specifies the display mode.</value>
40         /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
41         public CameraDisplayMode Mode
42         {
43             get
44             {
45                 CameraDisplayMode val = CameraDisplayMode.LetterBox;
46
47                 CameraErrorFactory.ThrowIfError(Native.GetMode(_camera.GetHandle(), out val),
48                     "Failed to get camera display mode");
49
50                 return val;
51             }
52
53             set
54             {
55                 ValidationUtil.ValidateEnum(typeof(CameraDisplayMode), value);
56                 CameraErrorFactory.ThrowIfError(Native.SetMode(_camera.GetHandle(), value),
57                     "Failed to set camera display mode.");
58             }
59         }
60
61         /// <summary>
62         /// The display visibility.
63         /// True if camera display visible, otherwise false.
64         /// </summary>
65         /// <since_tizen> 3 </since_tizen>
66         /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
67         public bool Visible
68         {
69             get
70             {
71                 bool val = false;
72
73                 CameraErrorFactory.ThrowIfError(Native.GetVisible(_camera.GetHandle(), out val),
74                     "Failed to get visible value");
75
76                 return val;
77             }
78
79             set
80             {
81                 CameraErrorFactory.ThrowIfError(Native.SetVisible(_camera.GetHandle(), value),
82                     "Failed to set display visible.");
83             }
84         }
85
86         /// <summary>
87         /// The display rotation.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         /// <value>A <see cref="CameraRotation"/> that specifies the rotation of camera device.</value>
91         /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
92         public CameraRotation Rotation
93         {
94             get
95             {
96                 CameraRotation val = CameraRotation.None;
97
98                 CameraErrorFactory.ThrowIfError(Native.GetRotation(_camera.GetHandle(), out val),
99                     "Failed to get display rotation");
100
101                 return val;
102             }
103
104             set
105             {
106                 ValidationUtil.ValidateEnum(typeof(CameraRotation), value);
107                 CameraErrorFactory.ThrowIfError(Native.SetRotation(_camera.GetHandle(), value),
108                     "Failed to set display rotation.");
109             }
110         }
111
112         /// <summary>
113         /// The display flip.
114         /// </summary>
115         /// <since_tizen> 3 </since_tizen>
116         /// <value>A <see cref="CameraFlip"/> that specifies camera flip type.</value>
117         /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
118         public CameraFlip Flip
119         {
120             get
121             {
122                 CameraFlip val = CameraFlip.None;
123
124                 CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out val),
125                     "Failed to get display flip");
126
127                 return val;
128             }
129
130             set
131             {
132                 ValidationUtil.ValidateEnum(typeof(CameraFlip), value);
133                 CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
134                     "Failed to set display flip.");
135             }
136         }
137
138         /// <summary>
139         /// the ROI(Region Of Interest) area of display.
140         /// </summary>
141         /// <since_tizen> 3 </since_tizen>
142         /// <exception cref="ObjectDisposedException" > The camera already has been disposed.</exception>
143         public Rectangle RoiArea
144         {
145             get
146             {
147                 int x = 0;
148                 int y = 0;
149                 int width = 0;
150                 int height = 0;
151
152                 CameraErrorFactory.ThrowIfError(Native.GetRoiArea(_camera.GetHandle(), out x, out y, out width, out height),
153                     "Failed to get display roi area");
154
155                 return new Rectangle(x, y, width, height);
156             }
157
158             set
159             {
160                 CameraErrorFactory.ThrowIfError(Native.SetRoiArea(_camera.GetHandle(),
161                     value.X, value.Y, value.Width, value.Height), "Failed to set display roi area.");
162             }
163         }
164     }
165 }
166