Tag Archives: resources

Load a cursor from a resource in C#

Sometimes it’s useful to use a non-standard cursor in a program. This example explains how you can load a cursor from a cursor file included as a project resource. To add a cursor file to the project’s resources, open the … Continue reading

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

Make a text file a project resource in C#

This is handy for including a large amount of text as a project resource instead of putting the text directly in the code or including a file in the program’s installation package. Open the Project menu and select Properties. Open … Continue reading

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

Play an audio resource in C#

The System.Media.SoundPlayer class lets you easily play a WAV file stored as an audio resource. For this example, first add the WAV file as an audio resource. To do that, open the Project menu and select Properties. Then open the … Continue reading

Posted in audio, multimedia | Tagged , , , , , , , , , , , , , | 1 Comment

Play WAV files in C#

The System.Media.SoundPlayer class lets you easily play WAV files. This example uses the following PlayWav method to play WAV files. // The player making the current sound. private SoundPlayer Player = null; // Dispose of the current player and // … Continue reading

Posted in audio, files, multimedia | Tagged , , , , , , , , , , , , , | Leave a comment

Use a string collection setting in C#

A program’s settings can include many data types such as int, char, DateTime, and Color. If you want to be able to hold a list of strings, you can make a setting that has type StringCollection. To create such a … Continue reading

Posted in settings | Tagged , , , , , , , , , | 1 Comment

Use vectors to manage bouncing balls in C#

This example is similar to the one Use sprites to animate several bouncing balls in C# except it uses vectors to store information about the balls. A vector is a direction represented by X and Y coordinates. For example, the … Continue reading

Posted in algorithms, animation, audio, geometry, graphics, multimedia | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

Use sprites to animate several bouncing balls in C#

This example is similar to the one described in the post Animate several bouncing balls in C# except it uses sprites to control the balls. The previous example stores the ball data in a group of arrays. This approach works … Continue reading

Posted in algorithms, animation, audio, graphics, multimedia | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Animate several bouncing balls in C#

This example modifies the earlier post Make a bouncing ball animation in C# to animate several bouncing balls. Much of the basic idea is the same so see that example first. The big difference is that this version stores ball … Continue reading

Posted in animation, audio, graphics, multimedia | Tagged , , , , , , , , , , , , , | 3 Comments

Make a bouncing ball animation in C#

This example shows how to make a bounding ball animation. When the form loads, the following code executes. // Some drawing parameters. private const int BallWidth = 50; private const int BallHeight = 50; private int BallX, BallY; // Position. … Continue reading

Posted in animation, audio, multimedia | Tagged , , , , , , , , , , , , | 4 Comments

Draw text filled with a picture in C#

This example shows how you can draw text filled with a picture. It uses two images added to the project as resources. (To add resources to the project, open the Project menu and select the Properties command at the very … Continue reading

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