Modernizing .NETpad Step-By-Step, Part 4: More Settings (Premium)

I probably should have realized that there was no way to document the new settings interface in just a single article. But let's wrap that up now.

In the previous article, I discussed how to implement a Notepad-like settings pane that takes over the entire app window and correctly handles the transition between that and the main app UI in both direction. We also implemented the Back button that gets the user out of there and the first three settings on that pane--App theme (which doesn't currently do anything), Font (which includes Font family, style, and size settings), and Word wrap--plus associated labels and formatting.

There are two major settings left to implement--Auto save, which is unique to .NETpad, and Spell check--plus a few hidden settings from Notepad that don't currently work (which I did make, but will skip here)--all their associated labels and formatting, an "About this app" section, and a "Reset settings" button at the bottom of settings that's especially useful when working on the app (and could be expanded to offer various choices).

That's the goal. Let's get started: There's a ton of XAML code in there, but most of it is straightforward.
Implement files-related settings UIs
The third section in settings is called Files. (This is called Opening Notepad in the original app, but because the two settings it contains--Opening files and When Notepad starts--are something we may try to implement later (or not), we're going to skip those, and rename the section). And there's just a single setting in there, for Auto save.

The Files header should be familiar by now, as it's nearly identical to the previous headers, Appearance and Text formatting.

The next section is for the Auto save feature. This is a toggle--it's either on or it's off--so mirroring the UI from Word wrap makes sense. That is, it's another "fake" Expander created with a Stackpanel wrapped in a Border. But the trick here will be making sure we hit all three of the places where this feature communicates its current status: In the File menu, in the status bar, and now in settings.

We'll add the code needed to correctly present this feature as on or off (and to handle the user changing it here in settings) below.
Implement spelling-related settings UIs
Notepad recently added a spell check feature, along with autocorrect and some associated sub-features. Autocorrect isn't natively available in WPF, so we'll skip that for now. But spell check is. So we'll need a Spelling header and then a Spell check expander.

As with the previous headers, the Spelling header is familiar.

And, so too is the code for the Spell check expander, which is another Stack panel wrapped in a Border. Same as ever.

As with Auto save, we'll add the C# code for this setting after we're doing laying out the XAML user interface.
Implement About this app
And that's it for the settings, amazingly. (Not counting the two or three we're not implementing, at...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Thurrott