[00:00:06] Hey, good morning, everyone. [00:00:07] Uh, this is uh from me um from the [00:00:11] WinForms team with a little bit of an [00:00:14] unusual type title, I would say. So we [00:00:17] have on the one side um [00:00:20] enormous history of WinForms [00:00:23] and then on the other side [00:00:25] the necessity to renew um constantly to [00:00:29] make WinForms down the road its own [00:00:32] migration tool. [00:00:34] For the new features that we have in [00:00:37] .NET 11 [00:00:38] um [00:00:39] I had actually planned something um [00:00:42] where you [00:00:44] must be kind of curious what what kind [00:00:45] of monster I've created here. Um I have [00:00:49] my normal laptop here on this side and I [00:00:51] have another laptop on this side, but [00:00:54] the really um [00:00:56] I said special thing about this laptop [00:00:58] here is um it runs [00:01:01] Windows XP [00:01:04] and it runs Visual Studio 2005. [00:01:07] What I what I actually wanted to to show [00:01:09] um are a couple of things that we had in [00:01:13] WinForms [00:01:15] for the absolute uh first minute so to [00:01:18] say. Now my plan was actually to [00:01:20] demonstrate that in in .NET uh two and [00:01:23] in Visual Studio 2005. [00:01:25] Um [00:01:27] let's take a look at um some things um [00:01:31] some properties actually um that we have [00:01:34] on the normal controls. Um and and those [00:01:37] those controls actually [00:01:41] they were they were there at the time [00:01:44] where we actually had um just just come [00:01:48] out under Windows 2000. I think it was [00:01:51] back in the day um a couple of style [00:01:53] changes. It was shortly before the [00:01:56] um visual styles from Windows XP uh XP [00:02:00] And it was um [00:02:02] when the new Office versions were there. [00:02:05] And the WinForms team back in the days [00:02:08] wanted to actually [00:02:10] um [00:02:11] you know create styles for the buttons [00:02:13] that they have um that would mimic the [00:02:16] then very you know like fancy styles. [00:02:20] And to that that was the reason that um [00:02:23] on [00:02:24] for example controls like button or [00:02:27] checkbox or also combo box [00:02:29] um we have um properties like um the [00:02:33] flat style. [00:02:35] And so um here [00:02:37] um with the flat style I can chose from [00:02:41] four different settings. [00:02:43] Um system is I delegate the rendering to [00:02:46] a of the control to the system. Um flat [00:02:50] pop-up and standard then are things that [00:02:53] um the .NET team decided back in the day [00:02:55] to draw themselves. Now here's the [00:02:57] thing. [00:02:59] Um [00:03:00] it did not [00:03:02] really turn out to be used that often. [00:03:05] And over the time [00:03:08] we hardly used it um at all. And the [00:03:11] reason for that is that when Windows XP [00:03:14] back in the days gen uh came along um [00:03:18] it came up with a complete different set [00:03:21] of styles. [00:03:23] And so the drawing of our controls in [00:03:25] WinForms were just handled down to the [00:03:27] system. And um and XP um yeah took over. [00:03:32] And so until recently we still had if [00:03:35] you went to the property page um of your [00:03:37] app um the Windows XP styles um would [00:03:42] Visual Basic it was even called um [00:03:44] enable um XP visual styles. [00:03:47] Um and and that was the style we were [00:03:49] drawing with. So those were properties [00:03:51] now that were laid dormant for a really [00:03:54] long time. [00:03:56] So what I um want to do now is actually [00:03:59] start an app [00:04:01] um [00:04:02] which demonstrates kind of a new thing [00:04:06] because what we [00:04:07] said now is this. [00:04:10] Primarily driven by accessibility, [00:04:14] [snorts] um we revived all these um [00:04:17] properties [00:04:18] um that were back in the day introduced. [00:04:22] And what we do now is we are using them [00:04:24] to [00:04:26] create styles which are [00:04:29] very close to the designed language that [00:04:32] we need in [00:04:34] that we need in Windows. [00:04:36] [snorts] So this is one example. This is [00:04:38] how a typical customer [00:04:40] um [00:04:42] entry form would look like. [00:04:44] [snorts] And [00:04:46] now I want you to and I need to you know [00:04:49] hurry up a little bit to to make to make [00:04:51] good for the for the time I lost at the [00:04:53] beginning. [00:04:54] Want to um just [00:04:57] keep your attention on on these two [00:04:59] things. [00:05:00] So in um in Visual [00:05:03] um in .NET 11 for for WinForms [00:05:06] we have on the application uh class [00:05:11] um a series of new methods and [00:05:14] properties where you can just with with [00:05:17] one line of code [00:05:19] change the appearance of your whole app. [00:05:22] [snorts] Um in that case um [00:05:25] we have the Visual Styles mode new in [00:05:29] Windows 11. And when I said that [00:05:32] to .NET 11 and you see this is an enum. [00:05:36] So our plan is then also to go forward [00:05:39] with extending those enum with .NET 12, [00:05:42] .NET 13 and make sure that we can this [00:05:46] way [00:05:48] you know like be in fashion and be in [00:05:50] time uh for the things to come. So when [00:05:54] I switch this um you see [00:05:56] this is just one line of code and um [00:05:59] yeah the there you go. This is now um [00:06:04] this is now as close as it can be to [00:06:07] your WinForms app. And, and [00:06:10] keep it short. [00:06:11] These controls are still the same [00:06:13] Windows controls, but [00:06:15] they are [00:06:17] they're drawn in a way that they mimic [00:06:20] the experience. And, we also make sure [00:06:24] that [00:06:25] when you are [00:06:28] using [clears throat] things like [00:06:30] checkboxes, [00:06:32] that you have [00:06:33] properties with which you can then, [00:06:37] you know, like switch to those styles. [00:06:40] And [00:06:42] and have the same experience [00:06:45] with [00:06:46] with what you with what you have in [00:06:50] in in [00:06:51] in Windows itself. So, I want to show [00:06:53] you something [00:06:55] how far we really [00:06:57] took these things in in in Windows in [00:07:00] WinForms. So, I have here [00:07:04] an edit mode [00:07:06] inside of the app. And and the idea is [00:07:09] now when I double click on a control, [00:07:12] then I see the properties of this [00:07:15] control. So, what you see here now is a [00:07:18] group box control. And you see also that [00:07:20] the group box [00:07:22] does behave a little bit differently [00:07:25] than the usual group box. First of all, [00:07:27] when you have the old [00:07:28] classic style group box, often it has [00:07:31] problems with [00:07:33] contrast. You barely see the frame [00:07:36] around that. So, [00:07:38] when we go to the flat style of [00:07:41] of the [00:07:43] group box now and, you know, like [00:07:45] cycle through the setting of [00:07:48] the [00:07:51] of the flat style [00:07:53] settings, then you see that there are [00:07:56] several [00:07:59] things, [00:08:01] but those are not exclusively [00:08:05] like [00:08:06] arbitrary styles [00:08:08] because [00:08:09] everything you see. [00:08:12] When you took when you look closer. [00:08:15] Has like a connection almost to Windows [00:08:18] itself. What I mean with that is [00:08:21] if you take a look at my particular. [00:08:24] Start. [00:08:25] Menu then or my my my task bar that it [00:08:28] has a certain color [00:08:30] and so does the title bar and the reason [00:08:33] is that [00:08:35] when you go now to the Windows settings [00:08:37] that I have the personalization and [00:08:41] let me let me do this here. [00:08:44] And then [00:08:46] if I go to colors and to the accent [00:08:49] color so now let's let me change this to [00:08:51] blue. [00:08:53] The moment I did that changed to blue [00:08:55] you see that you WinForms app now with a [00:08:58] new visual styles automatically picks [00:09:01] those things up. [00:09:03] And [00:09:04] and that means. [00:09:05] This is not. [00:09:07] Really not about styling this has all to [00:09:10] do with accessibility [00:09:12] and this is also one promise that we did [00:09:15] from the beginning even if you see [00:09:18] things that. [00:09:19] What we on first I think hey but this is [00:09:22] theming no it's not. [00:09:25] The primary the primary primary [00:09:27] motivation. [00:09:29] For all those controls is accessibility. [00:09:32] I mean think about the really small [00:09:34] checkbox and and option buttons that we [00:09:37] had [00:09:38] in in a 4K display [00:09:40] when you want to you know like drive and [00:09:43] hit that with mouse it had originally a [00:09:45] 12 by 12 pixel landing area if you will [00:09:49] and this is just too small for modern [00:09:51] monitor so that's no longer working. But [00:09:53] there's then. [00:09:54] Also another thing and that is [00:09:57] accessibility so [00:09:59] in Windows we also have now very [00:10:01] prominently available the the text size [00:10:05] which I can adjust [clears throat] right [00:10:07] so the moment I. [00:10:11] Change this let's say to. [00:10:13] almost 120% and I I press apply then um [00:10:19] takes a moment [00:10:21] that's Windows and now did you see what [00:10:23] just happened in the background so [00:10:26] we picked that up [00:10:27] and and then on the fly because the text [00:10:31] changed inside of [00:10:33] Windows because the [00:10:36] the the user [00:10:38] make made the the the the appropriate [00:10:40] settings [00:10:41] our WinForms app is now able to to pick [00:10:44] those things up [00:10:45] and then there's one thing more [00:10:48] which I wanted to show in a different [00:10:50] well let me first go back to the to the [00:10:53] other [00:10:54] text size [00:10:56] because I need the space for the next [00:10:57] demo I need that space on the screen [00:11:00] um [00:11:02] so [00:11:04] and that is [00:11:06] let me see that is [00:11:09] cash register that I [00:11:12] that I have here so [00:11:16] now this is a typical line of business [00:11:17] app that could have been you know like [00:11:19] done in in in in WinForms like 10 15 [00:11:23] years ago and usually there's no need to [00:11:26] migrate it right [00:11:28] but what often happens is that people [00:11:31] you know used control libraries from [00:11:34] from vendors that [00:11:37] well that have special [00:11:41] special let's say niche products at the [00:11:44] time but [00:11:47] the time is is so long ago that that [00:11:50] that those vendors are probably no [00:11:52] longer in in business and and then that [00:11:55] is in in many many cases [00:11:58] [snorts] sort of an impediment to really [00:12:00] bring you up over [00:12:01] and again to revive this old [00:12:07] properties that we always had but you [00:12:09] know weren't of any use [00:12:12] Um, [00:12:13] we did the same here. Now, [00:12:15] let me show you what happens if I, for [00:12:17] example, you know, change [00:12:20] the [00:12:21] the view of this cash register from [00:12:25] from standard to pop-up in this case. [00:12:28] You can observe actually two things. So [00:12:31] the first thing was um like the speed of [00:12:34] which the the transition happened [00:12:37] was a little bit, let's say um [00:12:45] slow. [00:12:46] And then secondly um [00:12:49] and that's the good thing, [00:12:51] the pop-up style really, you know, [00:12:53] brings [00:12:55] the the look and feel of, you know, like [00:12:58] the real 3D effects of a button [00:13:01] that [00:13:02] would equal to the to the modern [00:13:05] um [00:13:07] what you understand these days under [00:13:09] under a pop-up style [00:13:11] of the form. So now [00:13:13] there's an option here [00:13:15] that I want that I want to show and that [00:13:18] is [00:13:19] that's called use suspending scope. [00:13:22] Um, [00:13:23] you know when you when you have a layout [00:13:25] issue in terms of performance and [00:13:27] performs, then in that moment [00:13:31] that is often because you're cascading [00:13:34] containers. That means you have a table [00:13:36] layout panel then that has cells and [00:13:38] inside of them are table layout panels [00:13:40] and inside of them are table layout [00:13:42] panels. And usually what you need to do [00:13:44] is you need to suspend the layout really [00:13:47] like for the first level, second level, [00:13:49] third level, fourth level and so on. [00:13:51] [snorts] And what you could never do by [00:13:53] the way is actually suspend the painting [00:13:55] during that time when you knew, for [00:13:58] example, that a font change came and the [00:14:00] layout would completely be redone, then [00:14:04] it was a [00:14:05] pretty much effort that you had to do. [00:14:07] Now [00:14:08] with [00:14:09] with the new API that we have in 11 [00:14:11] which is called suspend a painting, you [00:14:15] can just [00:14:16] um get a so-called scope [00:14:19] and then using that scope, like using in [00:14:22] uh C# statement using um [00:14:25] and that's all you need to do. [00:14:28] Once you did that, suspending you you're [00:14:30] suspending the painting and the layout [00:14:33] for the time being and then no matter [00:14:35] how deep your controls have been nested [00:14:39] um this completely taken out of your [00:14:41] hands and when you then you know switch [00:14:44] between uh those views that normally [00:14:47] would take a lot of time to recalculate [00:14:50] the layout, you see it here um that goes [00:14:54] like [00:14:55] in in an instance. [00:14:57] So now um I want to show you one uh more [00:15:00] thing [snorts] um [00:15:03] which is also a part of the new um [00:15:07] WinForms experience and has to do do [00:15:09] with with accessibility um [00:15:13] we we all [00:15:15] let's put it that way. There are many [00:15:16] developers that prefer dark mode um [00:15:19] for their environment and and there's [00:15:22] one particular thing that [00:15:24] I don't know if you can see it now uh [00:15:27] when I do it like over the wire so to [00:15:29] say, but if you really look closely um [00:15:32] visual visual Studio itself is one [00:15:35] example. The moment I start Visual [00:15:38] Studio, then you see this [00:15:43] short white flash in dark mode, right? [00:15:46] And pretty much [00:15:47] all the apps that are you know providing [00:15:50] dark mode have this flash and um and [00:15:54] people complained about it and it is a [00:15:55] really annoying thing. [00:15:57] So [00:15:59] we have also a resolution for that and [00:16:01] with that let's let's quickly jump into [00:16:03] the code um [00:16:05] that um [00:16:07] that shows how [00:16:08] you can really just with a few lines of [00:16:11] code um configure away those things and [00:16:15] um and to the end uh to that end let me, [00:16:18] uh, quickly go back to the, [00:16:20] uh, [00:16:21] visual styles mode app. I have no idea [00:16:23] why it closed it. [00:16:26] Probably my nervous level because this [00:16:28] old machine, uh, [00:16:30] did not [00:16:32] want to do things as I wanted. [00:16:34] It's still pretty high. [00:16:36] Um, and so let's, you know, [00:16:39] do a quick recap of [00:16:40] what we can do [00:16:42] that we are, [00:16:44] well, actually prevent those things from [00:16:46] happening. First quick recap. [00:16:49] What do we have in the application, um, [00:16:52] class, um, that was more or less always [00:16:54] there. So set compatible text rendering [00:16:57] defaults, something that we don't want [00:16:59] to go into. Uh, that's a relic from, uh, [00:17:02] from the threshold from one to, uh, from [00:17:04] .NET .NET Framework one to two. Um, we [00:17:08] we don't want to talk about that, I [00:17:09] think. [00:17:11] And then we have the old visual styles [00:17:13] would be still needs. Um, [00:17:16] then, uh, with, um, with .NET 3.1, so [00:17:19] when we first like moved from .NET [00:17:22] Framework to .NET Core, uh, we [00:17:23] introduced the set high DPI mode so that [00:17:26] we with code [00:17:28] could [00:17:29] change, um, [00:17:31] the high DPI mode, um, to the to the [00:17:33] four important uh, modes that we have. [00:17:37] Uh, and then in .NET 9, uh, we [00:17:38] introduced um, dark mode. Uh, so we do [00:17:41] that with set color mode. Um, and then [00:17:44] you can with the system color mode [00:17:45] enumeration, um, just say you want to [00:17:49] have classic or dark mode or system and [00:17:52] then it picks whatever setting you [00:17:54] uh, have in Windows. [00:17:56] Um, now these are the new ones. The set [00:17:58] default visual style mode [00:18:02] is actually the one line of code that [00:18:04] you need if you just want to act your [00:18:06] whole WinForms apps that you already [00:18:08] have and that you migrated to .NET 11, [00:18:10] um, to appear in [00:18:13] these styles that are just demonstrated. [00:18:15] So this is just one line of code. [00:18:18] But [00:18:19] that of course does probably not work [00:18:22] for everything because what you just [00:18:23] also said sa [00:18:26] saw is that the real estate that we are [00:18:29] using inside of um the [00:18:33] the several containers um that we had of [00:18:35] on the screen is logically um [00:18:39] a lot of [00:18:40] larger than the old ones. [00:18:43] So if you really went for pixel perfect [00:18:45] controls then [00:18:47] that won't work because the location [00:18:49] will stay the same, the size changes and [00:18:52] so controls will overlap. [00:18:55] So here's the thing and I think um I'm [00:18:58] sorry I ran out of time to demo that but [00:19:02] I can promise you that it works. Um [00:19:05] we will have um uh very soon for Visual [00:19:09] Studio um a series of new skills [00:19:13] for Copilot where you just can prompt [00:19:15] Copilot and say hey I have here a pixel [00:19:18] perfect a form and um can you please [00:19:23] re layout or redesign it that the [00:19:27] controls basically stay the same and [00:19:29] also their functionality. [00:19:31] But they're all put inside of a table [00:19:33] layout construct like cascading [00:19:36] construct or nested construct so that [00:19:40] the layout can really grow and shrink um [00:19:45] as your app needs it. So when you then [00:19:47] change resolutions or the the user wants [00:19:50] to change the font then that exactly [00:19:52] what you saw in the demo happens and I [00:19:55] think that then [00:19:57] the migration time [00:19:59] to to make your app really professional [00:20:01] looking again comes down to zero also [00:20:03] because the round trips are not that [00:20:06] time consuming or expensive. It's [00:20:08] actually done um very quickly. [00:20:11] So then this is then uh the next thing [00:20:14] um [00:20:16] uh that we have here and that is the the [00:20:18] form reveal mode um and [00:20:21] there are like two constants that uh [00:20:25] that we use for that [00:20:27] and that is [00:20:29] deferred and [00:20:31] and classic. Deferred means just that [00:20:35] the app cloaks, so hides [00:20:39] like a cling on ship. [00:20:41] The [00:20:43] the primary window as long [00:20:46] as those things are [00:20:48] in the build up process and the moment [00:20:51] that is done [00:20:53] we're switching to [00:20:55] the actual app. And [00:20:58] and with that by the way [00:21:00] there's two things happen in the [00:21:02] background or as a side effect I would [00:21:04] rather say and that is [00:21:07] the whole process of starting becomes [00:21:10] a little bit faster [00:21:12] and then the perception of the [00:21:14] speed how the app starts [00:21:17] is like [00:21:18] immediately [00:21:20] a completely different one because it [00:21:22] feels like it's there instantly. This is [00:21:25] almost [00:21:27] like it was written in in C++ and and [00:21:30] and native [00:21:32] Win32. [00:21:33] And [00:21:34] and with this [00:21:36] fortunately I am [00:21:39] much closer again to my time limit that [00:21:41] I wanted to be.