private void OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (movingPokemon)
            {
                Point ptCursor = new Point();
                if (hoverIndex != -1)
                {
                    if (IsViewingParty)
                    {
                        ptCursor = partyClickAreas[hoverIndex].TranslatePoint(new Point(16, 9), adornerContainer);
                    }
                    else
                    {
                        ptCursor = boxClickAreas[hoverIndex].TranslatePoint(new Point(12, 8), adornerContainer);
                    }
                }
                else
                {
                    ptCursor = MouseUtilities.GetMousePosition(adornerContainer);
                }


                double left = ptCursor.X - 16;
                double top  = ptCursor.Y - 24;

                this.pickupDragAdorner.SetOffsets(left, top);
            }
        }
Exemple #2
0
        private void myRelationshipTree_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var dragAction = DragDropEffects.None;

            if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None)
            {
                dragAction = DragDropEffects.Move;
            }
            else if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None)
            {
                dragAction = DragDropEffects.Copy;
            }

            if (dragAction == DragDropEffects.None)
            {
                return;
            }

            var draggedItem = myTree.GetItemAtLocation <TreeViewItem>(MouseUtilities.GetMousePosition(myTree));

            if (draggedItem == null)
            {
                return;
            }

            var dragInfo = new TreeDragInfo(draggedItem);

            dragInfo.Action = dragAction;

            DragDrop.DoDragDrop(myTree, dragInfo.ToDataObject(), dragInfo.Action);
            e.Handled = true;
        }
        private void TickDragScroll(object sender, EventArgs e)
        {
            bool isDone = true;

            if (this.IsLoaded)
            {
                Rect  bounds = new Rect(RenderSize);
                Point p      = MouseUtilities.GetMousePosition(this);
                if (bounds.Contains(p))
                {
                    if (p.Y < DRAG_MARGIN)
                    {
                        DragScroll(DragDirection.Up);
                        isDone = false;
                    }
                    else if (p.Y > RenderSize.Height - DRAG_MARGIN)
                    {
                        DragScroll(DragDirection.Down);
                        isDone = false;
                    }
                }
            }

            if (isDone)
            {
                CancelDrag();
            }
        }
Exemple #4
0
        protected override void OnQueryContinueDrag(QueryContinueDragEventArgs e)
        {
            base.OnQueryContinueDrag(e);

            if (e.Action == DragAction.Cancel || e.Action == DragAction.Drop)
            {
                StopAutoScrolling();
            }
            else if (e.Action == DragAction.Continue)
            {
                Point  pt     = MouseUtilities.GetMousePosition(this);
                double height = this.RenderSize.Height;
                if (pt.Y < AutoScrollMargin)
                {
                    // start scrolling scroll up
                    StartAutoScrolling(pt.Y - AutoScrollMargin);
                }
                else if (pt.Y > height - AutoScrollMargin)
                {
                    // start scrolling scroll down.
                    StartAutoScrolling(pt.Y - (height - AutoScrollMargin));
                }
                else
                {
                    // stop autoscrolling.
                    StopAutoScrolling();
                }
            }
        }
Exemple #5
0
        void listView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.IsMouseOverScrollbar)
            {
                // 4/13/2007 - Set the flag to false when cursor is over scrollbar.
                this.canInitiateDrag = false;
                return;
            }

            int index = this.IndexUnderDragCursor;

            this.canInitiateDrag = index > -1;

            if (this.canInitiateDrag)
            {
                // Remember the location and index of the ListViewItem the user clicked on for later.
                this.ptMouseDown   = MouseUtilities.GetMousePosition(this.listView);
                this.indexToSelect = index;
            }
            else
            {
                this.ptMouseDown   = new Point(-10000, -10000);
                this.indexToSelect = -1;
            }
        }
        bool IsMouseOver(Visual target)
        {
            Rect  bounds   = VisualTreeHelper.GetDescendantBounds(target);
            Point mousePos = MouseUtilities.GetMousePosition(target);

            return(bounds.Contains(mousePos));
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method executes the new command.</summary>
        ///
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        ///--------------------------------------------------------------------------------
        private void NewExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            DiagramViewModel view = DataContext as DiagramViewModel;

            if (view != null)
            {
                Point currentPosition = MouseUtilities.GetMousePosition(this);
                dialog         = new Window();
                dialog.Height  = 350 * UserSettingsHelper.Instance.ControlSize;
                dialog.Width   = 300 * UserSettingsHelper.Instance.ControlSize;
                dialog.Left    = Math.Max(currentPosition.X, 20);
                dialog.Top     = Math.Max(currentPosition.Y, 20);
                dialog.Content = new EntityDialogControl();
                Entity newEntity = new Entity();
                newEntity.EntityID = Guid.NewGuid();
                newEntity.Solution = view.Solution;
                EntityViewModel newEntityView = new EntityViewModel(newEntity, view.Solution);
                dialog.DataContext          = newEntityView;
                dialog.Title                = newEntityView.Title;
                newEntityView.RequestClose += new EventHandler(newEntityView_RequestClose);

                dialog.ShowDialog();
                if (newEntityView.IsOK == true)
                {
                    // TODO: investigate why this workflow needs to be different than other elements in the model
                    newEntityView.Entity.TransformDataFromObject(newEntityView.EditEntity, null, false);
                    newEntityView.EditEntity = null;
                    view.AddEntity(newEntityView, currentPosition, true);
                }
            }
        }
Exemple #8
0
 protected override void OnGiveFeedback(GiveFeedbackEventArgs e)
 {
     base.OnGiveFeedback(e);
     if (CurrentAdorner != null)
     {
         CurrentAdorner.DrawArc(MouseUtilities.GetMousePosition(ParentCanvas));
     }
 }
Exemple #9
0
        bool IsMouseOver(Visual target)
        {
            // We need to use MouseUtilities to figure out the cursor
            // coordinates because, during a drag-drop operation, the WPF
            // mechanisms for getting the coordinates behave strangely.

            Rect  bounds   = VisualTreeHelper.GetDescendantBounds(target);
            Point mousePos = MouseUtilities.GetMousePosition(target);

            return(bounds.Contains(mousePos));
        }
        AdornerLayer InitializeAdornerLayer(ListViewItem itemToDrag)
        {
            VisualBrush brush = new VisualBrush(itemToDrag);

            this.dragAdorner         = new DragAdorner(this.listView, itemToDrag.RenderSize, brush);
            this.dragAdorner.Opacity = this.DragAdornerOpacity;
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this.listView);

            layer.Add(dragAdorner);
            this.ptMouseDown = MouseUtilities.GetMousePosition(this.listView);

            return(layer);
        }
        void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);

                double       left             = ptCursor.X - this.ptMouseDown.X;
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                double       top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;

                this.dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #12
0
        private void UpdateDragAdornerLocation()
        {
            if (dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(ListView);

                double left = ptCursor.X - ptMouseDown.X;

                // The top offset is relative to the item being dragged.
                ListViewItem itemBeingDragged = GetListViewItem(indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), ListView);
                double       top = itemLoc.Y + ptCursor.Y - ptMouseDown.Y;

                dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #13
0
        private void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);

                //double left = ptCursor.X - this.ptMouseDown.X;
                double left = ptCursor.X - 18; // borderÀÇ Àý¹Ý // wheo

                // 4/13/2007 - Made the top offset relative to the item being dragged.
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                double       top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;

                this.dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #14
0
        public void ChildrenRemoveAndCloseIfNeed(Popup child)
        {
            var pc = child.Tag as PopupContainer;

            if (pc != null)
            {
                if (pc.IsChildrenExists)
                {
                    return;
                }
            }

            Children.Remove(child);
            if (Children.Count != 0)
            {
                return;
            }

            var visual = Popup.Child as FrameworkElement;

            if (visual == null)
            {
                return;
            }

            var mousePnt = MouseUtilities.GetMousePosition(visual);

            if (!(visual.ActualWidth <= (mousePnt.X + 2)) && !(visual.ActualHeight <= (mousePnt.Y + 2)) && !(mousePnt.X < 2) && !(mousePnt.Y < 2))
            {
                return;
            }

            Popup.IsOpen = false;
            Popup removed;

            _openedPopups.TryRemove(PopupBase, out removed);

            if (Parent != null)
            {
                pc = Parent.Tag as PopupContainer;
                if (pc != null)
                {
                    pc.ChildrenRemoveAndCloseIfNeed(Popup);
                }
            }
        }
Exemple #15
0
        private void myRelationshipTree_Drop(object sender, DragEventArgs e)
        {
            var dragInfo    = (EntityDragInfo)e.Data.GetData(EntityDragInfo.DataFormat);
            var draggedItem = dragInfo.Entity;
            var dragTarget  = myTree.GetDataContextAtLocation <object>(MouseUtilities.GetMousePosition(myTree));

            if (dragInfo.Action == DragDropEffects.Move)
            {
                var treeDragInfo = dragInfo as TreeDragInfo;
                var oldGroup     = treeDragInfo == null ? null : GetGroupEntity(treeDragInfo.Item);
                TryAction(() => myController.MoveElementToGroup(dragTarget, draggedItem, oldGroup));
            }
            else if (dragInfo.Action == DragDropEffects.Copy)
            {
                TryAction(() => myController.AddElemntToGroup(dragTarget, draggedItem));
            }

            e.Handled = true;
        }
        public void HandleCustomDrop()
        {
            // handle "drop" of relationship in custom drag/drop approach with arc drawing adorner
            if (DragItem is DiagramRelationshipViewModel)
            {
                DiagramViewModel             diagramView       = DataContext as DiagramViewModel;
                DiagramEntityViewModel       diagramEntityView = GetMouseOverEntity();
                DiagramRelationshipViewModel dragRelationship  = DragItem as DiagramRelationshipViewModel;
                Point currentPosition = MouseUtilities.GetMousePosition(this);
                if (dragRelationship != null && diagramEntityView != null)
                {
                    dragRelationship.SinkDiagramEntityViewModel = diagramEntityView;
                    dragRelationship.Diagram = diagramView;
                    dialog         = new Window();
                    dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Width   = 650 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Left    = Math.Max(currentPosition.X, 20);
                    dialog.Top     = Math.Max(currentPosition.Y, 20);
                    dialog.Content = new RelationshipDialogControl();
                    Relationship newRelationship = new Relationship();
                    newRelationship.RelationshipID   = Guid.NewGuid();
                    newRelationship.Solution         = dragRelationship.Solution;
                    newRelationship.ReferencedEntity = dragRelationship.SinkDiagramEntityViewModel.DiagramEntity.Entity;
                    newRelationship.Entity           = dragRelationship.SourceDiagramEntityViewModel.DiagramEntity.Entity;
                    RelationshipViewModel newRelationshipView = new RelationshipViewModel(newRelationship, dragRelationship.Solution);
                    dialog.DataContext = newRelationshipView;
                    dialog.Title       = newRelationshipView.Title;
                    newRelationshipView.RequestClose += new EventHandler(Item_RequestClose);

                    dialog.ShowDialog();
                    if (newRelationshipView.IsOK == true)
                    {
                        dragRelationship.RelationshipViewModel = newRelationshipView;
                        diagramView.CreateRelationship(dragRelationship);
                    }
                    dialog.Close();
                    dialog = null;
                }
            }
            IsDragging = false;
            DragItem   = null;
        }
Exemple #17
0
        private void OnLeavePopupTimerCallback(object sender, EventArgs e)
        {
            _leavePopupTimer.Stop();

            var mousePnt = MouseUtilities.GetMousePosition(this);

            if (PopupBaseRect.Contains(mousePnt))
            {
                return;
            }

            Popup popup;

            if (!opened_popups.TryGetValue(this, out popup) || popup == null || popup.IsMouseOver)
            {
                return;
            }

            closeAllPopups(popup);
        }
        void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);

                double left = ptCursor.X - this.ptMouseDown.X;

                // 4/13/2007 - Made the top offset relative to the item being dragged.
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                if (beginDragLoc == new Point(-10000, -10000))
                {
                    beginDragLoc = itemLoc;
                }
                double top = itemLoc.Y + (beginDragLoc.Y - itemLoc.Y) + (ptCursor.Y - this.ptMouseDown.Y);

                this.dragAdorner.SetOffsets(left, top);
            }
        }
        DiagramEntityViewModel GetMouseOverEntity()
        {
            Point            currentPosition = MouseUtilities.GetMousePosition(this);
            DiagramViewModel diagramView     = DataContext as DiagramViewModel;

            foreach (DiagramEntityViewModel entity in diagramView.Items.OfType <DiagramEntityViewModel>())
            {
                EntityDiagramControl entityControl = VisualItemHelper.FindChild <EntityDiagramControl>(this, entity);
                if (entityControl != null)
                {
                    if (entity.X < currentPosition.X &&
                        currentPosition.X < (entity.X + entityControl.ActualWidth) &&
                        entity.Y < currentPosition.Y &&
                        currentPosition.Y < (entity.Y + entityControl.ActualHeight))
                    {
                        return(entity);
                    }
                }
            }
            return(null);
        }
        AdornerLayer InitializeAdornerLayer(ListViewItem itemToDrag)
        {
            // Create a brush which will paint the ListViewItem onto
            // a visual in the adorner layer.
            VisualBrush brush = new VisualBrush(itemToDrag);

            // Create an element which displays the source item while it is dragged.
            this.dragAdorner = new DragAdorner(this.listView, itemToDrag.RenderSize, brush);

            // Set the drag adorner's opacity.
            this.dragAdorner.Opacity = this.DragAdornerOpacity;

            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this.listView);

            layer.Add(dragAdorner);

            // Save the location of the cursor when the left mouse button was pressed.
            this.ptMouseDown = MouseUtilities.GetMousePosition(this.listView);

            return(layer);
        }
Exemple #21
0
        void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point        ptCursor        = MouseUtilities.GetMousePosition(this.ListView);
                Border       border          = (Border)VisualTreeHelper.GetChild(listView, 0);
                ScrollViewer scrollViewer    = VisualTreeHelper.GetChild(border, 0) as ScrollViewer;
                Point        ptScrollCurrent = new Point(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset);
                Point        p = ptScrollStart;
                p.Offset(-scrollViewer.HorizontalOffset, -scrollViewer.VerticalOffset);
                //ptScrollStart =

                double left = ptCursor.X - this.ptMouseDown.X;

                // 4/13/2007 - Made the top offset relative to the item being dragged.
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                double       top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;

                this.dragAdorner.SetOffsets(left - p.X * GetListViewItem(indexToSelect).ActualWidth, top - p.Y * GetListViewItem(indexToSelect).ActualHeight);
            }
        }
Exemple #22
0
        private void myRelationshipTree_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                var dragTarget  = myTree.GetDataContextAtLocation <object>(MouseUtilities.GetMousePosition(myTree));
                var dragInfo    = (EntityDragInfo)e.Data.GetData(EntityDragInfo.DataFormat);
                var draggedItem = dragInfo.Entity;

                if (myController.IsGroupingAllowed(draggedItem, dragTarget))
                {
                    e.Effects = dragInfo.Action;
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }
            }
            finally
            {
                e.Handled = true;
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method handles the execution of the new command.</summary>
        ///
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        ///--------------------------------------------------------------------------------
        private void NewExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Point currentPosition                    = MouseUtilities.GetMousePosition(this);
            PropertiesViewModel    items             = DataContext as PropertiesViewModel;
            EntityDiagramControl   diagram           = VisualItemHelper.VisualUpwardSearch <EntityDiagramControl>(this) as EntityDiagramControl;
            DiagramEntityViewModel diagramEntityView = diagram.DataContext as DiagramEntityViewModel;

            if (items != null && diagramEntityView != null)
            {
                dialog         = new Window();
                dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                dialog.Width   = 400 * UserSettingsHelper.Instance.ControlSize;
                dialog.Left    = Math.Max(currentPosition.X, 20);
                dialog.Top     = Math.Max(currentPosition.Y, 20);
                dialog.Content = new PropertyDialogControl();
                Property newItem = new Property();
                newItem.PropertyID = Guid.NewGuid();
                newItem.Solution   = items.Solution;
                newItem.Entity     = items.Entity;
                //newItem.ReferenceEntity = diagramEntityView.DiagramEntity.Entity;
                PropertyViewModel newItemView = new PropertyViewModel(newItem, items.Solution);
                newItemView.IsFreeDialog  = true;
                dialog.DataContext        = newItemView;
                dialog.Title              = newItemView.Title;
                newItemView.RequestClose += new EventHandler(Item_RequestClose);
                #region protected
                dialog.Width = 600 * UserSettingsHelper.Instance.ControlSize;
                #endregion protected
                dialog.ShowDialog();
                if (newItemView.IsOK == true)
                {
                    items.AddProperty(newItemView);
                }
                dialog.Close();
                dialog    = null;
                e.Handled = true;
                return;
            }
        }
        void listView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.IsMouseOverScrollbar)
            {
                this.canInitiateDrag = false;
                return;
            }

            int index = this.IndexUnderDragCursor;

            this.canInitiateDrag = index > -1;

            if (this.canInitiateDrag)
            {
                this.ptMouseDown   = MouseUtilities.GetMousePosition(this.listView);
                this.indexToSelect = index;
            }
            else
            {
                this.ptMouseDown   = new Point(-10000, -10000);
                this.indexToSelect = -1;
            }
        }
Exemple #25
0
        private AdornerLayer InitializeAdornerLayer(ListViewItem itemToDrag)
        {
            // Create a brush which will paint the ListViewItem onto
            // a visual in the adorner layer.
            var brush = new VisualBrush(itemToDrag);

            // Create an element which displays the source item while it is dragged.
// ReSharper disable UseObjectOrCollectionInitializer
            dragAdorner = new DragAdorner(listView, itemToDrag.RenderSize, brush);
// ReSharper restore UseObjectOrCollectionInitializer

            // Set the drag adorner's opacity.
            dragAdorner.Opacity = DragAdornerOpacity;

            AdornerLayer layer = AdornerLayer.GetAdornerLayer(listView);

            layer.Add(dragAdorner);

            // Save the location of the cursor when the left mouse button was pressed.
            ptMouseDown = MouseUtilities.GetMousePosition(listView);

            return(layer);
        }
Exemple #26
0
        private void OnLeavePopupFromPopupTimerCallback(object sender, EventArgs e)
        {
            _leavePopupFromPopupTimer.Stop();

            var parent = _leavePopupFromPopupTimer.Tag as Popup;

            if (parent == null)
            {
                return;
            }

            var popup = parent.Child as FrameworkElement;

            if (popup == null)
            {
                return;
            }

            var pc     = parent.Tag as PopupContainer;
            var bounds = pc == null || pc.PopupRect == Rect.Empty ? VisualTreeHelper.GetDescendantBounds(popup) : pc.PopupRect;

            var mousePnt = MouseUtilities.GetMousePosition(popup);

            if (bounds.Contains(mousePnt))
            {
                return;
            }

            mousePnt = MouseUtilities.GetMousePosition(this);
            if (PopupBaseRect.Contains(mousePnt))
            {
                return;
            }

            closeAllPopups(parent);
        }
        protected override void OnPreviewQueryContinueDrag(QueryContinueDragEventArgs args)
        {
            base.OnPreviewQueryContinueDrag(args);

            if (args.Action == DragAction.Cancel || args.Action == DragAction.Drop)
            {
                CancelDrag();
            }
            else if (args.Action == DragAction.Continue)
            {
                Point p = MouseUtilities.GetMousePosition(this);
                if ((p.Y < DRAG_MARGIN) || (p.Y > RenderSize.Height - DRAG_MARGIN))
                {
                    if (_dragScrollTimer == null)
                    {
                        _dragVelocity             = DRAG_INITIAL_VELOCITY;
                        _dragScrollTimer          = new DispatcherTimer();
                        _dragScrollTimer.Tick    += TickDragScroll;
                        _dragScrollTimer.Interval = new TimeSpan(0, 0, 0, 0, (int)DRAG_INTERVAL);
                        _dragScrollTimer.Start();
                    }
                }
            }
        }
Exemple #28
0
        private void listView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (IsMouseOverScrollbar)
            {
                canInitiateDrag = false;
                return;
            }

            int index = IndexUnderDragCursor;

            canInitiateDrag = index > -1;

            if (canInitiateDrag)
            {
                // Remember the location and index of the ListViewItem the user clicked on for later.
                ptMouseDown   = MouseUtilities.GetMousePosition(listView);
                indexToSelect = index;
            }
            else
            {
                ptMouseDown   = new Point(-10000, -10000);
                indexToSelect = -1;
            }
        }
Exemple #29
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);

            Point                  currentPosition   = MouseUtilities.GetMousePosition(this);
            DiagramViewModel       diagramView       = ParentCanvas.DataContext as DiagramViewModel;
            DiagramEntityViewModel diagramEntityView = DataContext as DiagramEntityViewModel;

            if (diagramView != null && diagramEntityView != null)
            {
                // try drop as diagram relationship
                DiagramRelationshipViewModel dragRelationship = e.Data.GetData(typeof(DiagramRelationshipViewModel)) as DiagramRelationshipViewModel;
                if (dragRelationship != null)
                {
                    dragRelationship.SinkDiagramEntityViewModel = diagramEntityView;
                    dragRelationship.Diagram = diagramView;
                    dialog         = new Window();
                    dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Width   = 650 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Left    = Math.Max(currentPosition.X, 20);
                    dialog.Top     = Math.Max(currentPosition.Y, 20);
                    dialog.Content = new RelationshipDialogControl();
                    Relationship newRelationship = new Relationship();
                    newRelationship.RelationshipID   = Guid.NewGuid();
                    newRelationship.Solution         = dragRelationship.Solution;
                    newRelationship.ReferencedEntity = dragRelationship.SinkDiagramEntityViewModel.DiagramEntity.Entity;
                    newRelationship.Entity           = dragRelationship.SourceDiagramEntityViewModel.DiagramEntity.Entity;
                    RelationshipViewModel newRelationshipView = new RelationshipViewModel(newRelationship, dragRelationship.Solution);
                    dialog.DataContext = newRelationshipView;
                    dialog.Title       = newRelationshipView.Title;
                    newRelationshipView.RequestClose += new EventHandler(Item_RequestClose);

                    dialog.ShowDialog();
                    if (newRelationshipView.IsOK == true)
                    {
                        dragRelationship.RelationshipViewModel = newRelationshipView;
                        diagramView.CreateRelationship(dragRelationship);
                    }
                    dialog.Close();
                    dialog    = null;
                    e.Handled = true;
                    return;
                }

                // try drop as collection
                CollectionsViewModel dragCollections = e.Data.GetData(typeof(CollectionsViewModel)) as CollectionsViewModel;
                if (dragCollections != null)
                {
                    dialog         = new Window();
                    dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Width   = 400 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Left    = Math.Max(currentPosition.X, 20);
                    dialog.Top     = Math.Max(currentPosition.Y, 20);
                    dialog.Content = new CollectionDialogControl();
                    Collection newProperty = new Collection();
                    newProperty.PropertyID       = Guid.NewGuid();
                    newProperty.Solution         = dragCollections.Solution;
                    newProperty.Entity           = dragCollections.Entity;
                    newProperty.ReferencedEntity = diagramEntityView.DiagramEntity.Entity;
                    CollectionViewModel newPropertyView = new CollectionViewModel(newProperty, dragCollections.Solution);
                    dialog.DataContext            = newPropertyView;
                    dialog.Title                  = newPropertyView.Title;
                    newPropertyView.RequestClose += new EventHandler(Item_RequestClose);

                    dialog.ShowDialog();
                    if (newPropertyView.IsOK == true)
                    {
                        dragCollections.AddCollection(newPropertyView);
                    }
                    dialog.Close();
                    dialog    = null;
                    e.Handled = true;
                    return;
                }

                // try drop as property reference
                PropertyReferencesViewModel dragPropertyReferences = e.Data.GetData(typeof(PropertyReferencesViewModel)) as PropertyReferencesViewModel;
                if (dragPropertyReferences != null)
                {
                    dialog         = new Window();
                    dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Width   = 400 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Left    = Math.Max(currentPosition.X, 20);
                    dialog.Top     = Math.Max(currentPosition.Y, 20);
                    dialog.Content = new PropertyReferenceDialogControl();
                    PropertyReference newProperty = new PropertyReference();
                    newProperty.PropertyID = Guid.NewGuid();
                    newProperty.Solution   = dragPropertyReferences.Solution;
                    newProperty.Entity     = dragPropertyReferences.Entity;
                    PropertyReferenceViewModel newPropertyView = new PropertyReferenceViewModel(newProperty, dragPropertyReferences.Solution);
                    newPropertyView.ReferencedEntityID = diagramEntityView.EntityViewModel.EntityID;
                    newPropertyView.RefreshProperties();
                    dialog.DataContext            = newPropertyView;
                    dialog.Title                  = newPropertyView.Title;
                    newPropertyView.RequestClose += new EventHandler(Item_RequestClose);

                    dialog.ShowDialog();
                    if (newPropertyView.IsOK == true)
                    {
                        dragPropertyReferences.AddPropertyReference(newPropertyView);
                    }
                    dialog.Close();
                    dialog    = null;
                    e.Handled = true;
                    return;
                }

                // try drop as entity reference
                EntityReferencesViewModel dragEntityReferences = e.Data.GetData(typeof(EntityReferencesViewModel)) as EntityReferencesViewModel;
                if (dragEntityReferences != null)
                {
                    dialog         = new Window();
                    dialog.Height  = 450 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Width   = 400 * UserSettingsHelper.Instance.ControlSize;
                    dialog.Left    = Math.Max(currentPosition.X, 20);
                    dialog.Top     = Math.Max(currentPosition.Y, 20);
                    dialog.Content = new EntityReferenceDialogControl();
                    EntityReference newProperty = new EntityReference();
                    newProperty.PropertyID       = Guid.NewGuid();
                    newProperty.Solution         = dragEntityReferences.Solution;
                    newProperty.Entity           = dragEntityReferences.Entity;
                    newProperty.ReferencedEntity = diagramEntityView.DiagramEntity.Entity;
                    EntityReferenceViewModel newPropertyView = new EntityReferenceViewModel(newProperty, dragEntityReferences.Solution);
                    dialog.DataContext            = newPropertyView;
                    dialog.Title                  = newPropertyView.Title;
                    newPropertyView.RequestClose += new EventHandler(Item_RequestClose);

                    dialog.ShowDialog();
                    if (newPropertyView.IsOK == true)
                    {
                        dragEntityReferences.AddEntityReference(newPropertyView);
                    }
                    dialog.Close();
                    dialog    = null;
                    e.Handled = true;
                    return;
                }
            }
        }