[NUI] Add Tizen.NUI.XamlBuild module
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.XamlBuild / src / internal / XamlBinding / DeviceInfo.cs
1 using System;
2 using System.ComponentModel;
3 using System.Runtime.CompilerServices;
4
5 namespace Tizen.NUI.Binding
6 {
7     [EditorBrowsable(EditorBrowsableState.Never)]
8     internal abstract class DeviceInfo : INotifyPropertyChanged, IDisposable
9     {
10         DeviceOrientation _currentOrientation;
11         bool _disposed;
12
13         public DeviceOrientation CurrentOrientation
14         {
15             get { return _currentOrientation; }
16             set
17             {
18                 if (Equals(_currentOrientation, value))
19                     return;
20                 _currentOrientation = value;
21                 OnPropertyChanged();
22             }
23         }
24
25         public virtual double DisplayRound(double value) =>
26             Math.Round(value);
27
28         public void Dispose()
29         {
30             Dispose(true);
31         }
32
33         public event PropertyChangedEventHandler PropertyChanged;
34
35         protected virtual void Dispose(bool disposing)
36         {
37             if (_disposed)
38                 return;
39             _disposed = true;
40         }
41
42         protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
43             => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
44     }
45 }