summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs')
-rw-r--r--win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs b/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs
new file mode 100644
index 000000000..91751474c
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs
@@ -0,0 +1,66 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DPIAwareness.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the DPIAwareness type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System.Windows;
+ using System.Windows.Media;
+
+ /// <summary>
+ /// The dpi awareness.
+ /// </summary>
+ public class DPIAwareness
+ {
+ /// <summary>
+ /// The dx.
+ /// </summary>
+ private static double dx;
+
+ /// <summary>
+ /// The dy.
+ /// </summary>
+ private static double dy;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DPIAwareness"/> class.
+ /// </summary>
+ public DPIAwareness()
+ {
+ var presentationSource = PresentationSource.FromVisual(Application.Current.MainWindow);
+ if (presentationSource != null && presentationSource.CompositionTarget != null)
+ {
+ Matrix m = presentationSource.CompositionTarget.TransformToDevice;
+ dx = m.M11;
+ dy = m.M22;
+ }
+ }
+
+ /// <summary>
+ /// Gets the dpix.
+ /// </summary>
+ public double Dpix
+ {
+ get
+ {
+ return dx;
+ }
+ }
+
+ /// <summary>
+ /// Gets the dpi y.
+ /// </summary>
+ public double DpiY
+ {
+ get
+ {
+ return dy;
+ }
+ }
+ }
+}