void designPanel_DragOver(object sender, DragEventArgs e)
		{
			try {
				IDesignPanel designPanel = (IDesignPanel)sender;
				e.Effects = DragDropEffects.Copy;
				e.Handled = true;
				Point p = e.GetPosition(designPanel);

				if (moveLogic == null) {
					if (e.Data.GetData(typeof(CreateComponentTool)) != this) return;
					// TODO: dropLayer in designPanel
					designPanel.IsAdornerLayerHitTestVisible = false;
					DesignPanelHitTestResult result = designPanel.HitTest(p, false, true);
					
					if (result.ModelHit != null) {
						designPanel.Focus();
						DesignItem createdItem = CreateItem(designPanel.Context);
						if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View))) {
							moveLogic = new MoveLogic(createdItem);
							createPoint = p;
						} else {
							changeGroup.Abort();
						}
					}
				} else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded) {
					if (moveLogic.Operation == null) {
						moveLogic.Start(createPoint);
					} else {
						moveLogic.Move(p);
					}
				}
			} catch (Exception x) {
				DragDropExceptionHandler.RaiseUnhandledException(x);
			}
		}
        internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick)
        {
            Debug.Assert(clickedOn != null);

            this.isDoubleClick      = isDoubleClick;
            this.positionRelativeTo = clickedOn.Services.DesignPanel;

            moveLogic = new MoveLogic(clickedOn);
        }
		internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick)
		{
			Debug.Assert(clickedOn != null);
			
			this.isDoubleClick = isDoubleClick;
			this.positionRelativeTo = clickedOn.Services.DesignPanel;

			moveLogic = new MoveLogic(clickedOn);
		}
        void designPanel_DragOver(object sender, DragEventArgs e)
        {
            try {
                IDesignPanel designPanel = (IDesignPanel)sender;
                e.Effects = DragDropEffects.Copy;
                e.Handled = true;
                Point p = e.GetPosition(designPanel);

                if (moveLogic == null)
                {
                    if (e.Data.GetData(this.GetType()) != this)
                    {
                        return;
                    }
                    // TODO: dropLayer in designPanel
                    designPanel.IsAdornerLayerHitTestVisible = false;
                    DesignPanelHitTestResult result = designPanel.HitTest(p, false, true, HitTestType.Default);

                    if (result.ModelHit != null)
                    {
                        designPanel.Focus();
                        DesignItem createdItem = CreateItem(designPanel.Context);
                        if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View)))
                        {
                            moveLogic = new MoveLogic(createdItem);

                            if (designPanel.Context.Services.Component is XamlComponentService)
                            {
                                ((XamlComponentService)designPanel.Context.Services.Component).RaiseComponentRegisteredAndAddedToContainer(createdItem);
                            }

                            createPoint = p;
                            // We'll keep the ChangeGroup open as long as the moveLogic is active.
                        }
                        else
                        {
                            // Abort the ChangeGroup created by the CreateItem() call.
                            changeGroup.Abort();
                        }
                    }
                }
                else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded)
                {
                    if (moveLogic.Operation == null)
                    {
                        moveLogic.Start(createPoint);
                    }
                    else
                    {
                        moveLogic.Move(p);
                    }
                }
            } catch (Exception x) {
                DragDropExceptionHandler.RaiseUnhandledException(x);
            }
        }
		public DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false)
		{
			Debug.Assert(clickedOn != null);
			
			this.isDoubleClick = isDoubleClick;
			this.setSelectionIfNotMoving = setSelectionIfNotMoving;
			this.positionRelativeTo = clickedOn.Services.DesignPanel;

			moveLogic = new MoveLogic(clickedOn);
		}
        public DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false)
        {
            Debug.Assert(clickedOn != null);

            this.isDoubleClick           = isDoubleClick;
            this.setSelectionIfNotMoving = setSelectionIfNotMoving;
            this.positionRelativeTo      = clickedOn.Services.DesignPanel;

            moveLogic = new MoveLogic(clickedOn);
        }
 void designPanel_DragLeave(object sender, DragEventArgs e)
 {
     try {
         if (moveLogic != null)
         {
             moveLogic.Cancel();
             moveLogic.ClickedOn.Services.Selection.SetSelectedComponents(null);
             moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
             moveLogic = null;
             changeGroup.Abort();
         }
     } catch (Exception x) {
         DragDropExceptionHandler.RaiseUnhandledException(x);
     }
 }
 void designPanel_Drop(object sender, DragEventArgs e)
 {
     try {
         if (moveLogic != null)
         {
             moveLogic.Stop();
             if (moveLogic.ClickedOn.Services.Tool.CurrentTool is CreateComponentTool)
             {
                 moveLogic.ClickedOn.Services.Tool.CurrentTool = moveLogic.ClickedOn.Services.Tool.PointerTool;
             }
             moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
             moveLogic = null;
             changeGroup.Commit();
         }
     } catch (Exception x) {
         DragDropExceptionHandler.RaiseUnhandledException(x);
     }
 }
		void designPanel_DragLeave(object sender, DragEventArgs e)
		{
			try {
				if (moveLogic != null) {
					moveLogic.Cancel();
					moveLogic.ClickedOn.Services.Selection.SetSelectedComponents(null);
					moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
					moveLogic = null;
					changeGroup.Abort();

				}
			} catch (Exception x) {
				DragDropExceptionHandler.RaiseUnhandledException(x);
			}
		}
		void designPanel_Drop(object sender, DragEventArgs e)
		{
			try {
				if (moveLogic != null) {
					moveLogic.Stop();
					if (moveLogic.ClickedOn.Services.Tool.CurrentTool is CreateComponentTool) {
						moveLogic.ClickedOn.Services.Tool.CurrentTool = moveLogic.ClickedOn.Services.Tool.PointerTool;
					}
					moveLogic.DesignPanel.IsAdornerLayerHitTestVisible = true;
					moveLogic = null;
					changeGroup.Commit();

					e.Handled = true;
				}
			} catch (Exception x) {
				DragDropExceptionHandler.RaiseUnhandledException(x);
			}
		}
        void designPanel_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                IDesignPanel designPanel = (IDesignPanel)sender;
                e.Effects = DragDropEffects.Copy;
                e.Handled = true;
                Point p = e.GetPosition(designPanel);

                if (moveLogic == null)
                {
                    if (ChangeGroup != null)
                    {
                        ChangeGroup.Abort();
                        ChangeGroup = null;
                    }
                    ChangeGroup = designPanel.Context.RootItem.OpenGroup("Add Control");
                    designPanel.IsAdornerLayerHitTestVisible = false;
                    DesignPanelHitTestResult result = designPanel.HitTest(p, false, true, HitTestType.Default);

                    if (result.ModelHit != null)
                    {
                        designPanel.Focus();
                        var items = CreateItemsWithPosition(designPanel.Context, e.GetPosition(result.ModelHit.View), e);
                        if (items != null)
                        {
                            if (AddItems(result.ModelHit, items))
                            {
                                moveLogic = new MoveLogic(items[0]);

                                foreach (var designItem in items)
                                {
                                    if (designPanel.Context.Services.Component is XamlComponentService)
                                    {
                                        ((XamlComponentService)designPanel.Context.Services.Component).RaiseComponentRegisteredAndAddedToContainer(designItem);
                                    }
                                }
                                createPoint = p;
                            }
                            else
                            {
                                ChangeGroup.Abort();
                                ChangeGroup = null;
                            }
                        }
                        else
                        {
                            e.Effects = DragDropEffects.None;
                        }
                    }
                }
                else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded)
                {
                    if (moveLogic.Operation == null)
                    {
                        moveLogic.Start(createPoint);
                    }
                    else
                    {
                        moveLogic.Move(p);
                    }
                }
            }
            catch (Exception x)
            {
                DragDropExceptionHandler.RaiseUnhandledException(x);
            }
        }
        void designPanel_DragOver(object sender, DragEventArgs e)
        {
            try {
                IDesignPanel designPanel = (IDesignPanel)sender;
                e.Effects = DragDropEffects.Copy;
                e.Handled = true;
                Point p = e.GetPosition(designPanel);

                if (moveLogic == null) {
                    if (e.Data.GetData(typeof(CreateComponentTool)) != this) return;
                    // TODO: dropLayer in designPanel
                    designPanel.IsAdornerLayerHitTestVisible = false;
                    DesignPanelHitTestResult result = designPanel.HitTest(p, false, true, HitTestType.Default);

                    if (result.ModelHit != null) {
                        designPanel.Focus();
                        DesignItem createdItem = CreateItem(designPanel.Context);
                        if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View))) {
                            moveLogic = new MoveLogic(createdItem);

                            if (designPanel.Context.Services.Component is XamlComponentService) {
                                ((XamlComponentService) designPanel.Context.Services.Component).RaiseComponentRegisteredAndAddedToContainer(createdItem);
                            }

                            createPoint = p;
                            // We'll keep the ChangeGroup open as long as the moveLogic is active.
                        } else {
                            // Abort the ChangeGroup created by the CreateItem() call.
                            changeGroup.Abort();
                        }
                    }
                } else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded) {
                    if (moveLogic.Operation == null) {
                        moveLogic.Start(createPoint);
                    } else {
                        moveLogic.Move(p);
                    }
                }
            } catch (Exception x) {
                DragDropExceptionHandler.RaiseUnhandledException(x);
            }
        }