aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs121
1 files changed, 121 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs
new file mode 100644
index 000000000..de3d2c356
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Tango.Core;
+using Tango.Core.DI;
+using Tango.FSE.Common.Resolution;
+
+namespace Tango.FSE.UI.Resolution
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultResolutionService : ExtendedObject, IResolutionService
+ {
+ public event EventHandler<ResolutionMode> ResolutionModeChanged;
+ public event EventHandler<SizeChangedEventArgs> ResolutionChanged;
+
+ private ResolutionMode resolution;
+ public ResolutionMode Resolution
+ {
+ get
+ {
+ return resolution;
+ }
+ private set
+ {
+ resolution = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private bool isLowResolution;
+ public bool IsLowResolution
+ {
+ get
+ {
+ return isLowResolution;
+ }
+ private set
+ {
+ isLowResolution = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+
+ private bool isHighResolution;
+ public bool IsHighResolution
+ {
+ get
+ {
+ return isHighResolution;
+ }
+ private set
+ {
+ isHighResolution = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private double resolutionWidth;
+ public double ResolutionWidth
+ {
+ get
+ {
+ return resolutionWidth;
+ }
+ private set
+ {
+ resolutionWidth = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private double resolutionHeight;
+ public double ResolutionHeight
+ {
+ get
+ {
+ return resolutionHeight;
+ }
+ private set
+ {
+ resolutionHeight = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ public DefaultResolutionService()
+ {
+ var window = Application.Current.MainWindow;
+ if (window != null)
+ {
+ window.SizeChanged += Window_SizeChanged;
+ }
+ }
+
+ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ var size = e.NewSize;
+
+ ResolutionWidth = size.Width;
+ ResolutionHeight = size.Height;
+
+ IsHighResolution = ResolutionWidth > 1280 && ResolutionHeight > 800;
+ IsLowResolution = !isHighResolution;
+
+ ResolutionMode previousMode = Resolution;
+
+ Resolution = IsHighResolution ? ResolutionMode.High : ResolutionMode.Low;
+
+ if (Resolution != previousMode)
+ {
+ ResolutionModeChanged?.Invoke(this, Resolution);
+ }
+
+ ResolutionChanged?.Invoke(this, e);
+ }
+ }
+}