Beispiel #1
0
 public override void Complete(SketchControl s, Point p1, Point p2)
 {
     shapeAction shapeAction = new shapeAction(Shape.Circle, true, p2, width, p1, this.brush, 0);
     s.sketch.stuff.Add(shapeAction);
     s.sketch.undo.Push(shapeAction);
     s.sketch.redo.Clear();
 }
Beispiel #2
0
        public bool checkCloseToCircle(shapeAction action, Point place)
        {
            double a = (action.startPoint.X - action.endPoint.X) / 2.0;
            double b = (action.startPoint.Y - action.endPoint.Y) / 2.0;
            double x = place.X - (action.startPoint.X + action.endPoint.X) / 2.0;
            double y = place.Y - (action.startPoint.Y + action.endPoint.Y) / 2.0;

            if (!action.filled)
                return ((x * x) / (a * a)) + ((y * y) / (b * b)) - 1 <= 0.1;
            return ((x * x) / (a * a)) + ((y * y) / (b * b)) < 1;
        }
Beispiel #3
0
 private void drawRectangle(shapeAction action, Graphics gr)
 {
     Point leftTop = new Point(Math.Min(action.startPoint.X, action.endPoint.X),
                               Math.Min(action.startPoint.Y, action.endPoint.Y));
     int width = Math.Abs(action.endPoint.X - action.startPoint.X);
     int height = Math.Abs(action.endPoint.Y - action.startPoint.Y);
     switch (action.filled)
     {
         case true:
             gr.FillRectangle(action.brush, leftTop.X, leftTop.Y, width, height);
             break;
         case false:
             gr.DrawRectangle(new Pen(((SolidBrush)action.brush).Color, action.width),
                              leftTop.X, leftTop.Y, width, height);
             break;
     }
 }
Beispiel #4
0
 private void drawCircle(shapeAction action, Graphics gr)
 {
     switch (action.filled)
     {
         case true:
             gr.FillEllipse(action.brush,
                            action.startPoint.X,
                            action.startPoint.Y,
                            action.endPoint.X - action.startPoint.X,
                            action.endPoint.Y - action.startPoint.Y);
             break;
         case false:
             gr.DrawEllipse(new Pen(((SolidBrush)action.brush).Color, action.width),
                            action.startPoint.X,
                            action.startPoint.Y,
                            action.endPoint.X - action.startPoint.X,
                            action.endPoint.Y - action.startPoint.Y);
             break;
     }
 }
Beispiel #5
0
 public void drawShape(shapeAction action, Graphics gr)
 {
     switch (action.shape)
     {
         case Shape.Circle:
             drawCircle(action, gr);
             break;
         case Shape.Rectangle:
             drawRectangle(action, gr);
             break;
     }
 }
Beispiel #6
0
        public bool checkCloseToRectangle(shapeAction action, Point place)
        {
            int startX = action.startPoint.X;
            int startY = action.startPoint.Y;
            int endX = action.endPoint.X;
            int endY = action.endPoint.Y;
            int mouseX = place.X;
            int mouseY = place.Y;

            switch (action.filled)
            {
                case true:
                    if (((mouseX <= startX && mouseX >= endX) ||
                         (mouseX >= startX && mouseX <= endX)) //check of je X in het vierkant ligt
                         &&
                        ((mouseY <= startY && mouseY >= endY) ||
                         (mouseY >= startY && mouseY <= endY))) //check of je Y in het vierkant ligt
                        return true;
                    return false;
                case false:
                    Point point1 = new Point(startX, endY);
                    Point point2 = new Point(endX, startY);
                    return checkCloseToLine(action.startPoint, point1, place)
                        || checkCloseToLine(point1, action.endPoint, place)
                        || checkCloseToLine(action.endPoint, point2, place)
                        || checkCloseToLine(point2, action.startPoint, place);
            }
            return false;
        }
Beispiel #7
0
 public override void whileDrawing(SketchControl s, Point p1, Point p2)
 {
     Action currentAction = new shapeAction(Shape.Circle, true, p2, width, p1, this.brush, 0);
     drawWhileDrawing(currentAction, s);
 }