Public Brushsize Brushalpha Clear Getimage
Public Brushsize Brushalpha Clear Getimage
It provides the following features: a round Brush, size selection of brush, brush opacity and a Clear option. For organizing the application, a Grid was used: in the left we have the canvas for editing the image, the Clear button, and under the canvas the size and opacity selectors. In the middle there is a Get Image command button which makes the conversion from the drawn mage to ImageSource. A save to disk option, or conversion to .jpg/.bmp/.png type was not implemented since it raises some difficulties and additional libraries are necessary. The following public properties and methods were used in implementation:
BrushSize - Dependency property. Brush size BrushAlpha - Dependency property. Brush opacity Clear() -Clear canvas GetImage() - Get current image
There are 3 layers that make possible the drowing of the image:
Sheet - It is a grid that contains geometries that have been drawn. CursorCanvas - Contains brush cursor and cross cursor InputCanvas - Collects all mouse inputs.
First, it is necessary to capture the mouse, to avoid drawing to be finished after user moves out of the control. Next, a path is created with selected opacity and dropped into Sheet. Geometry variable contains geometry that is drawn right now. The path is created by drawing a set of ellipses connected by rectangles. In the end the path is rendered . For this application the following tools are necessary: Silverlight 4 Tools for Visual Studio 2010, Silverlight 4 Runtime, Microsoft Expression Blend 4 Silverlight available at : http://www.silverlight.net/downloads