コード例 #1
0
ファイル: CopyCmd.cs プロジェクト: jpmofo/exp-site
 public override void executePress(Point p, Drawing d)
 {
     //grab frontmost shape at point, copy it, then perform normal move command on copy
     s = d.getFrontmostContainer(p);
     d.copy(s);
     base.executePress(p,d);
 }
コード例 #2
0
ファイル: ColorCmd.cs プロジェクト: jpmofo/exp-site
 public override void executeClick(Point p, Drawing d)
 {
     //if current point is contained by a shape
     if (d.getFrontmostContainer(p) != null)
     {
         //set shape's color equal to drawing object's color
         d.getFrontmostContainer(p).MyColor = d.MyColor;
     }
 }
コード例 #3
0
ファイル: MoveCmd.cs プロジェクト: jpmofo/exp-site
        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());
        }
コード例 #4
0
ファイル: MoveCmd.cs プロジェクト: jpmofo/exp-site
        public override void executeDrag(Point p, Drawing d)
        {
            //as long as point is contained in a shape onscreen...
            if (s != null)
            {
                s.move(p.X-lastX,p.Y-lastY);
                lastX = p.X;
                lastY = p.Y;

            }
            return;
        }
コード例 #5
0
ファイル: Drawing.cs プロジェクト: jpmofo/exp-site
        //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;
        }
コード例 #6
0
ファイル: AddLine.cs プロジェクト: jpmofo/exp-site
        //on mouse move
        public override void executeDrag(Point p, Drawing d)
        {
            d.clear();

            //if point of click was to the left of current point...
            if (lastX < p.X)
            {
                d.MyShape = new Segment(lastX,lastY,p.X-lastX,p.Y-lastY,d.MyColor,5);
            }
            //if point of click was to the right of current point...
            else if (p.X < lastX)
            {
                d.MyShape = new Segment(p.X, p.Y, lastX-p.X,lastY-p.Y,d.MyColor,5);

            }
        }
コード例 #7
0
ファイル: Command.cs プロジェクト: jpmofo/exp-site
 //on mouse down
 public abstract void executePress(Point p, Drawing d);
コード例 #8
0
ファイル: Command.cs プロジェクト: jpmofo/exp-site
 //on mouse move
 public abstract void executeDrag(Point p, Drawing d);
コード例 #9
0
ファイル: Command.cs プロジェクト: jpmofo/exp-site
 //on mouse up
 public abstract void executeClick(Point p, Drawing d);
コード例 #10
0
ファイル: AddLine.cs プロジェクト: jpmofo/exp-site
 //on mouse down
 public override void executePress(Point p, Drawing d)
 {
     //identify original point of mouse down
     lastX = p.X;
     lastY = p.Y;
 }
コード例 #11
0
ファイル: AddLine.cs プロジェクト: jpmofo/exp-site
 //on mouse up
 public override void executeClick(Point p, Drawing d)
 {
     d.addShape(d.MyShape);
     d.MyShape = null;
 }
コード例 #12
0
ファイル: DeleteCmd.cs プロジェクト: jpmofo/exp-site
 public override void executePress(Point p, Drawing d)
 {
 }
コード例 #13
0
ファイル: DeleteCmd.cs プロジェクト: jpmofo/exp-site
 public override void executeDrag(Point p, Drawing d)
 {
 }
コード例 #14
0
ファイル: DeleteCmd.cs プロジェクト: jpmofo/exp-site
 public override void executeClick(Point p, Drawing d)
 {
     //if current point is contained in a shape
     if(d.getFrontmostContainer(p)!=null)d.delete(d.getFrontmostContainer(p));
     return;
 }
コード例 #15
0
ファイル: MoveCmd.cs プロジェクト: jpmofo/exp-site
 public override void executeClick(Point p, Drawing d)
 {
     s = null;
 }