示例#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));