Monthly Archives: April 2016

Make extension methods that convert to and from Roman numerals in C#

The example Convert to and from Roman numerals in C# uses the RomanToArabic and ArabicToRoman methods to convert between Arabic and Roman numerals. See that example for a description of those methods. This example creates extension methods to make the … Continue reading

Posted in algorithms, extension methods, mathematics | Tagged , , , , , , , , , | Leave a comment

Convert to and from Roman numerals in C#

For a nice discussion of Roman numerals, see Roman Numerals, How they work. That page explains the basic rules and more advanced rules such as using parentheses or an overline to multiply values by 1,000. It includes a lot of … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , | 1 Comment

Sort ListBox or ComboBox items in numeric order in C#

If you set a ListBox control’s Sorted property to true, the control sorts its contents. Unfortunately it can only sort its contents in alphabetic order. If the items are numeric, that may not be what you want. This example sorts … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , , , , | Leave a comment

Easily reset file access and write times in C#

You can use this handy utility to reset the last access and last write times for any files that are dragged onto its executable. (I needed it because I had some files that were created while the system’s clock was … Continue reading

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

Make a slider with a value bar in C#

The example Make a slider with a needle in C# shows how to use a PictureBox to make a simple slider. This example is similar except it draws the slider in a different style. See the previous example for information … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , | Leave a comment

Resize an image to view its pixels in C#

This example shows how to resize an image so it is big enough to view its pixels. Normally you want resized images to be smooth, but this technique can be useful if you want to see exactly what colors the … Continue reading

Posted in graphics, image processing | Tagged , , , , , , , , , , , | Leave a comment

Make a slider with a needle in C#

This example draws a vertical “needle” in a PictureBox to let the user select a value much as a TrackBar does. The code does all of the drawing, however, so you have control over the slider’s appearance. The example also … Continue reading

Posted in controls, user interface | Tagged , , , , , , , , | 1 Comment

Enumerate metafile records in C#

This example shows how you can enumerate metafile records. You can then decide which ones to draw. (Although I’m not sure in general how you make that decision.) When the program starts, it uses the following code to load the … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , , , , , | Leave a comment

Read and draw a metafile in C#

This example shows how to read a metafile and draw its contents. This is really easy in C#. When the program starts, it executes the following code. private void Form1_Load(object sender, EventArgs e) { Metafile mf1 = (Metafile)Metafile.FromFile(“test.emf”); picMetafile1.Image = … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , , , , | 1 Comment

Make and use a metafile in C#

This example shows how to draw and use a metafile. A metafile is a drawing that doesn’t just contain the pixels in an image. Instead it contains a record of the commands used to produce a drawing so you can … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , , | 1 Comment