Monthly Archives: June 2016

Draw a simple robot arm with a hand in C#

The example Draw a simple robot arm in C# shows how to use transformations to make it (relatively) easy to draw a robot arm. Each piece of the arm is transformed to account for the pieces closer to the arm’s … Continue reading

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

Draw a simple robot arm in C#

This is really an exercise in using graphical transformations. You can draw each segment and joint in the arm by using simple drawing methods and transformations to rotate and translate the parts to their correct positions. The basic idea is … Continue reading

Posted in algorithms, drawing, graphics | Tagged , , , , , , , , , | 11 Comments

Fill a shape with random lines in C#

Click and drag to draw a shape. When you release the mouse, the program closes the shape and fills it with random line segments. The following code shows how the program lets you draw a shape. // The points selected … Continue reading

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

Fill an ellipse with random lines in C#

As the title implies, this example draws an ellipse filled with random lines. It cannot simply draw the ellipse in the form’s Paint event handler, however. That would make the program generate a new set of random lines every time … Continue reading

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

Use WPF code to display subscripts and superscripts in C#

In the post Display subscripts and superscripts in a WPF TextBlock in C# I mentioned that you could make subscripts and superscripts in WPF code but it was easier in XAML code. Juan Manuel Montes asked for an example, so … Continue reading

Posted in fonts, formatting, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , | Leave a comment

Display subscripts and superscripts in a WPF TextBlock in C#

The following examples show how to display subscripts and superscripts in a RichTextBox in a Windows Forms program. Easily display subscripts and superscripts in a RichTextBox in C# Display subscripts and superscripts in a RichTextBox in C# In a WPF … Continue reading

Posted in fonts, formatting, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Easily display subscripts and superscripts in a RichTextBox in C#

The example Display subscripts and superscripts in a RichTextBox in C# requires you to make arrays holding the positions of the characters that should be subscripts and superscripts. That’s not a big deal but it does require you to count … Continue reading

Posted in fonts, formatting | Tagged , , , , , , , , , , , , , , , | 1 Comment

Display subscripts and superscripts in a RichTextBox in C#

A TextBox can only use a single font at a time so it can’t display subscripts and superscripts, but a RichTextBox can do it. Simply use the control’s Select method to select the text that should be a subscript or … Continue reading

Posted in fonts, formatting | Tagged , , , , , , , , , , , , , | 1 Comment

Calculate credit payments in C#

For each month the program: Calculates the payment first. This is either a percent of the balance or the minimum amount, whichever is greater. Calculates interest after the payment is calculated but before it is subtracted from the balance. Adds … Continue reading

Posted in algorithms, calculations, finance, mathematics | Tagged , , , , , , , , , , , , , | Leave a comment

Make a stacked graph showing compound interest in C#

The example Show compound interest graphically in C# displays a graph showing contributions, compound interest, and total balance over time for a monthly investment strategy. This example may provide a better representation than that one. It shows the total contributions … Continue reading

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