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