DPI and Scaling
On a display with a scale factor above 100%, images that were made for 96 dpi and stretched by Windows look blurry. The document, the rulers, the status bar and the ribbon tabs of TX Text Control scale with the display, but icons you take for your own buttons and menus need the right resolution. The few problems that Text Control documents for WPF are below. DPI and Display Scaling describes scaling in a new application.
Icons in Your Own Buttons Are Blurry
Buttons or menu items of your own that show icons of TX Text Control look blurry or too small on a display with a high resolution.
An image made for 96 dpi is stretched on a display with a higher resolution, which makes it blurry. ResourceProvider returns the icons of TX Text Control in the size a resolution needs.
- In the
Loadedevent of the window, request the icon with GetLargeIcon or GetSmallIcon, passing the window or the resolution of its display. - Assign the returned image to your button or menu item.
Give Your Own Buttons Sharp Icons shows the code that passes the window. Code that passes the resolution reads it from the window, as the example of the reference does; printImage is an Image element in MainWindow.xaml:
using System.Windows;
using System.Windows.Controls;
using TXTextControl.WPF;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// The resolution of the display the window is shown on
double dpi = PresentationSource.FromVisual(this).CompositionTarget
.TransformToDevice.Transform(new Point(96.0, 96.0)).X;
printImage.Source = ResourceProvider.GetLargeIcon(
ResourceProvider.FileMenuItem.TXITEM_Print.ToString(), dpi);
}
GetLargeIcon or GetSmallIcon Throws an Exception
A call of GetLargeIcon or GetSmallIcon with a FrameworkElement throws an exception with this message:
The specified framework element has not been loaded for presentation.
The size of the icon depends on the display the element is shown on, and the element isn't loaded yet.
- Call the method in the
Loadedevent of the window or the element. - Or pass the resolution in dpi instead of the element, as the previous section shows.
The Zoom Factor Can't Be Set
A value you set for ZoomFactor, or pass to Zoom, isn't applied.
The zoom factor must be between 10 and 400 percent, and between 10 and 65535 percent when the ViewMode is PageView or Normal.
- Keep the value within the range of the current view mode, or switch to
PageViewfor larger values.