Tag Archives: Windows Forms programming

Make silly eyes that track the mouse without flicker in C#

The example Make silly eyes that track the mouse in C# shows how to make eyes track the mouse position, but if you look closely as that program runs you will see a noticeable flicker. The solution is quite simple: … Continue reading

Posted in games, geometry, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Make silly eyes that track the mouse in C#

This example uses a Timer named tmrTick to track the mouse. Its Tick event handler, which is shown in the following code, updates the eyes. // The previous mouse location. private Point OldMousePos = new Point(-1, -1); // See if … Continue reading

Posted in games, geometry, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Compare the performance of simple arithmetic operations in C#

I saw a post the other day that said division was the slowest arithmetic operation so I wrote this example to see exactly how the performance of multiplication, division, addition, and subtraction differ with floating point numbers. When you click … Continue reading

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

Make a 3D globe in WPF and C#

This example shows how you can draw a 3D globe. More generally it shows how you can make a three-dimensional textured sphere in WPF. The example Draw smooth spheres using WPF and C# shows how to make smooth colored spheres. … Continue reading

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

Graph event probabilities in C#

The example Calculate the probability of an event occurring in a given number of trials in C# shows how to calculate event probabilities. This example graphs the results. You can use the example to get some feel for how the … Continue reading

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

Find the number of trials for an event probability in C#

The post Understand probabilities of unrelated events (and escaping zombies) explains how to calculate the number of trials necessary to reach a certain probability of an event occurring. It explains that if an event has a probability P of occurring … Continue reading

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

Calculate the probability of an event occurring in a given number of trials in C#

The post Understand probabilities of unrelated events (and escaping zombies) explains how to calculate the probability of an event occurring in a certain number of trials. It explains that if an event has a probability P of occurring at each … Continue reading

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

Understand probabilities of unrelated events (and escaping zombies)

Given some event with a relatively low probability, what is the probability that the event will occur if you perform many trials? For example, suppose the zombie apocalypse has arrived and there’s a 1% chance that the zombies will get … Continue reading

Posted in mathematics | Tagged , , , , , , , , , | 2 Comments

Display reusable dialog forms in C#

The example Make a dialog with standard dialog features in C# shows the most common approach to making dialogs. Whenever it needs to display the dialog, the main program initializes a new instance of it and displays it. If the … Continue reading

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

Make a TextBox with auto-complete in C#

It’s not too hard to make a TextBox provide an auto-complete feature. In fact, the TextBox control offers three auto-complete styles. This example demonstrates those styles. To provide auto-complete, you need to set the following three TextBox properties. AutoCompleteMode – … Continue reading

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