Update src/Tizen.NUI/src/public/Window/WindowHandle.cs
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / WindowHandle.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
18 using System;
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// Contains and encapsulates Native Window handle.
26     /// </summary>
27     internal class SafeNativeWindowHandle : SafeHandle
28     {
29         /// <summary>
30         /// Initializes a new instance of SafeNativeWindowHandle referencing the given window.
31         /// </summary>
32         internal SafeNativeWindowHandle(Window currentWindow) : base(IntPtr.Zero, false)
33         {
34             SetHandle(currentWindow != null ? currentWindow.GetNativeWindowHandler() : IntPtr.Zero);
35         }
36         /// <summary>
37         /// Null check if the handle is valid or not.
38         /// </summary>
39         [EditorBrowsable(EditorBrowsableState.Never)]
40         public override bool IsInvalid
41         {
42             get
43             {
44                 return this.handle == IntPtr.Zero;
45             }
46         }
47         /// <summary>
48         /// Release handle itself.
49         /// </summary>
50         /// <returns>true when released successfully.</returns>
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         protected override bool ReleaseHandle()
53         {
54             SetHandle(global::System.IntPtr.Zero);
55             return true;
56         }
57     }
58 }