[NUI] Add Component Application (#1148) (#1157)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / NUIWindowInfo.cs
1 using System;
2 using Tizen.NUI;
3 using Tizen.Applications.ComponentBased.Common;
4
5 namespace Tizen.NUI
6 {
7     /// <summary>
8     /// Window information class for ComponentApplication
9     /// </summary>
10     internal class NUIWindowInfo : IWindowInfo
11     {
12         private const string LogTag = "Tizen.NUI";
13         private Window _win;
14         private int _resId;
15         private bool _disposed = false;
16
17         /// <summary>
18         /// Initializes the NUI Window class.
19         /// </summary>
20         /// <param name="win">The window object of component.</param>
21         /// <since_tizen> 6 </since_tizen>
22         internal NUIWindowInfo(Window win)
23         {
24             _win = win;
25         }
26
27         /// <summary>
28         /// Gets the resource ID of window
29         /// </summary>
30         /// <returns>The native handle of window</returns>
31         public int ResourceId
32         {
33             get
34             {
35                 if (_resId == 0)
36                 {
37                     _resId = _win.ResourceID;
38                     if (_resId != 0)
39                         Log.Info(LogTag, "Fail to get resource ID");
40                 }
41
42                 return _resId;
43             }
44         }
45
46         /// <summary>
47         /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
48         /// </summary>
49         /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
50         protected virtual void Dispose(bool disposing)
51         {
52             if (_disposed)
53                 return;
54
55             if (disposing)
56             {
57                 _win.Dispose();
58                 _win = null;
59             }
60             _disposed = true;
61         }
62
63         /// <summary>
64         /// Dispose the window resources
65         /// </summary>
66         /// <returns></returns>
67         /// <since_tizen> 6 </since_tizen>
68         public void Dispose()
69         {
70             Dispose(true);
71             GC.SuppressFinalize(this);
72         }
73     }
74
75 }
76