Esempio n. 1
0
        public void AddThumbail(string filePath)
        {
            DesignerItem newItem = new DesignerItem();
            FreeImageAlgorithmsWPFImage uiElement = new FreeImageAlgorithmsWPFImage(filePath);

            uiElement.Stretch = Stretch.Fill;
            newItem.Selected += new System.Windows.RoutedEventHandler(OnDesignerItemSelected);

            uiElement.IsHitTestVisible = false;
            newItem.Content            = uiElement;

            newItem.Width  = uiElement.ThumbnailFib.Width;
            newItem.Height = uiElement.ThumbnailFib.Height;

            DesignerCanvas.SetLeft(newItem, startx);
            DesignerCanvas.SetTop(newItem, starty);

            startx += 10.0f;
            starty += 10.0f;

            this.Canvas.Children.Add(newItem);

            this.Canvas.DeselectAll();
            newItem.IsSelected = true;
        }
        /// <summary>
        /// If is grid enabled, snap to intersects
        /// </summary>
        private void SnapToGrid()
        {
            if (_canvas.IsGridEnabled)
            {
                int cellWidth = DesignerCanvas.GridCellWidth;

                var selected = _canvas.SelectedLabels.ToArray();

                foreach (LabelContent item in selected)
                {
                    double top    = item.ViewModel.Top;
                    double left   = item.ViewModel.Left;
                    double bottom = top + item.ViewModel.Height;
                    double right  = left + item.ViewModel.Width;

                    double approxCellTop  = Math.Round(top / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    double approxCellLeft = Math.Round(left / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;


                    DesignerCanvas.SetLeft(item, approxCellLeft);
                    DesignerCanvas.SetTop(item, approxCellTop);
                    item.ViewModel.Left = approxCellLeft;
                    item.ViewModel.Top  = approxCellTop;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Helper method for update of table position
        /// </summary>
        /// <param name="table">Table</param>
        private void UpdateTablePosition(TableContent table)
        {
            int step   = 100;
            var grid   = CreateMinifiedGridForPathFindingSync(ViewModel, step);
            var finder = new FreeRectangleFinder(grid);

            var rect = GetTableRectangles(new[] { table.TableViewModel }, step).Select(s =>
            {
                var t = s.Y / step;
                var l = s.X / step;
                var r = s.Right / step;
                var b = s.Bottom / step;
                return(new Rectangle(l, t, r - l, b - t));
            }).FirstOrDefault();

            var res = finder.FindFreeRectangle(rect);

            if (res.HasValue)
            {
                var realPoint = res.Value.FromMinified(step);
                table.TableViewModel.Top  = realPoint.Y;
                table.TableViewModel.Left = realPoint.X;

                DesignerCanvas.SetTop(table, realPoint.Y);
                DesignerCanvas.SetLeft(table, realPoint.X);
            }
        }
Esempio n. 4
0
 public void Create(UIElement element, double x, double y)
 {
     DesignerCanvas.SetLeft(element, x);
     DesignerCanvas.SetTop(element, y);
     Canvas.SetZIndex(element, designer.Children.Count);
     designer.Children.Add(element);
 }
Esempio n. 5
0
        void txtX_TextChanged(object sender, TextChangedEventArgs e)
        {
            double  x;
            TextBox txt = sender as TextBox;

            if (txt == null)
            {
                return;
            }
            if (_source == null)
            {
                return;
            }

            if (double.TryParse(txt.Text, out x))
            {
                DesignerCanvas.SetLeft(_source, x);
                if (PropertyXChanged == null)
                {
                    return;
                }

                PropertyXChanged(_source, new RoutedPropertyChangedEventArgs <double>(oldHeight, x));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Dragging
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDragDelta(object sender, DragDeltaEventArgs e)
        {
            if (_item != null && _canvas != null && _item.IsSelected)
            {
                double maxDeltaVertical   = _canvas.ActualHeight - (DesignerCanvas.GetTop(_item) + _item.ActualHeight);
                double maxDeltaHorizontal = _canvas.ActualWidth - (DesignerCanvas.GetLeft(_item) + _item.ActualWidth);

                var minDeltaVertical   = _item.ActualHeight - _item.MinHeight;
                var minDeltaHorizontal = _item.ActualWidth - _item.MinWidth;

                double deltaVertical;
                switch (VerticalAlignment)
                {
                case VerticalAlignment.Bottom:
                    deltaVertical = e.VerticalChange > 0 && e.VerticalChange >= maxDeltaVertical
                                                        ? 0
                                                        : Math.Min(-e.VerticalChange, minDeltaVertical);
                    _item.Height           = _item.ActualHeight - (int)deltaVertical;
                    _item.ViewModel.Height = _item.Height;
                    break;

                case VerticalAlignment.Top:
                    deltaVertical = (int)Math.Min(Math.Max(-DesignerCanvas.GetTop(_item), e.VerticalChange), minDeltaVertical);
                    var topPos = DesignerCanvas.GetTop(_item) + deltaVertical;
                    DesignerCanvas.SetTop(_item, topPos);
                    _item.Height           = _item.ActualHeight - deltaVertical;
                    _item.ViewModel.Height = _item.Height;
                    _item.ViewModel.Top    = topPos;
                    break;
                }

                double deltaHorizontal;
                switch (HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    deltaHorizontal = (int)Math.Min(Math.Max(-DesignerCanvas.GetLeft(_item), e.HorizontalChange), minDeltaHorizontal);
                    var leftPos = DesignerCanvas.GetLeft(_item) + deltaHorizontal;
                    DesignerCanvas.SetLeft(_item, leftPos);
                    _item.Width           = _item.ActualWidth - deltaHorizontal;
                    _item.ViewModel.Width = _item.Width;
                    _item.ViewModel.Left  = leftPos;
                    break;

                case HorizontalAlignment.Right:
                    deltaHorizontal       = e.HorizontalChange > 0 && e.HorizontalChange >= maxDeltaHorizontal ? 0 : (int)Math.Min(-e.HorizontalChange, minDeltaHorizontal);
                    _item.Width           = _item.ActualWidth - deltaHorizontal;
                    _item.ViewModel.Width = _item.Width;
                    break;
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// If is grid enabled, snap to intersects
        /// </summary>
        private void SnapToGrid()
        {
            if (_canvas.IsGridEnabled)
            {
                int cellWidth = DesignerCanvas.GridCellWidth;

                var selected = _canvas.SelectedTables.ToArray();

                double topConnectionLimit    = double.MaxValue;
                double bottomConnectionLimit = double.MaxValue;
                double leftConnectionLimit   = double.MaxValue;
                double rightConnectionLimit  = double.MaxValue;

                foreach (TableContent item in _canvas.SelectedTables)
                {
                    foreach (ConnectionInfoViewModel model in _connections.Where(t => t.SourceViewModel.Equals(item.TableViewModel)))
                    {
                        ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.SourceConnector, model);
                    }

                    foreach (ConnectionInfoViewModel model in _connections.Where(t => t.DestinationViewModel.Equals(item.TableViewModel)))
                    {
                        ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.DestinationConnector, model);
                    }
                }

                foreach (TableContent item in selected)
                {
                    double top    = item.TableViewModel.Top;
                    double left   = item.TableViewModel.Left;
                    double bottom = top + item.TableViewModel.Height;
                    double right  = left + item.TableViewModel.Width;

                    double approxCellTop  = Math.Round(top / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    double approxCellLeft = Math.Round(left / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;

                    if (WillSnapToGridBrokeConnections(topConnectionLimit, leftConnectionLimit, bottomConnectionLimit, rightConnectionLimit, top, left, bottom, right, approxCellTop, approxCellLeft))
                    {
                        continue;
                    }

                    DesignerCanvas.SetLeft(item, approxCellLeft);
                    DesignerCanvas.SetTop(item, approxCellTop);
                    item.TableViewModel.Left = approxCellLeft;
                    item.TableViewModel.Top  = approxCellTop;
                }
            }
        }
        private void CenterPointThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);

            if (this.designerItem != null && this._parent != null)
            {
                if (this._transform != null)
                {
                    dragDelta = _transform.Transform(dragDelta);
                }

                DesignerCanvas.SetLeft(this, DesignerCanvas.GetLeft(this) + dragDelta.X);
                DesignerCanvas.SetTop(this, DesignerCanvas.GetTop(this) + dragDelta.Y);
                e.Handled = true;
            }
        }
        /// <summary>
        /// Dragging
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDragDelta(object sender, DragDeltaEventArgs e)
        {
            if (_item != null && _canvas != null && _item.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                double maxTop  = double.MinValue;
                double maxLeft = double.MinValue;

                LabelContent[] selected = _canvas.SelectedLabels.ToArray();
                foreach (LabelContent item in selected)
                {
                    minLeft = Math.Min(DesignerCanvas.GetLeft(item), minLeft);
                    minTop  = Math.Min(DesignerCanvas.GetTop(item), minTop);
                    maxLeft = Math.Max(DesignerCanvas.GetLeft(item) + item.ActualWidth, maxLeft);
                    maxTop  = Math.Max(DesignerCanvas.GetTop(item) + item.ActualHeight, maxTop);
                }

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

                if (deltaHorizontal + maxLeft > _canvas.ActualWidth)
                {
                    deltaHorizontal = 0;
                }

                if (deltaVertical + maxTop > _canvas.ActualHeight)
                {
                    deltaVertical = 0;
                }

                foreach (LabelContent item in selected)
                {
                    var leftPos = DesignerCanvas.GetLeft(item) + deltaHorizontal;
                    var topPos  = DesignerCanvas.GetTop(item) + deltaVertical;
                    DesignerCanvas.SetLeft(item, leftPos);
                    DesignerCanvas.SetTop(item, topPos);
                    item.ViewModel.Left = leftPos;
                    item.ViewModel.Top  = topPos;
                }

                e.Handled = true;
            }
        }
Esempio n. 10
0
        protected override void OnDrop(DragEventArgs e)
        {
            //base.OnDrop(e);
            DragDropContainer dragObject = e.Data.GetData(typeof(DragDropContainer)) as DragDropContainer;

            if (dragObject != null && dragObject.Data != null)
            {
                ReflectDesignItem newItem = null;
                Object            content = dragObject.Data;

                if (content != null)
                {
                    newItem             = new ReflectDesignItem();
                    newItem.Style       = (Style)Application.Current.FindResource(typeof(DesignerItem));
                    newItem.DataContext = content;

                    Point position = e.GetPosition(this);

                    if (dragObject.DesiredSize.HasValue)
                    {
                        Size desiredSize = dragObject.DesiredSize.Value;
                        newItem.Width  = desiredSize.Width;
                        newItem.Height = desiredSize.Height;

                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
                    }
                    else
                    {
                        DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X));
                        DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y));
                    }

                    Canvas.SetZIndex(newItem, this.Children.Count);
                    this.Children.Add(newItem);
                    SetConnectorDecoratorTemplate(newItem);

                    //update selection
                    this.SelectionService.SelectItem(newItem);
                    newItem.Focus();
                }

                e.Handled = true;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// If is grid enabled, snap to intersects
        /// </summary>
        private void SnapToGrid()
        {
            if (_canvas.IsGridEnabled)
            {
                double top       = _item.ViewModel.Top;
                double left      = _item.ViewModel.Left;
                double bottom    = top + _item.ViewModel.Height;
                double right     = left + _item.ViewModel.Width;
                int    cellWidth = DesignerCanvas.GridCellWidth;

                double approxCell;

                switch (VerticalAlignment)
                {
                case VerticalAlignment.Top:
                    approxCell = Math.Round(top / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    DesignerCanvas.SetTop(_item, approxCell);
                    _item.ViewModel.Top = approxCell;
                    break;

                case VerticalAlignment.Bottom:
                    approxCell             = Math.Round(bottom / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    _item.ViewModel.Height = approxCell - _item.ViewModel.Top;
                    _item.Height           = _item.ViewModel.Height;
                    break;
                }

                switch (HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    approxCell = Math.Round(left / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    DesignerCanvas.SetLeft(_item, approxCell);
                    _item.ViewModel.Left = approxCell;
                    break;

                case HorizontalAlignment.Right:
                    approxCell            = Math.Round(right / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    _item.ViewModel.Width = approxCell - _item.ViewModel.Left;
                    _item.Width           = _item.ViewModel.Width;
                    break;
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// If is grid enabled, snap to intersects
        /// </summary>
        private void SnapToGrid()
        {
            if (_canvas.IsGridEnabled)
            {
                double topConnectionLimit    = double.MaxValue;
                double bottomConnectionLimit = double.MaxValue;
                double leftConnectionLimit   = double.MaxValue;
                double rightConnectionLimit  = double.MaxValue;

                foreach (ConnectionInfoViewModel model in _connections.Where(t => t.SourceViewModel.Equals(_item.TableViewModel)))
                {
                    ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.SourceConnector, model);
                }

                foreach (ConnectionInfoViewModel model in _connections.Where(t => t.DestinationViewModel.Equals(_item.TableViewModel)))
                {
                    ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.DestinationConnector, model);
                }

                double top       = _item.TableViewModel.Top;
                double left      = _item.TableViewModel.Left;
                double bottom    = top + _item.TableViewModel.Height;
                double right     = left + _item.TableViewModel.Width;
                int    cellWidth = DesignerCanvas.GridCellWidth;

                double approxCell;

                switch (VerticalAlignment)
                {
                case VerticalAlignment.Top:
                    approxCell = Math.Round(top / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    if (topConnectionLimit < double.MaxValue)
                    {
                        if (approxCell > top - topConnectionLimit)
                        {
                            DesignerCanvas.SetTop(_item, approxCell);
                            _item.TableViewModel.Top = approxCell;
                        }
                    }
                    else
                    {
                        DesignerCanvas.SetTop(_item, approxCell);
                        _item.TableViewModel.Top = approxCell;
                    }
                    break;

                case VerticalAlignment.Bottom:
                    approxCell = Math.Round(bottom / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    if (bottomConnectionLimit < double.MaxValue)
                    {
                        if (approxCell < bottom + bottomConnectionLimit)
                        {
                            _item.TableViewModel.Height = approxCell - _item.TableViewModel.Top;
                            _item.Height = _item.TableViewModel.Height;
                        }
                    }
                    else
                    {
                        _item.TableViewModel.Height = approxCell - _item.TableViewModel.Top;
                        _item.Height = _item.TableViewModel.Height;
                    }
                    break;
                }

                switch (HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    approxCell = Math.Round(left / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    if (leftConnectionLimit < double.MaxValue)
                    {
                        if (approxCell > left - leftConnectionLimit)
                        {
                            DesignerCanvas.SetLeft(_item, approxCell);
                            _item.TableViewModel.Left = approxCell;
                        }
                    }
                    else
                    {
                        DesignerCanvas.SetLeft(_item, approxCell);
                        _item.TableViewModel.Left = approxCell;
                    }
                    break;

                case HorizontalAlignment.Right:
                    approxCell = Math.Round(right / cellWidth, MidpointRounding.AwayFromZero) * cellWidth;
                    if (rightConnectionLimit < double.MaxValue)
                    {
                        if (approxCell < right + rightConnectionLimit)
                        {
                            _item.TableViewModel.Width = approxCell - _item.TableViewModel.Left;
                            _item.Width = _item.TableViewModel.Width;
                        }
                    }
                    else
                    {
                        _item.TableViewModel.Width = approxCell - _item.TableViewModel.Left;
                        _item.Width = _item.TableViewModel.Width;
                    }
                    break;
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Drag of thumb in progress
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            if (_item != null && _canvas != null && _item.IsSelected)
            {
                double maxDeltaVertical   = _canvas.ActualHeight - (DesignerCanvas.GetTop(_item) + _item.ActualHeight);
                double maxDeltaHorizontal = _canvas.ActualWidth - (DesignerCanvas.GetLeft(_item) + _item.ActualWidth);

                var minDeltaVertical   = _item.ActualHeight - _item.MinHeight;
                var minDeltaHorizontal = _item.ActualWidth - _item.MinWidth;

                #region Bad approach

                //Bad approach
                //foreach(TableContent item in _canvas.SelectedTables)
                //{
                //	minLeft = Math.Min(DesignerCanvas.GetLeft(item), minLeft);
                //	minTop = Math.Min(DesignerCanvas.GetTop(item), minTop);

                //	maxLeft = Math.Max(DesignerCanvas.GetLeft(item) + item.ActualWidth, maxLeft);
                //	maxTop = Math.Max(DesignerCanvas.GetTop(item) + item.ActualHeight, maxTop);

                //	if (item.TableViewModel.ViewMode != TableViewMode.NameOnly)
                //	{
                //		minDeltaVertical = Math.Min(item.ActualHeight - item.MinHeight, minDeltaVertical);
                //	}
                //	minDeltaHorizontal = Math.Min(item.ActualWidth - item.MinWidth, minDeltaHorizontal);

                //	maxDeltaVertical = Math.Min(_canvas.ActualHeight - (DesignerCanvas.GetTop(item) + item.ActualHeight), maxDeltaVertical);
                //	maxDeltaHorizontal = Math.Min(_canvas.ActualWidth - (DesignerCanvas.GetLeft(item) + item.ActualWidth), maxDeltaHorizontal);
                //}

                #endregion

                double topConnectionLimit    = double.MaxValue;
                double bottomConnectionLimit = double.MaxValue;
                double leftConnectionLimit   = double.MaxValue;
                double rightConnectionLimit  = double.MaxValue;

                foreach (ConnectionInfoViewModel model in _connections.Where(t => t.SourceViewModel.Equals(_item.TableViewModel)))
                {
                    ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.SourceConnector, model);
                }

                foreach (ConnectionInfoViewModel model in _connections.Where(t => t.DestinationViewModel.Equals(_item.TableViewModel)))
                {
                    ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.DestinationConnector, model);
                }

                if (_item.TableViewModel.ViewMode != TableViewMode.NameOnly)
                {
                    double deltaVertical;
                    switch (VerticalAlignment)
                    {
                    case VerticalAlignment.Bottom:
                        deltaVertical = e.VerticalChange > 0 && e.VerticalChange >= maxDeltaVertical ? 0 : Math.Min(-e.VerticalChange, minDeltaVertical);
                        if (bottomConnectionLimit < double.MaxValue)
                        {
                            if (DesignerCanvas.GetTop(_item) + _item.ActualHeight - deltaVertical >= (DesignerCanvas.GetTop(_item) + _item.ActualHeight) + bottomConnectionLimit)
                            {
                                deltaVertical = 0;
                            }
                        }
                        _item.Height = _item.ActualHeight - (int)deltaVertical;
                        _item.TableViewModel.Height = _item.Height;
                        break;

                    case VerticalAlignment.Top:
                        deltaVertical = (int)Math.Min(Math.Max(-DesignerCanvas.GetTop(_item), e.VerticalChange), minDeltaVertical);
                        if (topConnectionLimit < double.MaxValue)
                        {
                            if (deltaVertical < 0 && DesignerCanvas.GetTop(_item) + deltaVertical <= DesignerCanvas.GetTop(_item) - topConnectionLimit)
                            {
                                deltaVertical = 0;
                            }
                        }
                        var topPos = DesignerCanvas.GetTop(_item) + deltaVertical;
                        DesignerCanvas.SetTop(_item, topPos);
                        _item.Height = _item.ActualHeight - deltaVertical;
                        _item.TableViewModel.Height = _item.Height;
                        _item.TableViewModel.Top    = topPos;
                        break;
                    }
                }

                double deltaHorizontal;
                switch (HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    deltaHorizontal = (int)Math.Min(Math.Max(-DesignerCanvas.GetLeft(_item), e.HorizontalChange), minDeltaHorizontal);
                    if (leftConnectionLimit < double.MaxValue)
                    {
                        if (deltaHorizontal < 0 && DesignerCanvas.GetLeft(_item) + deltaHorizontal <= DesignerCanvas.GetLeft(_item) - leftConnectionLimit)
                        {
                            deltaHorizontal = 0;
                        }
                    }
                    var leftPos = DesignerCanvas.GetLeft(_item) + deltaHorizontal;
                    DesignerCanvas.SetLeft(_item, leftPos);
                    _item.Width = _item.ActualWidth - deltaHorizontal;
                    _item.TableViewModel.Width = _item.Width;
                    _item.TableViewModel.Left  = leftPos;
                    break;

                case HorizontalAlignment.Right:
                    deltaHorizontal = e.HorizontalChange > 0 && e.HorizontalChange >= maxDeltaHorizontal ? 0 : (int)Math.Min(-e.HorizontalChange, minDeltaHorizontal);
                    if (rightConnectionLimit < double.MaxValue)
                    {
                        if (DesignerCanvas.GetLeft(_item) + _item.ActualWidth - deltaHorizontal >= DesignerCanvas.GetLeft(_item) + _item.ActualWidth + rightConnectionLimit)
                        {
                            deltaHorizontal = 0;
                        }
                    }
                    _item.Width = _item.ActualWidth - deltaHorizontal;
                    _item.TableViewModel.Width = _item.Width;
                    break;
                }
            }
            e.Handled = true;
        }
Esempio n. 14
0
 public void Undo()
 {
     DesignerCanvas.SetLeft(_item, _oldProperty);
 }
Esempio n. 15
0
 public void Execute()
 {
     DesignerCanvas.SetLeft(_item, _newProperty);
 }
Esempio n. 16
0
        /// <summary>
        /// Mouse drag in progress
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="dragDeltaEventArgs"></param>
        private void OnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs)
        {
            if (_item != null && _canvas != null && _item.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                double maxTop  = double.MinValue;
                double maxLeft = double.MinValue;

                foreach (TableContent item in _canvas.SelectedTables)
                {
                    minLeft = Math.Min(DesignerCanvas.GetLeft(item), minLeft);
                    minTop  = Math.Min(DesignerCanvas.GetTop(item), minTop);
                    maxLeft = Math.Max(DesignerCanvas.GetLeft(item) + item.ActualWidth, maxLeft);
                    maxTop  = Math.Max(DesignerCanvas.GetTop(item) + item.ActualHeight, maxTop);
                }

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

                //Limit movement by connection position
                double topConnectionLimit    = double.MaxValue;
                double bottomConnectionLimit = double.MaxValue;
                double leftConnectionLimit   = double.MaxValue;
                double rightConnectionLimit  = double.MaxValue;

                foreach (TableContent item in _canvas.SelectedTables)
                {
                    foreach (ConnectionInfoViewModel model in _connections.Where(t => t.SourceViewModel.Equals(item.TableViewModel)))
                    {
                        ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.SourceConnector, model);
                    }

                    foreach (ConnectionInfoViewModel model in _connections.Where(t => t.DestinationViewModel.Equals(item.TableViewModel)))
                    {
                        ConnectionInfoViewModel.GetConnectionLimits(ref topConnectionLimit, ref bottomConnectionLimit, ref leftConnectionLimit, ref rightConnectionLimit, model.DestinationConnector, model);
                    }
                }

                if (_item.TableViewModel.AreLimitsEnabled)
                {
                    if (topConnectionLimit < double.MaxValue)
                    {
                        if (deltaVertical < 0 && minTop + deltaVertical <= minTop - topConnectionLimit)
                        {
                            deltaVertical = 0;
                        }
                    }

                    if (bottomConnectionLimit < double.MaxValue)
                    {
                        if (deltaVertical > 0 && maxTop + deltaVertical >= maxTop + bottomConnectionLimit)
                        {
                            deltaVertical = 0;
                        }
                    }

                    if (leftConnectionLimit < double.MaxValue)
                    {
                        if (deltaHorizontal < 0 && minLeft + deltaHorizontal <= minLeft - leftConnectionLimit)
                        {
                            deltaHorizontal = 0;
                        }
                    }

                    if (rightConnectionLimit < double.MaxValue)
                    {
                        if (deltaHorizontal > 0 && maxLeft + deltaHorizontal >= maxLeft + rightConnectionLimit)
                        {
                            deltaHorizontal = 0;
                        }
                    }

                    if (maxLeft >= _canvas.ActualWidth && dragDeltaEventArgs.HorizontalChange > 0)
                    {
                        deltaHorizontal = 0;
                    }

                    if (maxTop >= _canvas.ActualHeight && dragDeltaEventArgs.VerticalChange > 0)
                    {
                        deltaVertical = 0;
                    }
                }

                var selected = _canvas.SelectedTables.ToArray();

                foreach (TableContent item in selected)
                {
                    var leftPos = DesignerCanvas.GetLeft(item) + deltaHorizontal;
                    var topPos  = DesignerCanvas.GetTop(item) + deltaVertical;
                    DesignerCanvas.SetLeft(item, leftPos);
                    DesignerCanvas.SetTop(item, topPos);
                    item.TableViewModel.Left = leftPos;
                    item.TableViewModel.Top  = topPos;
                }

                dragDeltaEventArgs.Handled = true;
            }
        }