386
//------
public void setSelected(bool b) { selected = b;
}
//-----
//move to new position
public void move(int xp, int yp) {
x = xp; |
y = yp; |
saveAsRect(); |
|
} |
|
//----- |
|
public virtual void draw(Graphics g) { //draw rectangle g.DrawRectangle(bPen, x, y, w, h); if(filled)
g.FillRectangle (rBrush, x,y,w,h); drawHandles(g);
}
//-----
public void drawHandles(Graphics g) { if (selected) { //draw handles
g.FillRectangle(bBrush, x + w / 2, y - 2, 4, ); g.FillRectangle(bBrush, x - 2, y + h / 2, 4, ); g.FillRectangle(bBrush, x + (w / 2),
y + h - 2, 4, 4); g.FillRectangle(bBrush, x + (w - 2),
y + (h / 2), 4, 4);
}
}
//-----
//return whether point is inside rectangle public bool contains(int x, int y) {
return rect.contains (x, y);
}
//------
//create Rectangle object from new position protected void saveAsRect() {
rect = new CsharpPats.Rectangle (x,y,w,h);
}
public void setFill(bool b) { filled = b;
}