Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
vermeir_nico_introducing_net_6_getting_started_with_blazor_m.pdf
Скачиваний:
19
Добавлен:
26.06.2023
Размер:
11.64 Mб
Скачать

Chapter 4 Desktop Development

Figure 4-12.  Same application without Windows 10 theme

The application still runs, but visually it looks very old; that is because all the controls fallback to their default look and feel. Application.EnableVisualStyles will keep the user’s preference in mind; if it runs on a Windows system with visual styles disabled, it will respect this setting and load the application without visual styles.

Text Rendering

The next call in our WinForms application’s startup cycle is Application.SetCompatibl eTextRenderingDefault(false).

Before I can explain what SetCompatibleTextRenderingDefault does, we’ll need to take a small history lesson. Back in .NET Framework version older than .NET 2.0, text was rendered using GDI+ and its Graphics class. From .NET Framework

2.0 onward, this was switched to GDI and the TextRenderer class. TextRenderer fixed a number of problems with performance and localization. Because WinForms prides itself on backward compatibility, we had two different ways text on WinForms controls could be rendered, and they were visually different. To fix this, the

81