Category Archives: drawing

Print the contents of a ListView control in C#

The ListView control, like most controls, includes no support for printing. If you want to display a ListView control’s contents on a print out, you need to do all of the printing yourself. Unfortunately printing in C# is extremely flexible … Continue reading

Posted in controls, drawing, graphics, printing | Tagged , , , , , , , , , , , , | 22 Comments

Make rectangle extension methods in C#

This example shows how to add rectangle extension methods to the Rectangle and RectangleF structs. The Rectangle and RectangleF structs have several useful properties for determining their geometry such as Left, Right, Top, and Bottom, but they have no midpoint … Continue reading

Posted in drawing, extension methods, graphics | Tagged , , , , , , , , , , , , , , | Leave a 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

Draw transformed text in C#

This example uses the following Paint event handler to draw transformed text. // Draw some transformed text. private void Form1_Paint(object sender, PaintEventArgs e) { // Transform. e.Graphics.ScaleTransform(1.5f, 1.5f, MatrixOrder.Append); e.Graphics.RotateTransform(25, MatrixOrder.Append); e.Graphics.TranslateTransform(80, 30, MatrixOrder.Append); // Make a font. using (Font … Continue reading

Posted in drawing, fonts, graphics | Tagged , , , , , , , , , | 2 Comments

Make a sunburst chart in C#, Part 4

The previous post showed how to make a sunburst chart with curved text. This example extends that one so it can draw multi-line text. The previous post used the DrawTextOnArc method to draw curved text. The text is a distance … Continue reading

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

Make a sunburst chart in C#, Part 3

The post Make a sunburst chart in C#, Part 1 shows how to build a basic sunburst chart. The post Make a sunburst chart in C#, Part 2 enhances that example by drawing each node’s text at an angle so … Continue reading

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

Make a sunburst chart in C#, Part 2

The post Make a sunburst chart in C#, Part 1 explained how to build a simple sunburst chart. Unfortunately the node labels used by that chart didn’t fit their wedges very well because the text was all drawn horizontally. This … Continue reading

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

Make a sunburst chart in C#, Part 1

A sunburst chart displays hierarchical data in a circular diagram. The hierarchy’s root is drawn in the center. Its children sit in a ring around the root. After that, each node’s wedge in a ring is divided among its children … Continue reading

Posted in drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , | 3 Comments

Make a shaded ellipse control in C#

Note: Before you can use the ShadedEllipse control in the example program, you must build the solution. After you download the example, build it before you try to view the form. This example walks through building a control that draws … Continue reading

Posted in controls, drawing, graphics | Tagged , , , , , , , , , | 1 Comment