CustomMoveResizeTool.cs 915 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Linq;
  2. using SHJX.Service.WorkFlowEdit;
  3. namespace Flowchart
  4. {
  5. class CustomMoveResizeTool : MoveResizeTool
  6. {
  7. private FlowchartModel _model;
  8. public CustomMoveResizeTool(DiagramView view, FlowchartModel model) : base(view)
  9. {
  10. _model = model;
  11. }
  12. public override bool CanDrop()
  13. {
  14. foreach (var item in DragItems)
  15. {
  16. var column = (int)(item.Bounds.X / View.GridCellSize.Width);
  17. var row = (int)(item.Bounds.Y / View.GridCellSize.Height);
  18. if (_model.Nodes.Where(p => !IsDragged(p) && p.Row == row && p.Column == column).Count() != 0)
  19. return false;
  20. }
  21. return true;
  22. }
  23. private bool IsDragged(FlowNode node)
  24. {
  25. return DragItems.Where(p => p.ModelElement == node).Count() > 0;
  26. }
  27. }
  28. }