Tag Archives: dash

Render dashed lines in a WPF program using C#

When you draw in WPF, you create a Pen object. You can set that object’s DashStyle to make the pen draw dashed or dotted lines. The following code shows how this example draws the second line from the top. Pen … Continue reading

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

Let the user zoom on a picture in C#

The example Provide autosave in C# explains how to make a program that lets the user draw lines in different colors and styles. That program lets the user undo and redo, save and load drawings, and autosaves so it can … Continue reading

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

Provide autosave in C#

This example extends the scribble example (most recently described in the post Provide undo and redo in C#) so it provides an auto-save feature. The following code creates the name of the program’s auto-save file. // The auto-save file name. … Continue reading

Posted in drawing, files, graphics, serialization | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Provide undo and redo in C#

This example adds undo and redo features to the example Save and restore pictures drawn by the user in C#. It’s not terribly hard, but it is long so I’ll break it into sections to make it easier to understand. … Continue reading

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

Save and restore pictures drawn by the user in C#

The example Let the user scribble with different line styles in C# explains how to let the user draw curves with different colors, line thicknesses, and dash patterns. This example adds the ability to save and load pictures drawn by … Continue reading

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

Let the user scribble with different line styles in C#

The example Let the user scribble on a PictureBox in C# explains how to let the user draw polylines, but the program only draws thin black curves. This example adds color, line thickness, and line styles such as dashed or … Continue reading

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

Draw lines with custom dash patterns in C#

To create lines with custom dash patterns, first create a Pen object and set its DashStyle property to Custom. Then set its DashPattern property to an array of floating point numbers that indicate how many units to draw and then … Continue reading

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