jeudi 26 février 2015

decorator pattern in drawing program

yep, Hi everybody I'm a newbie in design pattern and I want to ask something about decorator pattern


I'm trying to make software about drawing shape like : line, rectangle.... and I want to apply decorator pattern to make effect when I click on "line" in form ....This is my Implement Decorator



class Composite
{}
class line, rect...: Composite
{}

interface UserCommand
{
void Excute();
}

class ClickStyle: UserCommand
{
Composite Concrete;
.....
}

class MoveStyle: UserCommand
{
Composite Concrete;
...
}

Composite Line = new Line();
if(LineClick)
Line = new BorderStyle(Line);
if(LineMove)
Line = new MoveStyle(Line);
....
To add Effect


But how to remove this Effect when User NotClick, and NotMove?


Exp: I Have Line have both Click and Move Effect And I Click Rect ...How to Remove Effect from Line?


I'm not good in English, Sorry For That. Thanks For View this Post... :)


Aucun commentaire:

Enregistrer un commentaire