From ec522a70a2f4e584e486b9412a86a7440c2e6b50 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 18 May 2014 19:56:12 +0000 Subject: WinGui: Minor tidy up of options. Cleanup of some code warnings and some initial DPIAwareness code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6198 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs (limited to 'win/CS/HandBrakeWPF/Utilities') 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 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the DPIAwareness type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System.Windows; + using System.Windows.Media; + + /// + /// The dpi awareness. + /// + public class DPIAwareness + { + /// + /// The dx. + /// + private static double dx; + + /// + /// The dy. + /// + private static double dy; + + /// + /// Initializes a new instance of the class. + /// + 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; + } + } + + /// + /// Gets the dpix. + /// + public double Dpix + { + get + { + return dx; + } + } + + /// + /// Gets the dpi y. + /// + public double DpiY + { + get + { + return dy; + } + } + } +} -- cgit v1.2.3