Пример #1
0
        private ContentZoomable(DiagramCanvas canvas)
        {
            _canvas = canvas;

            _canvas.MouseWheel += _canvas_MouseWheel;
            _canvas.MouseEnter += _canvas_MouseEnter;
        }
Пример #2
0
        /// <summary>
        /// Create adorner which will show dragged object.
        /// </summary>
        /// <param name="item">Dragged object.</param>
        /// <param name="dragStart">Drag start in mouse relative coordinates!!</param>
        public DragAdorner(DiagramItem item, Point dragStart)
            : base(item)
        {
            Item = item;

            _dragScope = item.DiagramContext.Provider.Output;

            _dragLayer = AdornerLayer.GetAdornerLayer(_dragScope);
            _dragLayer.Add(this);

            _hint = new MouseHint(_dragScope);


            _visualBrush         = new VisualBrush(item);
            _visualBrush.Opacity = 0.5;


            _startPosition = item.GlobalPosition;
            GlobalPosition = _startPosition;

            _center = getScaledPosition(dragStart) - _startPosition;



            IsHitTestVisible            = false;
            _dragScope.PreviewDragOver += _updatePosition;
        }
Пример #3
0
        private ContentShiftable(DiagramCanvas canvas)
        {
            _canvas = canvas;

            _canvas.MouseDown += canvas_MouseDown;
            _canvas.MouseUp   += _canvas_MouseUp;
        }
Пример #4
0
 public RubberbandAdorner(DiagramCanvas diagramCanvas, Point?dragStartPoint)
     : base(diagramCanvas)
 {
     this.diagramCanvas      = diagramCanvas;
     this.startPoint         = dragStartPoint;
     rubberbandPen           = new Pen(Brushes.LightSlateGray, 1);
     rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
 }
Пример #5
0
 public ConnectorAdorner(DiagramCanvas diagram, ConnectorViewModel sourceConnector)
     : base(diagram)
 {
     this.diagram         = diagram;
     this.sourceConnector = sourceConnector;
     drawingPen           = new Pen(Brushes.LightSlateGray, 1)
     {
         LineJoin = PenLineJoin.Round
     };
     Cursor = Cursors.Cross;
 }
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain"
            };
            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person, SelectedDomain = this.domain
            };

            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.modelsetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.diagram = new DiagramCanvas(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "diagram"
            };
            this.model.Iteration.Add(this.iteration);
            this.iteration.DiagramCanvas.Add(this.diagram);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
        }
Пример #7
0
        private void OnDragDelta(object sender, DragDeltaEventArgs e)
        {
            var block   = DataContext as BlockViewModel;
            var diagram = VisualTreeHelper.GetParent(block) as DiagramCanvas;

            if (block != null && diagram != null && block.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                // only move blocks
                var blocks = from element in diagram.SelectedElements
                             where element is BlockViewModel
                             select element;

                // Sets left and top position
                foreach (BlockViewModel element in blocks)
                {
                    var left = Canvas.GetLeft(element);
                    var top  = Canvas.GetTop(element);

                    minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
                    minTop  = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
                }

                // Calculate delta movement
                var deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                var deltaVertical   = Math.Max(-minTop, e.VerticalChange);

                // Set moved postion
                foreach (BlockViewModel element in blocks)
                {
                    var left = Canvas.GetLeft(element);
                    var top  = Canvas.GetTop(element);

                    if (double.IsNaN(left))
                    {
                        left = 0;
                    }
                    if (double.IsNaN(top))
                    {
                        top = 0;
                    }

                    element.BlockModel.Position = new Point(left + deltaHorizontal, top + deltaVertical);
                    DiagramCanvas.UpdatePosition(element);
                }

                diagram.InvalidateMeasure();
                e.Handled = true;
            }
        }
Пример #8
0
        private void OnModelChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Height")
            {
                Height = blockModel.Height;
            }
            if (e.PropertyName == "Width")
            {
                Width = blockModel.Width;
            }

            DiagramCanvas.UpdatePosition(this);
        }
        void DragControl_DragDelta(object sender, DragDeltaEventArgs e)
        {
            DiagramElement DiagramElement = this.DataContext as DiagramElement;
            DiagramCanvas  designer       = VisualTreeHelper.GetParent(DiagramElement) as DiagramCanvas;

            if (DiagramElement != null && designer != null && DiagramElement.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                // we only move DiagramElements
                var DiagramElements = designer.SelectionService.CurrentSelection.OfType <DiagramElement>();

                foreach (DiagramElement item in DiagramElements)
                {
                    double left = Canvas.GetLeft(item);
                    double top  = Canvas.GetTop(item);

                    minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
                    minTop  = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
                }

                double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                double deltaVertical   = Math.Max(-minTop, e.VerticalChange);

                foreach (DiagramElement item in DiagramElements)
                {
                    double left = Canvas.GetLeft(item);
                    double top  = Canvas.GetTop(item);

                    if (double.IsNaN(left))
                    {
                        left = 0;
                    }
                    if (double.IsNaN(top))
                    {
                        top = 0;
                    }

                    Canvas.SetLeft(item, left + deltaHorizontal);
                    Canvas.SetTop(item, top + deltaVertical);
                }

                designer.InvalidateMeasure();
                e.Handled = true;
            }
        }
Пример #10
0
        /// <summary>
        /// Serialize the <see cref="DiagramCanvas"/>
        /// </summary>
        /// <param name="diagramCanvas">The <see cref="DiagramCanvas"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(DiagramCanvas diagramCanvas)
        {
            var jsonObject = new JObject();

            jsonObject.Add("bounds", this.PropertySerializerMap["bounds"](diagramCanvas.Bounds));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), diagramCanvas.ClassKind)));
            jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](diagramCanvas.CreatedOn));
            jsonObject.Add("diagramElement", this.PropertySerializerMap["diagramElement"](diagramCanvas.DiagramElement.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](diagramCanvas.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](diagramCanvas.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](diagramCanvas.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](diagramCanvas.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](diagramCanvas.Name));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](diagramCanvas.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](diagramCanvas.ThingPreference));
            return(jsonObject);
        }
Пример #11
0
        private DiagramContext getContext()
        {
            if (_context == null)
            {
                var testCanvas = new DiagramCanvas();
                var diagramDef = new DiagramDefinition(null);
                foreach (var item in _items.Values)
                {
                    diagramDef.DrawItem(item);
                }

                var provider = new DrawingProvider(testCanvas, new TestDrawingFactory());
                _context = provider.Display(diagramDef);

                testCanvas.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
                testCanvas.Arrange(new Rect(new Point(), testCanvas.DesiredSize));
            }

            return(_context);
        }
Пример #12
0
        public ConnectionAdorner(DiagramCanvas diagram, ConnectionViewModel connection)
            : base(diagram)
        {
            this.diagram        = diagram;
            canvas              = new Canvas();
            this.visualChildren = new VisualCollection(this)
            {
                canvas
            };

            this.connection = connection;
            this.connection.PropertyChanged += new PropertyChangedEventHandler(AnchorPositionChanged);

            InitializeDragThumbs();

            drawingPen = new Pen(Brushes.LightSlateGray, 1)
            {
                LineJoin = PenLineJoin.Round
            };
        }
        public void VerifyThatCreateDiagramWorks()
        {
            var clone = this.iteration.Clone(false);

            this.transaction.CreateOrUpdate(clone);
            var diagram   = new DiagramCanvas();
            var viewmodel = new DiagramCanvasDialogViewModel(diagram, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.navigation.Object, clone, null);

            var nameCheck = viewmodel["Name"];

            Assert.IsFalse(viewmodel.OkCanExecute);

            viewmodel.Name = "test";

            nameCheck = viewmodel["Name"];
            Assert.IsTrue(viewmodel.OkCanExecute);

            var result = viewmodel.OkCommand.ExecuteAsync(null);

            Assert.AreNotEqual(default, diagram.CreatedOn);
        public void VerifyThatDiagramRowsAreUpdated()
        {
            var viewmodel = new DiagramBrowserViewModel(this.iteration, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, null);

            var newdiagram = new DiagramCanvas(Guid.NewGuid(), null, this.uri);

            this.iteration.DiagramCanvas.Add(newdiagram);

            var revision = typeof(Iteration).GetProperty("RevisionNumber");

            revision.SetValue(this.iteration, 2);

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated);
            Assert.AreEqual(2, viewmodel.Diagrams.Count);

            this.iteration.DiagramCanvas.Clear();
            revision.SetValue(this.iteration, 3);

            CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated);
            Assert.AreEqual(0, viewmodel.Diagrams.Count);
        }
        private FrameworkElement CreateDiagramElement(string diagram,
                                                      Size areaExtent,
                                                      Point origin,
                                                      Rect area,
                                                      bool fixedStrokeThickness,
                                                      ResourceDictionary resources,
                                                      DiagramTable table)
        {
            var grid = new Grid()
            {
                ClipToBounds = true,
                Resources    = resources
            };

            var template = new Control()
            {
                Template = grid.Resources[ResourceConstants.KeyLandscapePageTemplate] as ControlTemplate
            };

            var canvas = new DiagramCanvas()
            {
                Width  = PageWidth,
                Height = PageHeight
            };

            ModelEditor.Parse(diagram,
                              canvas, this.DiagramCreator,
                              0, 0,
                              false, false, false, true);

            grid.Children.Add(template);
            grid.Children.Add(canvas);

            LineEx.SetShortenStart(grid, ShortenStart);
            LineEx.SetShortenEnd(grid, ShortenEnd);

            TableGrid.SetData(grid, table);

            return(grid);
        }
 /// <summary>
 /// Add an Diagram Canvas row view model to the list of <see cref="DiagramCanvas"/>
 /// </summary>
 /// <param name="diagramCanvas">
 /// The <see cref="DiagramCanvas"/> that is to be added
 /// </param>
 private DiagramCanvasRowViewModel AddDiagramCanvasRowViewModel(DiagramCanvas diagramCanvas)
 {
     return(new DiagramCanvasRowViewModel(diagramCanvas, this.Session, this));
 }
Пример #17
0
 internal static void Attach(DiagramCanvas canvas)
 {
     new ContentShiftable(canvas);
 }
Пример #18
0
        public void Setup()
        {
            this.session                     = new Mock <ISession>();
            this.assembler                   = new Assembler(this.uri);
            this.permissionService           = new Mock <IPermissionService>();
            this.mockExtendedDiagramBehavior = new Mock <IExtendedDiagramOrgChartBehavior>();
            this.mockDiagramBehavior         = new Mock <ICdp4DiagramOrgChartBehavior>(MockBehavior.Strict);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.pluginSettingsService        = new Mock <IPluginSettingsService>();
            this.dropinfo = new Mock <IDiagramDropInfo>();
            this.cache    = this.assembler.Cache;

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.srdl       = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain"
            };

            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person         = this.person,
                SelectedDomain = this.domain
            };

            this.diagram = new DiagramCanvas(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.modelsetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.iteration.DiagramCanvas.Add(this.diagram);
            this.model.Iteration.Add(this.iteration);

            this.specCat         = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.relationshipCat = new Category(Guid.NewGuid(), this.cache, this.uri);

            this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.spec3 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);

            this.link1 = new BinaryRelationship(Guid.NewGuid(), this.cache, this.uri)
            {
                Source = this.spec1,
                Target = this.spec2
            };

            this.link1.Category.Add(this.relationshipCat);
            this.spec1.Category.Add(this.specCat);
            this.spec2.Category.Add(this.specCat);
            this.spec3.Category.Add(this.specCat);

            this.srdl.DefinedCategory.Add(this.specCat);
            this.srdl.DefinedCategory.Add(this.relationshipCat);

            this.iteration.RequirementsSpecification.Add(this.spec1);
            this.iteration.RequirementsSpecification.Add(this.spec2);
            this.iteration.RequirementsSpecification.Add(this.spec3);
            this.iteration.Relationship.Add(this.link1);


            var tuple = new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant);

            var openedIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                {
                    this.iteration, tuple
                }
            };

            this.diagramObject1 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec1
            };
            this.diagramObject2 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec2
            };
            this.diagramObject3 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec3
            };

            this.connector = new DiagramEdge(Guid.NewGuid(), this.cache, this.uri)
            {
                Source        = this.diagramObject1,
                Target        = this.diagramObject2,
                DepictedThing = this.link1
            };
            this.elementDefinition = new ElementDefinition()
            {
                Name = "WhyNot", ShortName = "WhyNot"
            };
            this.bound1 = new Bounds(Guid.NewGuid(), this.cache, this.uri)
            {
                X      = 1,
                Y      = 1,
                Height = 12,
                Width  = 10
            };

            this.bound2 = new Bounds(Guid.NewGuid(), this.cache, this.uri)
            {
                X      = 1,
                Y      = 1,
                Height = 12,
                Width  = 10
            };

            this.diagramObject1.Bounds.Add(this.bound1);
            this.diagramObject2.Bounds.Add(this.bound2);

            this.diagram.DiagramElement.Add(this.diagramObject1);
            this.diagram.DiagramElement.Add(this.diagramObject2);
            this.diagram.DiagramElement.Add(this.connector);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(openedIterations);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.mockExtendedDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point());
            this.mockDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point());
            this.mockDiagramBehavior.Setup(x => x.ItemPositions).Returns(new Dictionary <object, Point>());
            this.mockDiagramBehavior.Setup(x => x.ApplyChildLayout(It.IsAny <DiagramItem>()));

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
        }
Пример #19
0
 private void RemoveModel(object sender, BlockViewModel model)
 {
     DiagramCanvas.Remove(model);
 }
Пример #20
0
 private void AddModel(object sender, BlockViewModel model)
 {
     DiagramCanvas.Add(model);
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagramCanvasDialogViewModel"/> class.
 /// </summary>
 /// <param name="diagram">
 /// The <see cref="DiagramCanvas"/> that is the subject of the current view-model. This is the object
 /// that will be either created, or edited.
 /// </param>
 /// <param name="transaction">
 /// The <see cref="ThingTransaction"/> that contains the log of recorded changes.
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated
 /// </param>
 /// <param name="isRoot">
 /// Assert if this <see cref="DiagramCanvasDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/>
 /// </param>
 /// <param name="dialogKind">
 /// The kind of operation this <see cref="DiagramCanvasDialogViewModel"/> performs
 /// </param>
 /// <param name="thingDialogNavigationService">
 /// The <see cref="IThingDialogNavigationService"/>
 /// </param>
 /// <param name="container">
 /// The Container <see cref="Thing"/> of the created <see cref="Thing"/>
 /// </param>
 /// <param name="chainOfContainers">
 /// The optional chain of containers that contains the <paramref name="container"/> argument
 /// </param>
 public DiagramCanvasDialogViewModel(DiagramCanvas diagram, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null)
     : base(diagram, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
 }
        /// <summary>
        /// Persist the <see cref="DiagramCanvas"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="diagramCanvas">
        /// The <see cref="DiagramCanvas"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, DiagramCanvas diagramCanvas)
        {
            var results = new List <bool>();

            foreach (var bounds in this.ResolveFromRequestCache(diagramCanvas.Bounds))
            {
                results.Add(this.BoundsService.UpsertConcept(transaction, partition, bounds, diagramCanvas));
            }

            foreach (var diagramElement in this.ResolveFromRequestCache(diagramCanvas.DiagramElement))
            {
                results.Add(this.DiagramElementService.UpsertConcept(transaction, partition, diagramElement, diagramCanvas));
            }

            return(results.All(x => x));
        }
Пример #23
0
        void ResizeControl_DragDelta(object sender, DragDeltaEventArgs e)
        {
            DiagramElement DiagramElement = this.DataContext as DiagramElement;
            DiagramCanvas  designer       = VisualTreeHelper.GetParent(DiagramElement) as DiagramCanvas;

            if (DiagramElement != null && designer != null && DiagramElement.IsSelected)
            {
                double minLeft, minTop, minDeltaHorizontal, minDeltaVertical;
                double dragDeltaVertical, dragDeltaHorizontal, scale;

                IEnumerable <DiagramElement> selectedDiagramElements = designer.SelectionService.CurrentSelection.OfType <DiagramElement>();

                CalculateDragLimits(selectedDiagramElements, out minLeft, out minTop,
                                    out minDeltaHorizontal, out minDeltaVertical);

                foreach (DiagramElement item in selectedDiagramElements)
                {
                    if (item != null && item.ParentID == Guid.Empty)
                    {
                        switch (base.VerticalAlignment)
                        {
                        case VerticalAlignment.Bottom:
                            dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
                            scale             = (item.ActualHeight - dragDeltaVertical) / item.ActualHeight;
                            DragBottom(scale, item, designer.SelectionService);
                            break;

                        case VerticalAlignment.Top:
                            double top = Canvas.GetTop(item);
                            dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
                            scale             = (item.ActualHeight - dragDeltaVertical) / item.ActualHeight;
                            DragTop(scale, item, designer.SelectionService);
                            break;

                        default:
                            break;
                        }

                        switch (base.HorizontalAlignment)
                        {
                        case HorizontalAlignment.Left:
                            double left = Canvas.GetLeft(item);
                            dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
                            scale = (item.ActualWidth - dragDeltaHorizontal) / item.ActualWidth;
                            DragLeft(scale, item, designer.SelectionService);
                            break;

                        case HorizontalAlignment.Right:
                            dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
                            scale = (item.ActualWidth - dragDeltaHorizontal) / item.ActualWidth;
                            DragRight(scale, item, designer.SelectionService);
                            break;

                        default:
                            break;
                        }
                    }
                }
                e.Handled = true;
            }
        }