예제 #1
0
파일: MiniCad.cs 프로젝트: Hauser/oop
        public void Create(Shape shape, OOP1.Point pos)
        {
            pos.m_X -= ShapeSize / 2;
            pos.m_Y -= ShapeSize / 2;

            switch (shape)
            {
            case OOP1.Rectangle _:
                _shapes.Add(new OOP1.Rectangle(pos, new OOP1.Point(pos.m_X + ShapeSize, pos.m_Y + ShapeSize)));
                break;

            case Circle _:
                _shapes.Add(new Circle(pos, ShapeSize / 2));
                break;

            case Triangle _:
                _shapes.Add(new Triangle(
                                new OOP1.Point(pos.m_X + ShapeSize / 2, pos.m_Y),
                                new OOP1.Point(pos.m_X, pos.m_Y + ShapeSize),
                                new OOP1.Point(pos.m_X + ShapeSize, pos.m_Y + ShapeSize)));
                break;

            default:
                break;
            }
        }
예제 #2
0
 public bool Move(OOP1.Point pos)
 {
     if (_draggedShape != null)
     {
         _draggedShape.Move(pos.m_X - ShapeSize / 2, pos.m_Y - ShapeSize / 2);
         return(true);
     }
     return(false);
 }
예제 #3
0
파일: MiniCad.cs 프로젝트: Hauser/oop
 public void Delete(OOP1.Point pos)
 {
     _shapes.RemoveAll(s => s.IsHit(pos));
 }
예제 #4
0
 public void StartMove(OOP1.Point pos)
 => _draggedShape = _shapes.Find(s => s.IsHit(pos));