Tag Archives: example

Examine the relationship between the Fibonacci sequence and phi in C#

The golden ratio (also called the golden mean, golden section, or divine proportion) is a number that pops up in a surprising number of places in geometry and nature. This number is also called φ (phi, pronounced either “fee” or … Continue reading

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

Use a TextFieldParser to read fixed-width data in C#

This example uses a TextFieldParser object to load fixed-width data from a file that contains names and addresses. Each field has a fixed width. Some records also have ZIP+4 format ZIP codes (for example, 08109-2120) and the program should discard … Continue reading

Posted in classes, database, files, parsing | Tagged , , , , , , , , , , , , , , , | Leave a comment

Use a TextFieldParser to read delimited data in C#

This example uses a TextFieldParser object to parse a data file that contains name and address data. The data contains fields delimited by commas and semi-colons. Some records also have ZIP+4 format ZIP codes (for example, 08109-2120) and the program … Continue reading

Posted in classes, database, files, parsing | Tagged , , , , , , , , , , , , , | 2 Comments

Suspend or hibernate the system in C#

The Application.SetSuspendState method lets an application make the system suspend or hibernate. A suspended system enters a low power mode. A hibernating system saves its memory contents to disk and then enters low power mode. Because it doesn’t need to … Continue reading

Posted in system | Tagged , , , , , , , , , , , , | Leave a comment

Make light pixels transparent in an image in C#

Recently I had an image and I wanted to make all of the light pixels transparent. Ideally I could simply make the white pixels transparent, but the image was scanned so few of the pixels were pure white. What I … Continue reading

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

Draw a smiley face with WPF in C#

Often I need to use images for demonstration purposes or for a book, and a smiley face makes a neutral, pleasant image. This example shows how to draw a smiley face with XAML and WPF, and then save an image … Continue reading

Posted in drawing, graphics, image processing, wpf, XAML | Tagged , , , , , , , , , , , , , , | Leave a comment

Rotate images that are scaled in C#

The example Interactively rotate images in C# lets you click and drag to rotate images but it doesn’t always work well if the image you are rotating is too big to fit on the screen. The example Rotate images inside … Continue reading

Posted in algorithms, graphics, image processing, transformations | Tagged , , , , , , , , , , , , , , | 1 Comment

Rotate images inside a scrolled panel in C#

The example Interactively rotate images in C# lets you click and drag to rotate images. Unfortunately it doesn’t work well with images that are too big to fit on the screen. If an image is too big, the program lets … Continue reading

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

Explore the Visual Studio Image Library in C#

This example explains where you can find standard images in the Visual Studio Image Library that you can use in your applications. The example Give transparent backgrounds to images displayed on buttons in C# explains how to make some pixels … Continue reading

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

List controls on a form in C#

There are several ways you can list controls on a form. At design time, you can open the form and then use the dropdown at the top of the Properties window. You can also look inside the file Form1.Designer.cs. At … Continue reading

Posted in controls, forms, system | Tagged , , , , , , , , , | Leave a comment