Ejemplo n.º 1
0
    //--------------------------------------------------------------------------------------------------

    public override bool Start()
    {
        _SourceBody = WorkspaceController.Selection.SelectedEntities.First() as Body;

        if (WorkspaceController.Selection.SelectedEntities.Count > 1)
        {
            var shapeOperands = WorkspaceController.Selection.SelectedEntities
                                .Skip(1)
                                .OfType <Body>()
                                .Select(body => (IShapeOperand) new BodyShapeOperand(body))
                                .ToArray();
            Execute(_SourceBody, shapeOperands);
            Stop();
            WorkspaceController.Invalidate();
            return(false);
        }
        else
        {
            var toolAction = new SelectEntityAction <Body>(this);
            toolAction.SetFilter(body => body.Shape?.ShapeType == ShapeType.Solid);
            if (!WorkspaceController.StartToolAction(toolAction))
            {
                return(false);
            }
            toolAction.Previewed += _OnActionPreview;
            toolAction.Finished  += _OnActionFinished;
            toolAction.Exclude(_SourceBody);

            UpdateStatusText(null);
            WorkspaceController.HudManager?.SetCursor(Cursors.SelectShape);
            return(true);
        }
    }
        //--------------------------------------------------------------------------------------------------

        bool _StartToolAction()
        {
            var toolAction = new SelectEntityAction <Body>(this);

            toolAction.SetFilter((body) => body.Shape.ShapeType == ShapeType.Sketch);
            if (!WorkspaceController.StartToolAction(toolAction))
            {
                return(false);
            }
            toolAction.Finished += _OnActionFinished;

            toolAction.Exclude(_TargetBody);

            return(true);
        }