CustomMoveResizeTool.cs 935 B

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