Esempio n. 1
0
        private void Handle_ToolTipOpened(object sender, RoutedEventArgs e)
        {
            var cm = sender as ToolTip;

            if (cm != null && cm.PlacementTarget != null)
            {
                var scale = DpiEvents.GetWindowDpiScale(cm.PlacementTarget);
                DpiEvents.ScaleElement(cm, scale);
                Debug.WriteLine("ToolTip scale = " + scale);
            }
        }
Esempio n. 2
0
        private void RescaleForDpi()
        {
            var test = Shcore.ProcessDpiAwareness;

            if (test == CommonWin32.HighDPI.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE)
            {
                var child = VisualTreeHelper.GetChild(ContentWindow, 0) as FrameworkElement;
                if (child != null)
                {
                    DpiEvents.ScaleElement(child, _dpiScaleFactor, true);
                }
            }

            var dpiArgs = new DpiChangeEventArgs(ContentWindow, _monitorDPI, _dpiScaleFactor);

            ContentWindow.RaiseEvent(dpiArgs);
            DpiEvents.SetWindowDpi(ContentWindow, dpiArgs.NewDpi);
            DpiEvents.SetWindowDpiScale(ContentWindow, dpiArgs.Scale);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts a TextBlock value to boolean true if too small.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="culture">The culture.</param>
        /// <returns></returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var tooSmall = false;

            if (values != null)
            {
                foreach (var value in values)
                {
                    var tb = value as TextBlock;
                    if (tb != null)
                    {
                        var dpi = DpiEvents.GetWindowDpi(tb);

                        tooSmall = dpi <= 96 && tb.FontSize <= Threshold;
                        break;
                    }
                }
            }
            return(tooSmall);
        }