Tag Archives: graphics

Use statement lambdas in C#

The example Use lambda expressions in C# showed how to use lambda expressions to concisely create an anonymous method that takes parameters and returns a value. The following code shows one of the lambda expressions that example used. private void … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Use lambda expressions in C#

Lambda expressions are basically just a shorthand notation for making an anonymous method. There are a couple of formats, the simplest of which has the following syntax. x => expression Here expression is an expression involving the variable x. For … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , , , | 1 Comment

Use anonymous methods in C#

My previous post Use the predefined Action, Func, and EventHandler delegate types in C# explains how to use the predefined generic Func, Action, and EventHandler delegate types to graph four functions F(x, y). It uses the following code to define … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , | 1 Comment

Use the predefined Action, Func, and EventHandler delegate types in C#

This and the next couple of posts discuss delegates and the somewhat related topics of anonymous methods and lambda expressions. Briefly, delegate types are programmer-defined data types that represent methods. For example, the following code declares a delegate type. // … Continue reading

Posted in algorithms, graphics, variables | Tagged , , , , , , , , , , , , | 1 Comment

Make a button display the picture beneath slightly grayed it in C#

The example Make a button display the picture beneath it in C# shows how to make a button display the picture that lies below it. Unfortunately, the button only adds a border as decoration and the border doesn’t have a … Continue reading

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

Make a button display the picture beneath it in C#

This example makes a button display copies of the picture on which it sits, making it appear that the button is part of the underlying image. The key to this example is the following SetButtonBackground method. // Make the Button … Continue reading

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

Draw a picture-filled histogram in C#

The example Make a simple histogram in C# shows how to draw a histogram. This example shows how to fill the histogram’s bars with pictures. The following TileRectangle method fills a rectangle with an image. // Tile an area from … Continue reading

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

Make a dice-rolling simulation in C#

This example performs a simulation of rolling two six-sided dice. It’s related to my book Interview Puzzles Dissected, which includes several examples that involve rolling dice. When you enter a number of trials and click Roll, the program uses the … Continue reading

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

Tile a PictureBox in C#

If you set a form’s BackgroundImageLayout property Tile, then the control fills itself with copies of its background image. Strangely the PictureBox control does not have a corresponding Tile property. This example shows one way you can tile images on … Continue reading

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

Use a symbiote to graphically select hours in C#

This example modifies the previous example Graphically select hours in C# so it uses a symbiote class. That example shows how to use a PictureBox to let the user select a range of hours. If you want to let the … Continue reading

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