diff options
Diffstat (limited to 'Xamarin.Forms.Core/DeviceInfo.cs')
-rw-r--r-- | Xamarin.Forms.Core/DeviceInfo.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/DeviceInfo.cs b/Xamarin.Forms.Core/DeviceInfo.cs new file mode 100644 index 00000000..dc83075a --- /dev/null +++ b/Xamarin.Forms.Core/DeviceInfo.cs @@ -0,0 +1,51 @@ +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace Xamarin.Forms +{ + internal abstract class DeviceInfo : INotifyPropertyChanged, IDisposable + { + DeviceOrientation _currentOrientation; + bool _disposed; + + public DeviceOrientation CurrentOrientation + { + get { return _currentOrientation; } + internal set + { + if (Equals(_currentOrientation, value)) + return; + _currentOrientation = value; + OnPropertyChanged(); + } + } + + public abstract Size PixelScreenSize { get; } + + public abstract Size ScaledScreenSize { get; } + + public abstract double ScalingFactor { get; } + + public void Dispose() + { + Dispose(true); + } + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void Dispose(bool disposing) + { + if (_disposed) + return; + _disposed = true; + } + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } +}
\ No newline at end of file |