public Shape(Shape s) { myX = s.myX; myY = s.myY; myWidth = s.myWidth; myHeight = s.myHeight; myColor = s.myColor; myCenter = s.myCenter; }
public override void executePress(Point p, Drawing d) { lastX = p.X; lastY = p.Y; do { s = d.getFrontmostContainer(p); doTwice++; }while(doTwice < 2); //System.Windows.Forms.MessageBox.Show(d.getFrontmostContainer(p).ToString()); }
//copy constructor public Drawing(Drawing d) { InitializeComponent(); ClientSize = d.ClientSize; myImage = d.myImage; myShapes = new ArrayList(); //copy each shape in list foreach (Shape s in d.myShapes) { myShape = new Rect(0,0,1,1,Color.Black); //is s a rectangle...? if (myShape.GetType() == s.GetType()) myShape = new Rect((Rect)s); else { //is it an oval...? myShape = new Oval(0,0,1,1,Color.Black); if (myShape.GetType() == s.GetType()) myShape = new Oval((Oval)s); else { //is it a line...? myShape = new Segment(0,0,1,1,Color.Black,1); if (myShape.GetType() == s.GetType()) myShape = new Segment((Segment)s); else { //is it a triangle...? Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(); myShape = new Triangle(p1,p2,p3,Color.Black); if (myShape.GetType() == s.GetType()) myShape = new Triangle((Triangle)s); } } } myShape.MyColor = s.MyColor; myShape.MyCenter = s.MyCenter; myShapes.Add(myShape); } myShape = d.myShape; offGraphics = d.offGraphics; visGraphics = d.visGraphics; offBitmap = d.offBitmap; offGraphics = Graphics.FromImage(offBitmap); myColor = d.myColor; }
public void front(Shape s) { Shape temp = s; myShapes.Remove(s); myShapes.Add(s); }
public void exchangeWithFront(Shape s) { Shape temp = (Shape) myShapes[myShapes.Count-1]; myShapes.Insert(myShapes.IndexOf(s),temp); temp = s; myShapes.Remove(s); myShapes.Add(s); }
public void delete(Shape s) { myShapes.Remove(s); }
public void copy(Shape s) { Shape temp; if (s!=null) { temp = new Rect(0,0,1,1,Color.Black); //is s a rectangle...? if (temp.GetType() == s.GetType()) temp = new Rect((Rect)s); else { //is it an oval...? temp = new Oval(0,0,1,1,Color.Black); if (temp.GetType() == s.GetType()) temp = new Oval((Oval)s); else { //is it a line...? temp = new Segment(0,0,1,1,Color.Black,1); if (temp.GetType() == s.GetType()) temp = new Segment((Segment)s); else { //is it a triangle...? Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(); temp = new Triangle(p1,p2,p3,Color.Black); if (temp.GetType() == s.GetType()) temp = new Triangle((Triangle)s); } } } //put the brand new copy into myShapes right after(above in the picture) the original myShapes.Insert(myShapes.IndexOf(s)+1,temp); } //if s is null, do nothing return; }
//clear EVERYTHING public void clearAll() { if (myImage != null) myImage = null; myShapes.Clear(); myShape = null; offGraphics.Clear(Color.White); //this.Invalidate(); }
public void back(Shape s) { Shape temp = s; myShapes.Remove(s); myShapes.Insert(0,s); }
public void addShape(Shape s) { if (s!=null)myShapes.Add(s); return; }
public override void executeClick(Point p, Drawing d) { s = null; }