Author Archives: Rod Stephens

Easily manipulate pixels in WPF and C#

After building the example Save bitmap files in WPF and C#, I couldn’t get it out of my head. Doing the math to set the correct bytes in a one-dimensional pixel array isn’t all that hard, but it is annoying … Continue reading

Posted in graphics, image processing, wpf | Tagged , , , , , , , , , , , , , | 1 Comment

Save bitmap files in WPF and C#

This example shows how to use WPF and C# to save bitmap files. The example Set the pixels in a WPF bitmap in C# shows how to create a WriteableBitmap in WPF. This example shows how to save the resulting … Continue reading

Posted in files, graphics, image processing | Tagged , , , , , , , , , , , , , , , | 3 Comments

Draw different styles of “illuminated” text in C#

My previous post Draw “illuminated” text in C# showed how to draw “illuminated” text. It drew each paragraph’s initial letter in a large font with a box around it. Real illuminated manuscripts typically make the initial letter much more elaborate. … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , | Leave a comment

Draw “illuminated” text in C#

This example lets you draw “illuminated text” where each paragraph begins with an oversized letter. In some illuminated manuscripts, the first letter of a paragraph is drawn in a larger font than the remaining text. This example does something similar. … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , | 2 Comments

Merge directories in C#

This example lets you merge directories. Once upon a time, if you used Windows Explorer to move a file from one directory to another and the destination directory already contained a file with that name, you had the option of … Continue reading

Posted in directories, files, system, tools | Tagged , , , , , , , , , , , , , , | Leave a comment

Use a FileSystemWatcher to build a spooler in C#

This example uses a FileSystemWatcher to implement a spooling program. SPOOL is an ancient computer acronym dating from the 1950s that stands for “Simultaneous Peripheral Operations On-Line.” It is a technique in which jobs are placed in a queue in … Continue reading

Posted in controls, files | Tagged , , , , , , , , , , , , | 2 Comments

Implement interfaces explicitly or implicitly in C#

Suppose you create a class and in the declaration you indicate that it implements one or more interfaces. If you right-click an interface’s name, the dropdown displayed by Visual Studio includes an “Implement Interface” submenu. If you look at the … Continue reading

Posted in interfaces, syntax | Tagged , , , , , , , , , , | Leave a comment

Understand ways to end case blocks in C#

There are several ways that you can exit case blocks in a switch statement. For example, consider the following code. string result = “”; int control = 1; switch (control) { case 1: case 2: result = “One or two”; … Continue reading

Posted in syntax | Tagged , , , , , , , , , , | 2 Comments

Control a loop that uses floating-point values in C#

Sometimes you might need to use a floating-point variable that loop over a range of values. For example, you might want a value to step through the values 0.0 through 1.0 in increments of 0.1. The sequence of numbers would … Continue reading

Posted in calculations, mathematics, variables | Tagged , , , , , , , , , , , , , , | Leave a comment

Display locale-aware sample dates and currency values in C#

This program uses the following simple CultureData class to store information about a locale. // A class to store cultre data. public class CultureData { // The CultureInfo. public CultureInfo Info; // Initializing constructor. public CultureData(CultureInfo info) { Info = … Continue reading

Posted in internationalization, localization | Tagged , , , , , , , , , , , , , , , | Leave a comment