Provides DPI information for a window.
コード例 #1
0
ファイル: DpiAwareWindow.cs プロジェクト: IAIS/verifier
        private void OnSourceInitialized(object sender, EventArgs e)
        {
            this.source = (HwndSource)HwndSource.FromVisual(this);

            // calculate the DPI used by WPF; this is the same as the system DPI
            var matrix = source.CompositionTarget.TransformToDevice;

            this.dpiInfo = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);

            if (this.isPerMonitorDpiAware) {
                this.source.AddHook(WndProc);

                RefreshMonitorDpi();
            }
        }
コード例 #2
0
        private void OnSourceInitialized(object sender, EventArgs e)
        {
            this.source = (HwndSource)HwndSource.FromVisual(this);

            // calculate the DPI used by WPF; this is the same as the system DPI
            var matrix = source.CompositionTarget.TransformToDevice;

            this.dpiInfo = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);

            if (this.isPerMonitorDpiAware)
            {
                this.source.AddHook(WndProc);

                RefreshMonitorDpi();
            }
        }
コード例 #3
0
        private void OnSourceInitialized(object sender, EventArgs e)
        {
            _source = (HwndSource)PresentationSource.FromVisual(this);
            if (_source?.CompositionTarget == null)
            {
                return;
            }

            // calculate the DPI used by WPF; this is the same as the system DPI
            var matrix = _source.CompositionTarget.TransformToDevice;

            DpiInformation = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);

            if (!_isPerMonitorDpiAware)
            {
                return;
            }
            _source.AddHook(WndProc);
            RefreshMonitorDpi();
        }
コード例 #4
0
        protected sealed override void OnSourceInitialized(EventArgs e)
        {
            Logging.Here();

            base.OnSourceInitialized(e);

            _hwndSource = (HwndSource)PresentationSource.FromVisual(this);
            if (_hwndSource?.CompositionTarget != null)
            {
                var matrix = _hwndSource.CompositionTarget.TransformToDevice;
                _dpi         = new DpiInformation(BaseDpi * matrix.M11, BaseDpi * matrix.M22);
                DeviceScaleX = matrix.M11;
                DeviceScaleY = matrix.M22;
            }
            else
            {
                _dpi = new DpiInformation(BaseDpi, BaseDpi);
            }

            _dpi.UpdateUserScale(AppearanceManager.Instance.AppScale);
            Logging.Debug($"DPI: {_dpi}");

            LoadLocationAndSize();
            UpdateReferenceSizeForDpiAwareness();

            if (IsPerMonitorDpiAware)
            {
                Logging.Debug("Per-monitor DPI-aware");
                _hwndSource?.AddHook(WndProc);
            }
            else
            {
                Logging.Error("Not per-monitor DPI-aware!");
            }

            RefreshMonitorDpi();
            UpdateScaleRelatedParams();
            OnSourceInitializedOverride();
        }
コード例 #5
0
ファイル: DpiAwareWindow.cs プロジェクト: gro-ove/actools
        private void OnSourceInitialized(object sender, EventArgs e) {
            _source = (HwndSource)PresentationSource.FromVisual(this);
            if (_source?.CompositionTarget == null) return;

            // calculate the DPI used by WPF; this is the same as the system DPI
            var matrix = _source.CompositionTarget.TransformToDevice;
            DpiInformation = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);

            if (!_isPerMonitorDpiAware) return;
            _source.AddHook(WndProc);
            RefreshMonitorDpi();
        }