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