2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
25 /// Contains and encapsulates Native Window handle.
27 internal class SafeNativeWindowHandle : SafeHandle
30 /// Initializes a new instance of SafeNativeWindowHandle referencing the given window.
32 internal SafeNativeWindowHandle(Window currentWindow) : base(IntPtr.Zero, false)
34 SetHandle(currentWindow != null ? currentWindow.GetNativeWindowHandler() : IntPtr.Zero);
37 /// Null check if the handle is valid or not.
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public override bool IsInvalid
44 return this.handle == IntPtr.Zero;
48 /// Release handle itself.
50 /// <returns>true when released successfully.</returns>
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 protected override bool ReleaseHandle()
54 SetHandle(global::System.IntPtr.Zero);