public static Point[] AttachPoints(Rect rect)
 {
     return(new Point[]
     {
         DiagramHelpers.GetMiddlePoint(AttachDirection.Top, rect),
         DiagramHelpers.GetMiddlePoint(AttachDirection.Right, rect),
         DiagramHelpers.GetMiddlePoint(AttachDirection.Bottom, rect),
         DiagramHelpers.GetMiddlePoint(AttachDirection.Left, rect)
     });
 }
        /// <summary>
        /// Updates attach points belongig to this descriptor(which belongs to entityviewmodel)
        /// When call it?
        /// -Parent control size or location changed
        /// -Any attachment view size or location changed
        /// -On create(When parent view has size, when all attachnment have size
        /// </summary>
        public void UpdateAttachPoints()
        {
            if (parent.ParentDiagram == null)
            {
                return;
            }
            // update attach point ic called from external code in case of batch mode usage
            if (parent.ParentDiagram.IsInBatchMode)
            {
                return;
            }

            //  Console.WriteLine(parent.Name + "::UpdateAttachPoints");
            if (AttachPoints.All((kv) => kv.Value.Count == 0))
            {
                return;
            }


            //if (AttachPoints.Any(kv => kv.Value.Count(a => a.Control.Width == 0) > 0))
            //{
            //    return;
            //}

            UpdateAttachPointOrder();

            foreach (var directionPoints in AttachPoints)
            {
                var direction    = directionPoints.Key;
                var attachPoints = directionPoints.Value;


                if (attachPoints.Any(ap => ap.Width == 0))
                {
                }

                if (attachPoints.Count == 0)
                {
                    continue;
                }

                int    attachSpacing = 5;
                double groupWidth    = attachPoints.Sum(p => p.Width) + attachSpacing * (attachPoints.Count - 1);
                double groupHeight   = attachPoints.Sum(p => p.Height) + attachSpacing * (attachPoints.Count - 1);

                var middlePoint = GetPoint(direction, parent.Rect);

                double offsetX = middlePoint.X - (groupWidth / 2.0);
                double offsetY = middlePoint.Y - (groupHeight / 2.0);

                foreach (var attachPoint in attachPoints.OrderBy(a => a.Order))
                {
                    if (attachPoint.Width == 0)
                    {
                        if (attachPoint.Control != null)
                        {
                            Trace.TraceWarning("W: width of attach point is 0: {0}", attachPoint.Control.Name);
                        }
                        else
                        {
                            Trace.TraceWarning("W: no control associated with attach point");
                        }
                    }
                    if (direction == AttachDirection.Top || direction == AttachDirection.Bottom)
                    {
                        attachPoint.Location = new Point(offsetX + (attachPoint.Width / 2), middlePoint.Y);
                        offsetX += attachPoint.Width + attachSpacing;
                    }
                    else if (direction == AttachDirection.Left || direction == AttachDirection.Right)
                    {
                        attachPoint.Location = new Point(middlePoint.X, offsetY + (attachPoint.Height / 2));
                        offsetY += attachPoint.Height + attachSpacing;
                    }

                    if (attachPoint.Control != null)
                    {
                        attachPoint.ControlLocation = DiagramHelpers.GetAttachmentLocation(attachPoint.Control,
                                                                                           attachPoint.Location, attachPoint.Side);


                        attachPoint.Control.Location = attachPoint.ControlLocation;
                    }
                }
            }
        }