الجمعة، 28 نوفمبر 2008

Make Paint Brush Easy

صورة

Introduction

Paint Brush tool is similar to the pencil (Free hand) with more features. It too can be used in different colors, the shape and size of the Paint Brush can also be changed.

Project Idea
صورة


Global Variable

صورة

Steps

In mouse down
صورة

In mouse move
صورة

Problem

If we run the previous code, the free hand will work but if we stop in drawing we will note that , pen is still drawing however the mouse up so we will make flag and test through it where flag will be true if mouse down and set flag to be false while mouse up.

صورة

صورة

صورة

Change Color of Pencil

صورة

Steps:

In event of Label : make all label in one event

صورة

Note: I add flag named colorflag because I give default color to pen when app run first , I depend on getting color if user press click on label so if I do not make this flag and user start to draw without choose color exception will occur, so I avoid this by given default color and if make something like sensor to know if user click on label and if this done I will switch to take user color.

Change Size of pencil

صورة

Surprise!!!

After we ended from paint brush if we minimize the form to taskbar we will note that the form not contains any graphics and like a blank page.

Solution
I will class that store each point p1, p2 and pen and for each line I do I will store it in Arraylist then I will retrieve data stored in Arraylist in event Paint.
صورة


Save Your Image

صورة

Future develpoement

if Allah wishes i will add the following to the following

add undo & redo to lines.
open image
make paint brush client-server