コード例 #1
0
        public DragAdorner(UIElement owner, DragAdorner element)
            : base(owner)
        {
            this._owner = owner;

            textBlock.Text = "X=" + Math.Round(element.LeftOffset).ToString() + "  Y=" + Math.Round(element.TopOffset).ToString();
            textBlock.Foreground = Brushes.White;
            this._child = textBlock;
        }
コード例 #2
0
        private void Receive_MouseMove(object sender, MouseEventArgs e, IElement element)
        {
            if (element is LineElement)
            {
                ILineElement lineElement = (LineElement)element;
                IRectElement frontElment = lineElement.FrontElement;
                IRectElement endElement = lineElement.EndElement;
                Point mousePointInLine = e.GetPosition(_itemsControl);
                int clickNum = 0;
                if (mousePointInLine.X <= frontElment.X + frontElment.Width && mousePointInLine.X >= frontElment.X &&
                    mousePointInLine.Y <= frontElment.Y + frontElment.Height && mousePointInLine.Y >= frontElment.Y)
                {
                    element = frontElment;
                    clickNum += 1;
                }
                else if (mousePointInLine.X <= endElement.X + endElement.Width && mousePointInLine.X >= endElement.X &&
                    mousePointInLine.Y <= endElement.Y + endElement.Height && mousePointInLine.Y >= endElement.Y)
                {
                    element = endElement;
                    clickNum += 1;
                }
                if (clickNum == 2)
                {
                    if (frontElment.ZIndex > endElement.ZIndex)
                    {
                        element = frontElment;
                    }
                    else if (frontElment.ZIndex < endElement.ZIndex)
                    {
                        element = endElement;
                    }
                }
                if (clickNum == 0)
                {
                    e.Handled = true;
                    return;
                }

            }
            FrameworkElement currentFramework = (FrameworkElement)sender;
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                currentFramework.CaptureMouse();
            }
            else
            {
                currentFramework.ReleaseMouseCapture();
                if (this._adorner != null || (_addReceiveInfo != null && _myScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen))
                {
                    e.Handled = false;
                }
                else
                {
                    e.Handled = true;
                }
                return;
            }

            if (this._adorner != null)
            {
                e.Handled = false;
                return;
            }
            else
            {
                if ((Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))) ||
               (Keyboard.GetKeyStates(Key.RightCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.RightCtrl) == (KeyStates.Down | KeyStates.Toggled))))
                {
                }
                else if (_isMouseLeftButtonDown == true && element.EleType == ElementType.receive && element.ElementSelectedState != SelectedState.None)
                {
                    //虚构选中箱体的区域
                    _selectedReceiveArea = new Rect();
                    if (_selectedElementCollection != null && _selectedElementCollection.Count != 0)
                    {
                        double changedValue = Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex);
                        #region 1.计算选中箱体的区域
                        foreach (int groupName in _currentSelectedElement.Keys)
                        {
                            Rect currentSelectedRect = _currentSelectedElement[groupName].SelectedElementRect;
                            if (currentSelectedRect.Height != 0 && currentSelectedRect.Width != 0)
                            {
                                if (_selectedReceiveArea == new Rect())
                                {
                                    _selectedReceiveArea = currentSelectedRect;
                                }
                                else
                                {
                                    _selectedReceiveArea = Rect.Union(_selectedReceiveArea, currentSelectedRect);
                                }
                            }
                        }
                        #endregion
                        #region 2.生成虚构的箱体移动区域
                        //拖动的区域
                        this._dragScope = _itemsControl as FrameworkElement;

                        //是否可以拖放
                        this._dragScope.AllowDrop = true;
                        draghandler = new MouseEventHandler(DragScope_PreviewDragOver);
                        //加载处理拖放的路由事件
                        this._dragScope.MouseMove += draghandler;
                        this._dragScope.PreviewMouseMove += draghandler;
                        //鼠标跟随效果的装饰器
                        Point adornerMousePoint = new Point();
                        adornerMousePoint = e.GetPosition(this);
                        adornerMousePoint = this.TranslatePoint(adornerMousePoint, _itemsControl);
                        //已经是缩放后的真实值
                        _virtualMoveDifValue = new Point(adornerMousePoint.X - _selectedReceiveArea.X, adornerMousePoint.Y - _selectedReceiveArea.Y);
                        if(_myScreenLayer.OperateEnviron==OperatEnvironment.AdjustScreenLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation)
                        {
                            _virtualMoveDifValue.X -= _myScreenLayer.X;
                            _virtualMoveDifValue.Y -= _myScreenLayer.Y;
                        }
                        //_virtualMoveDifValue.X = Math.Round(_virtualMoveDifValue.X);
                        //_virtualMoveDifValue.Y = Math.Round(_virtualMoveDifValue.Y);
                        this._adorner = new DragAdorner(this._dragScope, _selectedReceiveArea.Width, _selectedReceiveArea.Height, adornerMousePoint, 0.5);
                        //装饰器的位置
                        this._adorner.LeftOffset = _selectedReceiveArea.X * changedValue;
                        this._adorner.TopOffset = _selectedReceiveArea.Y * changedValue;
                        if(_myScreenLayer.OperateEnviron==OperatEnvironment.AdjustSenderLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation)
                        {
                            this._adorner.LeftOffset += _myScreenLayer.X*changedValue;
                            this._adorner.TopOffset += _myScreenLayer.Y*changedValue;
                        }
                        this._adorner.Height = _selectedReceiveArea.Height;
                        this._adorner.Width = _selectedReceiveArea.Width;

                        this._layer = AdornerLayer.GetAdornerLayer(this._dragScope as Visual);
                        this._layer.Add(this._adorner);

                        //显示位置的装饰器
                        this._locationAdorner = new DragAdorner(this._dragScope, this._adorner);
                        //this._locationAdorner.TopOffset = adornerMousePoint.Y-20;
                        //this._locationAdorner.LeftOffset = adornerMousePoint.X;
                        this._locationAdorner.LeftOffset = _selectedReceiveArea.X * changedValue;
                        this._locationAdorner.TopOffset = _selectedReceiveArea.Y * changedValue;
                        if (_myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation)
                        {
                            this._locationAdorner.LeftOffset += _myScreenLayer.X*changedValue;
                            this._locationAdorner.TopOffset += _myScreenLayer.Y*changedValue;
                        }
                        this._layer.Add(this._locationAdorner);

                        return;
                        #endregion
                    }
                }
            }
            if (_addReceiveInfo != null && _myScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen)
            {
                e.Handled = false;
                return;
            }
            if (_myScreenLayer != null && _myScreenLayer.CLineType == ConnectLineType.Manual)
            {
                this.Cursor = Cursors.Hand;
                e.Handled = true;
                return;
            }
            #region 空格+鼠标移动屏体
            if ((Keyboard.GetKeyStates(Key.Space) == KeyStates.Down || (Keyboard.GetKeyStates(Key.Space) == (KeyStates.Down | KeyStates.Toggled))))
            {
                Layer_MouseMove(sender, e, _myScreenLayer);
                e.Handled = true;
                return;
            }
            #endregion

            #region 条件

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                currentFramework.CaptureMouse();
            }
            else
            {
                currentFramework.ReleaseMouseCapture();
                e.Handled = true;
                return;
            }
            List<IElement> selectedElementList = new List<IElement>();
            bool isMoveX = true;
            bool isMoveY = true;
            Point mousePoint = e.GetPosition(currentFramework);
            if (element.EleType == ElementType.receive && element.ElementSelectedState == SelectedState.None)
            {
                if (Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))
                {
                    //有可能是框选
                }
                else
                {
                    e.Handled = true;
                    return;
                }

            }

            if ((!_isMouseLeftButtonDown) || element.ParentElement.IsLocked)
            {
                e.Handled = true;
                return;
            }
            #endregion

            #region 鼠标框选处理

            if (((Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))) && element.EleType == ElementType.receive) ||
                element.EleType == ElementType.screen ||
                  element.EleType == ElementType.groupframe)
            {

                Rect oldRect = new Rect();
                if (((IRectElement)element.ParentElement).OperateEnviron == OperatEnvironment.DesignScreen)
                {
                    #region 移除前一个(框选的矩形zorder==-1)
                    for (int elementIndex = 0; elementIndex < _myScreenLayer.ElementCollection.Count; elementIndex++)
                    {
                        if (!(_myScreenLayer.ElementCollection[elementIndex] is RectElement))
                        {
                            continue;
                        }
                        if (((RectElement)_myScreenLayer.ElementCollection[elementIndex]).ZOrder == -1)
                        {
                            IRectElement re=(RectElement)_myScreenLayer.ElementCollection[elementIndex];
                            _myScreenLayer.ElementCollection.RemoveAt(elementIndex);
                            oldRect = new Rect(re.X, re.Y, re.Width, re.Height);
                        }
                    }
                    #endregion
                    Point mouseMovePointInThis = e.GetPosition(this);
                    mouseMovePointInThis.X = mouseMovePointInThis.X;
                    mouseMovePointInThis.Y = mouseMovePointInThis.Y;
                    Point mouseMovePointInItemsControl = this.TranslatePoint(mouseMovePointInThis, _itemsControl);
                    if (mouseMovePointInItemsControl.X > SmartLCTViewModeBase.MaxScreenWidth)
                    {
                        mouseMovePointInItemsControl.X = SmartLCTViewModeBase.MaxScreenWidth;
                    }
                    if (mouseMovePointInItemsControl.Y > SmartLCTViewModeBase.MaxScreenHeight)
                    {
                        mouseMovePointInItemsControl.Y = SmartLCTViewModeBase.MaxScreenHeight;
                    }
                    if (mouseMovePointInItemsControl.X < 0)
                    {
                        mouseMovePointInItemsControl.X = 0;
                    }
                    if (mouseMovePointInItemsControl.Y < 0)
                    {
                        mouseMovePointInItemsControl.Y = 0;
                    }
                    Point mouseLeftDownPointInItemControl = _mouseLeftDownPointInThis;

                    double height = Math.Abs(mouseMovePointInItemsControl.Y - mouseLeftDownPointInItemControl.Y);
                    double width = Math.Abs(mouseMovePointInItemsControl.X - mouseLeftDownPointInItemControl.X);

                    RectElement rect = new RectElement(mouseLeftDownPointInItemControl.X, mouseLeftDownPointInItemControl.Y, width, height, _myScreenLayer, -1);

                    if (mouseMovePointInItemsControl.X > mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y > mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseLeftDownPointInItemControl.X;
                        rect.Y = mouseLeftDownPointInItemControl.Y;

                    }
                    else if (mouseMovePointInItemsControl.X > mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y < mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseLeftDownPointInItemControl.X;
                        rect.Y = mouseMovePointInItemsControl.Y;
                    }
                    else if (mouseMovePointInItemsControl.X < mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y > mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseMovePointInItemsControl.X;
                        rect.Y = mouseLeftDownPointInItemControl.Y;
                    }
                    else if (mouseMovePointInItemsControl.X < mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y < mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseMovePointInItemsControl.X;
                        rect.Y = mouseMovePointInItemsControl.Y;
                    }

                    Thickness margin = new Thickness(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
                    rect.Margin = margin;
                    rect.ZOrder = -1;
                    rect.BackgroundBrush = Brushes.Gray;
                    rect.Opacity = 0.5;
                    rect.ZIndex = 8;
                    rect.MyLockAndVisibleButtonVisible = Visibility.Hidden;
                    rect.ElementSelectedState = SelectedState.FrameSelected;
                    rect.EleType = ElementType.frameSelected;
                    _myScreenLayer.ElementCollection.Add(rect);
                    _isFrameSelected = true;

                    Point minPoint=new Point(0,0);
                    Point maxPoint = new Point(this.ActualWidth, this.ActualHeight);
                    minPoint=this.TranslatePoint(minPoint, _itemsControl);
                    maxPoint = this.TranslatePoint(maxPoint, _itemsControl);
                    //判断移动的方向
                    if (oldRect != new Rect())
                    {
                        //向右框选
                        if (oldRect.X == rect.X && oldRect.Width<rect.Width && rect.X + rect.Width > maxPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + rect.X + rect.Width - maxPoint.X);
                        }
                        else if (oldRect.X+oldRect.Width==rect.X+rect.Width && oldRect.Width > rect.Width && rect.X > maxPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + rect.X - maxPoint.X);
                        }
                        //向左框选
                        if (oldRect.X + oldRect.Width == rect.X + rect.Width && oldRect.X > rect.X && rect.X < minPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset - (minPoint.X-rect.X));
                        }
                        else if (oldRect.X == rect.X && oldRect.Width > rect.Width && rect.X + rect.Width < minPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset - (minPoint.X - rect.X-rect.Width));
                        }
                        //向下框选
                        if (oldRect.Y == rect.Y && oldRect.Height < rect.Height && rect.Y + rect.Height > maxPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + rect.Y + rect.Height - maxPoint.Y);
                        }
                        else if (oldRect.Y + oldRect.Height == rect.Y + rect.Height && oldRect.Height > rect.Height && rect.Y > maxPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + rect.Y - maxPoint.Y);
                        }
                        //向上框选
                        if (oldRect.Y + oldRect.Height == rect.Y + rect.Height && oldRect.Y > rect.Y && rect.Y < minPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset - (minPoint.Y - rect.Y));
                        }
                        else if (oldRect.Y == rect.Y && oldRect.Height > rect.Height && rect.Y + rect.Height < minPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset - (minPoint.Y - rect.Y - rect.Height));
                        }
                    }

                    e.Handled = true;
                    return;
                }
            }
            #endregion

            #region 旧的移动
            //if (element.EleType==ElementType.receive && ((IRectElement)element).OperateEnviron==OperatEnvironment.DesignScreen)
            //{
            //    element.AddressVisible = Visibility.Visible;
            //    if (_selectedElementCollection.Count == 0)
            //    {
            //        e.Handled = true;
            //        return;
            //    }
            //}

            //#region 移动距离处理(超出最大最小边界时)
            //double controlMovingValueX = mousePoint.X - _mousePoint.X;
            //double controlMovingValueY = mousePoint.Y - _mousePoint.Y;
            ////controlMovingValueX = Math.Round(controlMovingValueX);
            ////controlMovingValueY = Math.Round(controlMovingValueY);
            //double maxScreenHeight = 0;
            //double maxScreenWidth = 0;
            //if (_myScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen)
            //{
            //    maxScreenHeight = SmartLCTViewModeBase.MaxScreenHeight;
            //    maxScreenWidth = SmartLCTViewModeBase.MaxScreenWidth;
            //}
            //else
            //{
            //    maxScreenWidth = _myScreenLayer.Width;
            //    maxScreenHeight = _myScreenLayer.Height;
            //}
            //if (_selectedElementRect.Width > maxScreenWidth)
            //{
            //    controlMovingValueX = -_selectedElementRect.X;
            //}
            //else if (_selectedElementRect.X + controlMovingValueX + _selectedElementRect.Width > maxScreenWidth)
            // {
            //     controlMovingValueX = maxScreenWidth - _selectedElementRect.X - _selectedElementRect.Width;
            //}
            //else if (_selectedElementRect.X + controlMovingValueX < 0)
            // {
            //     controlMovingValueX = -_selectedElementRect.X;
            //     _isStartMoveX = false;
            // }
            //if (_selectedElementRect.Height > maxScreenHeight)
            //{
            //    controlMovingValueY = -_selectedElementRect.Y;
            //}
            //else if (_selectedElementRect.Y + controlMovingValueY + _selectedElementRect.Height > maxScreenHeight)
            // {
            //     controlMovingValueY = maxScreenHeight - _selectedElementRect.Y - _selectedElementRect.Height;
            // }
            //else if (_selectedElementRect.Y + controlMovingValueY < 0)
            // {
            //     controlMovingValueY = -_selectedElementRect.Y;
            //     _isStartMoveY = false;
            // }
            // #endregion

            // #region 吸附

            //if (_isStartMoveX) //刚开始移动(移动距离大于SmartLCTViewModeBase.AdsorbValue才能移动)
            //{
            //    isMoveX = true;
            //    if (Math.Abs(controlMovingValueX) < SmartLCTViewModeBase.AdsorbValue)
            //    {
            //        isMoveX = false;
            //        controlMovingValueX = 0;
            //    }
            //    else
            //    {
            //        isMoveX = true;
            //        _isStartMoveX = false;
            //    }
            //}
            //if (_isStartMoveY) //刚开始移动(移动距离大于5才能移动)
            //{
            //    isMoveY = true;
            //    if (Math.Abs(controlMovingValueY) < SmartLCTViewModeBase.AdsorbValue)
            //    {
            //        isMoveY = false;
            //        controlMovingValueY = 0;
            //    }
            //    else
            //    {
            //        isMoveY = true;
            //        _isStartMoveY = false;
            //    }
            //}
            //if (isMoveY == false && isMoveX == false)
            //{
            //    e.Handled = true;
            //    return;
            //}
            //double valueX = SmartLCTViewModeBase.AdsorbValue + 1;
            //double valueY = SmartLCTViewModeBase.AdsorbValue + 1;

            //double currentElementMaxX = 0;
            //double currentElementMaxY = 0;
            //IRectElement currentElement = (IRectElement)element;
            //currentElementMaxX = currentElement.X;
            //currentElementMaxY = currentElement.Y;
            //if (controlMovingValueX > 0)
            //{
            //    if (_currentSelectedElement[element.GroupName].NoSelectedGroupElementList.Count == 0)
            //    {
            //        currentElementMaxX += _currentSelectedElement[element.GroupName].SelectedElementRect.Width;
            //    }
            //    else
            //    {
            //        currentElementMaxX += currentElement.Width;
            //    }
            //}
            //if (controlMovingValueY > 0)
            //{
            //    if (_currentSelectedElement[element.GroupName].NoSelectedGroupElementList.Count == 0)
            //    {
            //        currentElementMaxY += _currentSelectedElement[element.GroupName].SelectedElementRect.Height;
            //    }
            //    else
            //    {
            //        currentElementMaxY += currentElement.Height;
            //    }
            //}
            //for (int i = 0; i < _myScreenLayer.ElementCollection.Count; i++)
            //{
            //    if (_myScreenLayer.ElementCollection[i] is LineElement ||
            //        _myScreenLayer.ElementCollection[i].ElementSelectedState!=SelectedState.None)
            //    {
            //        continue;
            //    }
            //    IRectElement rect = (IRectElement)_myScreenLayer.ElementCollection[i];

            //    if (controlMovingValueX < 0 && isMoveX)
            //    {
            //        #region 向左移动
            //        if (rect.X > currentElementMaxX
            //            || rect.X + rect.Width < currentElementMaxX - SmartLCTViewModeBase.AdsorbValue
            //            || rect.Y > currentElementMaxY + currentElement.Height
            //            || rect.Height + rect.Y < currentElementMaxY)
            //        {
            //            continue;
            //        }
            //        if (rect.X < currentElementMaxX
            //            && rect.X + rect.Width > currentElement.X + currentElement.Width
            //            && currentElementMaxX - rect.X < valueX && currentElementMaxX - rect.X > 0)
            //        {
            //            valueX = currentElementMaxX - rect.X;
            //        }
            //        else
            //        {
            //            if (currentElementMaxX - rect.X < valueX && currentElementMaxX - rect.X > 0)
            //            {
            //                valueX = currentElementMaxX - rect.X;
            //            }
            //            else if (currentElementMaxX - rect.X - rect.Width < valueX
            //                && currentElementMaxX - rect.X - rect.Width > 0)
            //            {
            //                valueX = currentElementMaxX - rect.X - rect.Width;
            //            }
            //        }
            //        if (valueX < SmartLCTViewModeBase.AdsorbValue + 1 && valueX > 0)
            //        {
            //            controlMovingValueX = -valueX;
            //            _isStartMoveX = true;
            //        }
            //        #endregion
            //    }
            //    else if (controlMovingValueX > 0 && isMoveX)
            //    {
            //        #region 向右移动
            //        if (rect.X + rect.Width < currentElementMaxX
            //            || rect.X > currentElementMaxX + SmartLCTViewModeBase.AdsorbValue
            //            || rect.Y + rect.Height < currentElementMaxY
            //            || rect.Y > currentElementMaxY + currentElement.Height)
            //        {
            //            continue;
            //        }
            //        if (rect.X < currentElementMaxX && rect.X + rect.Width > currentElementMaxX
            //            && rect.X + rect.Width - currentElementMaxX < valueX
            //            && rect.X + rect.Width - currentElementMaxX > 0)
            //        {
            //            valueX = rect.X + rect.Width - currentElementMaxX;
            //        }
            //        else
            //        {
            //            if (rect.X - currentElementMaxX < valueX && rect.X - currentElementMaxX > 0)
            //            {
            //                valueX = rect.X - currentElementMaxX;
            //            }
            //            else if (rect.X + rect.Width - currentElementMaxX < valueX
            //                && rect.X + rect.Width - currentElementMaxX > 0)
            //            {
            //                valueX = rect.X + rect.Width - currentElementMaxX;
            //            }
            //        }
            //        if (valueX < SmartLCTViewModeBase.AdsorbValue + 1 && valueX > 0)
            //        {
            //            controlMovingValueX = valueX;
            //            _isStartMoveX = true;
            //        }
            //        #endregion
            //    }
            //    if (controlMovingValueY < 0 && isMoveY)
            //    {
            //        #region 向上移动
            //        if (rect.Y > currentElementMaxY
            //            || rect.Y + rect.Height < currentElementMaxY - SmartLCTViewModeBase.AdsorbValue
            //            || rect.X > currentElementMaxX + currentElement.Width
            //            || rect.Width + rect.X < currentElementMaxX)
            //        {
            //            continue;
            //        }
            //        if (rect.Y < currentElementMaxY
            //            && rect.Y + rect.Height > currentElement.Y + currentElement.Height
            //            && currentElementMaxY - rect.Y < valueY && currentElementMaxY - rect.Y > 0)
            //        {
            //            valueY = currentElementMaxY - rect.Y;
            //        }
            //        else
            //        {
            //            if (currentElementMaxY - rect.Y < valueY && currentElementMaxY - rect.Y > 0)
            //            {
            //                valueY = currentElementMaxY - rect.Y;
            //            }
            //            else if (currentElementMaxY - rect.Y - rect.Height < valueY
            //                && currentElementMaxY - rect.Y - rect.Height > 0)
            //            {
            //                valueY = currentElementMaxY - rect.Y - rect.Height;
            //            }
            //        }
            //        if (valueY < SmartLCTViewModeBase.AdsorbValue + 1 && valueY > 0)
            //        {
            //            controlMovingValueY = -valueY;
            //            _isStartMoveY = true;
            //        }
            //        #endregion
            //    }
            //    else if (controlMovingValueY > 0 && isMoveY)
            //    {
            //        #region 向下移动
            //        if (rect.Y + rect.Height < currentElementMaxY
            //            || rect.Y > currentElementMaxY + SmartLCTViewModeBase.AdsorbValue
            //            || rect.X + rect.Width < currentElementMaxX
            //            || rect.X > currentElementMaxX + currentElement.Width)
            //        {
            //            continue;
            //        }
            //        if (rect.Y < currentElementMaxY && rect.Y + rect.Height > currentElementMaxY
            //            && rect.Y + rect.Height - currentElementMaxY < valueY
            //            && rect.Y + rect.Height - currentElementMaxY > 0)
            //        {
            //            valueY = rect.Y + rect.Height - currentElementMaxY;
            //        }
            //        else
            //        {
            //            if (rect.Y - currentElementMaxY < valueY && rect.Y - currentElementMaxY > 0)
            //            {
            //                valueY = rect.Y - currentElementMaxY;
            //            }
            //            else if (rect.Y + rect.Height - currentElementMaxY < valueY
            //                && rect.Y + rect.Height - currentElementMaxY > 0)
            //            {
            //                valueY = rect.Y + rect.Height - currentElementMaxY;
            //            }

            //            if (valueY < SmartLCTViewModeBase.AdsorbValue + 1 && valueY > 0)
            //            {
            //                controlMovingValueY = valueY;
            //                _isStartMoveY = true;
            //            }
            //        }
            //        #endregion
            //    }
            //}
            // #endregion

            // #region 滚动条处理
            // Point maxXInThis = new Point();
            // Point minXInThis = new Point();
            // minXInThis.X = _selectedElementRect.X + controlMovingValueX + _myScreenLayer.X;
            // minXInThis.Y = _selectedElementRect.Y + controlMovingValueY + _myScreenLayer.Y;
            // maxXInThis.X = _selectedElementRect.X + controlMovingValueX + _selectedElementRect.Width + _myScreenLayer.X;
            // maxXInThis.Y = _selectedElementRect.Y + controlMovingValueY + _selectedElementRect.Height + _myScreenLayer.Y;
            // maxXInThis = _itemsControl.TranslatePoint(maxXInThis, this);
            // minXInThis = _itemsControl.TranslatePoint(minXInThis, this);
            //if (isMoveX)
            // {
            //     if (minXInThis.X < 0 && controlMovingValueX < 0)
            //     {
            //         if (minXInThis.X - controlMovingValueX < 0)
            //         {
            //             _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + controlMovingValueX * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //         else
            //         {
            //             _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + minXInThis.X * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //     }
            //     else if (maxXInThis.X > this.ActualWidth - (_scrollViewer.ActualWidth - _scrollViewer.ViewportWidth) && controlMovingValueX > 0)
            //     {
            //         if (maxXInThis.X - controlMovingValueX > this.ActualWidth - (_scrollViewer.ActualWidth - _scrollViewer.ViewportWidth))
            //         {
            //             _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + controlMovingValueX * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //         else
            //         {
            //             _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + (maxXInThis.X - this.ActualWidth + (_scrollViewer.ActualWidth - _scrollViewer.ViewportWidth)) * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //     }
            // }
            // if (isMoveY)
            // {
            //     if (minXInThis.Y < 0 && controlMovingValueY < 0)
            //     {
            //         if (minXInThis.Y - controlMovingValueY < 0)
            //         {
            //             _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + controlMovingValueY * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //         else
            //         {
            //             _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + minXInThis.Y * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //     }
            //     else if (maxXInThis.Y > this.ActualHeight - (_scrollViewer.ActualHeight - _scrollViewer.ViewportHeight) && controlMovingValueY > 0)
            //     {
            //         if (maxXInThis.Y - controlMovingValueY > this.ActualHeight - (_scrollViewer.ActualHeight - _scrollViewer.ViewportHeight))
            //         {
            //             _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + controlMovingValueY * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //         else
            //         {
            //             _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + (maxXInThis.Y - this.ActualHeight + (_scrollViewer.ActualHeight - _scrollViewer.ViewportHeight)) * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex));
            //         }
            //     }
            // }
            // #endregion

            // #region 移动与边框改变
            // if (controlMovingValueX != 0 || controlMovingValueY != 0)
            // {
            //     _isMoving = true;
            // }
            // foreach (int i in _currentSelectedElement.Keys)
            // {
            //     if (_currentSelectedElement[i].SelectedGroupElementList.Count == 0)
            //     {
            //         continue;
            //     }
            //     ObservableCollection<IRectElement> selectedList = _currentSelectedElement[i].SelectedGroupElementList;
            //     ObservableCollection<IRectElement> noSelectedList = _currentSelectedElement[i].NoSelectedGroupElementList;
            //     Rect selectedElementRect = _currentSelectedElement[i].SelectedElementRect;
            //     Rect noSelectedElementRect = _currentSelectedElement[i].NoSelectedElementRect;
            //    if (controlMovingValueX != 0)
            //    {
            //        Console.WriteLine("旧的移动x:" + controlMovingValueX.ToString());
            //        Function.SetElementCollectionX(selectedList, controlMovingValueX);
            //        selectedElementRect.X += controlMovingValueX;
            //        selectedElementRect.X = Math.Round(selectedElementRect.X);
            //    }
            //    if (controlMovingValueY != 0)
            //    {
            //        Console.WriteLine("旧的移动y:" + controlMovingValueY.ToString());

            //        Function.SetElementCollectionY(selectedList, controlMovingValueY);
            //        selectedElementRect.Y += controlMovingValueY;
            //        selectedElementRect.Y = Math.Round(selectedElementRect.Y);
            //    }
            //    if (i != -1 && (controlMovingValueX != 0 || controlMovingValueY != 0))
            //    {
            //        if (noSelectedList.Count == 0)
            //        {
            //            _groupframeList[i].X += controlMovingValueX;
            //            _groupframeList[i].Y += controlMovingValueY;
            //        }
            //        else
            //        {
            //            Rect unionrect = Rect.Union(selectedElementRect, noSelectedElementRect);
            //            _groupframeList[i].Width = unionrect.Width;
            //            _groupframeList[i].Height = unionrect.Height;
            //            _groupframeList[i].X = unionrect.X;
            //            _groupframeList[i].Y = unionrect.Y;

            //        }
            //        _currentSelectedElement[i].SelectedElementRect = selectedElementRect;
            //        _currentSelectedElement[i].NoSelectedElementRect = noSelectedElementRect;
            //    }
            //    else if (i == -1 && (controlMovingValueX != 0 || controlMovingValueY != 0))
            //    {
            //        _currentSelectedElement[i].SelectedElementRect = selectedElementRect;
            //    }
            // }
            // _selectedElementRect = new Rect();
            // foreach (int key in _currentSelectedElement.Keys)
            // {
            //     if (_currentSelectedElement[key].SelectedGroupElementList.Count != 0)
            //     {
            //         if (_selectedElementRect == new Rect())
            //         {
            //             _selectedElementRect = _currentSelectedElement[key].SelectedElementRect;
            //         }
            //         else
            //         {
            //             _selectedElementRect = Rect.Union(_selectedElementRect, _currentSelectedElement[key].SelectedElementRect);
            //         }

            //     }
            // }
            // #endregion
            #endregion
            e.Handled = true;
        }
コード例 #3
0
        public void Receive_MouseUp(object sender, MouseButtonEventArgs e, IElement element)
        {
            //if (element is LineElement)
            //{
            //    return;
            //}
            //清理工作
            _isScrollHorizon = false;
            _isScrollVertial = false;
            if (_addReceiveInfo != null)
            {
                this.Cursor = Cursors.Arrow;

            }
            if (this._adorner != null)
            {
                #region 移动与边框改变
                double changedValue = Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex);
                Point currentAdorner = new Point(_adorner.LeftOffset / changedValue, _adorner.TopOffset / changedValue);
                if (_myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation ||
                   _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation)
                {
                    currentAdorner.X -= _myScreenLayer.X;
                    currentAdorner.Y -= _myScreenLayer.Y;
                }
                //currentAdorner = this.TranslatePoint(currentAdorner,_itemsControl);
                currentAdorner.X = Math.Round(currentAdorner.X);
                currentAdorner.Y = Math.Round(currentAdorner.Y);
                double controlMovingValueX = currentAdorner.X - _selectedReceiveArea.X;
                double controlMovingValueY = currentAdorner.Y - _selectedReceiveArea.Y;
                controlMovingValueX = Math.Round(controlMovingValueX);
                controlMovingValueY = Math.Round(controlMovingValueY);
                if (controlMovingValueX != 0 || controlMovingValueY != 0)
                {
                    _isMoving = true;
                }
                foreach (int i in _currentSelectedElement.Keys)
                {
                    if (_currentSelectedElement[i].SelectedGroupElementList.Count == 0)
                    {
                        continue;
                    }
                    ObservableCollection<IRectElement> selectedList = _currentSelectedElement[i].SelectedGroupElementList;
                    ObservableCollection<IRectElement> noSelectedList = _currentSelectedElement[i].NoSelectedGroupElementList;
                    Rect selectedElementRect = _currentSelectedElement[i].SelectedElementRect;
                    Rect noSelectedElementRect = _currentSelectedElement[i].NoSelectedElementRect;
                    if (controlMovingValueX != 0)
                    {
                        Function.SetElementCollectionX(selectedList, controlMovingValueX);
                        selectedElementRect.X += controlMovingValueX;
                        selectedElementRect.X = Math.Round(selectedElementRect.X);
                    }
                    if (controlMovingValueY != 0)
                    {
                        Function.SetElementCollectionY(selectedList, controlMovingValueY);
                        selectedElementRect.Y += controlMovingValueY;
                        selectedElementRect.Y = Math.Round(selectedElementRect.Y);
                    }
                    if (i != -1 && (controlMovingValueX != 0 || controlMovingValueY != 0))
                    {
                        if (noSelectedList.Count == 0)
                        {
                            _groupframeList[i].X += controlMovingValueX;
                            _groupframeList[i].Y += controlMovingValueY;
                        }
                        else
                        {
                            Rect unionrect = Rect.Union(selectedElementRect, noSelectedElementRect);
                            _groupframeList[i].Width = unionrect.Width;
                            _groupframeList[i].Height = unionrect.Height;
                            _groupframeList[i].X = unionrect.X;
                            _groupframeList[i].Y = unionrect.Y;

                        }
                        _currentSelectedElement[i].SelectedElementRect = selectedElementRect;
                        _currentSelectedElement[i].NoSelectedElementRect = noSelectedElementRect;
                    }
                    else if (i == -1 && (controlMovingValueX != 0 || controlMovingValueY != 0))
                    {
                        _currentSelectedElement[i].SelectedElementRect = selectedElementRect;
                    }
                }
                _selectedElementRect = new Rect();
                foreach (int key in _currentSelectedElement.Keys)
                {
                    if (_currentSelectedElement[key].SelectedGroupElementList.Count != 0)
                    {
                        if (_selectedElementRect == new Rect())
                        {
                            _selectedElementRect = _currentSelectedElement[key].SelectedElementRect;
                        }
                        else
                        {
                            _selectedElementRect = Rect.Union(_selectedElementRect, _currentSelectedElement[key].SelectedElementRect);
                        }

                    }
                }
                #endregion

                AdornerLayer.GetAdornerLayer(this._dragScope).Remove(this._adorner);
                AdornerLayer.GetAdornerLayer(this._dragScope).Remove(this._locationAdorner);
                this._adorner = null;
                this._locationAdorner = null;
                this._dragScope.MouseMove -= draghandler;
                this._dragScope.PreviewMouseMove -= draghandler;
            }

            #region 空格+鼠标移动屏体
            if ((Keyboard.GetKeyStates(Key.Space) == KeyStates.Down || (Keyboard.GetKeyStates(Key.Space) == (KeyStates.Down | KeyStates.Toggled))))
            {
                Layer_MouseLeftButtonUp(sender, e, _myScreenLayer);
                e.Handled = true;
                return;
            }
            #endregion
            _myScreenLayer = (RectLayer)MyRectLayer.ElementCollection[0];
            element.AddressVisible = Visibility.Hidden;
            FrameworkElement currentFramework = (FrameworkElement)sender;
            #region 记录移动动作
            if (_isMoving)
            {
                RecordEndMoveData();
            }
            _isMoving = false;
            #endregion

            #region 框选
            if (_isFrameSelected)
            {
                ObservableCollection<SelectedStateInfo> oldSelectedStateInfoCollection = new ObservableCollection<SelectedStateInfo>();
                oldSelectedStateInfoCollection = GetOldSelectedStateInfoCollection();
                Function.SetElementCollectionState(_selectedElementCollection, SelectedState.None);
                for (int elementIndex = 0; elementIndex < _myScreenLayer.ElementCollection.Count; elementIndex++)
                {
                    if (!(_myScreenLayer.ElementCollection[elementIndex] is RectElement))
                    {
                        continue;
                    }
                    if ((_myScreenLayer.ElementCollection[elementIndex]).ZOrder == -1)
                    {
                        #region 选中框选的元素
                        RectElement rect1 = (RectElement)_myScreenLayer.ElementCollection[elementIndex];
                        for (int i = 0; i < _myScreenLayer.ElementCollection.Count; i++)
                        {
                            if (_myScreenLayer.ElementCollection[i].EleType != ElementType.receive)
                            {
                                continue;
                            }
                            IRectElement rect2 = ((IRectElement)_myScreenLayer.ElementCollection[i]);
                            if (Function.IsRectIntersect(rect1, rect2))
                            {
                                if (rect2.EleType == ElementType.receive)
                                {
                                    ((IRectElement)_myScreenLayer.ElementCollection[i]).ElementSelectedState = SelectedState.Selected;
                                }
                            }
                        }
                        #endregion
                        ((RectLayer)_myScreenLayer).ElementCollection.RemoveAt(elementIndex);
                        break;
                    }
                }
            }
            #endregion

            GetCurrentElementInfo();

            SelectedElementChangedHandle(MouseState.MouseUp);

            _isLayerMouseLeftButtonDown = false;
            _isFrameSelected = false;
            _isMouseLeftButtonDown = false;
            currentFramework.ReleaseMouseCapture();
            e.Handled = true;
        }
コード例 #4
0
        private void Receive_MouseMove(object sender, MouseEventArgs e, IElement element)
        {
            if (element is LineElement)
            {
                ILineElement lineElement = (LineElement)element;
                IRectElement frontElment = lineElement.FrontElement;
                IRectElement endElement = lineElement.EndElement;
                Point mousePointInLine = e.GetPosition(_itemsControl);
                int clickNum = 0;
                if (mousePointInLine.X <= frontElment.X + frontElment.Width && mousePointInLine.X >= frontElment.X &&
                    mousePointInLine.Y <= frontElment.Y + frontElment.Height && mousePointInLine.Y >= frontElment.Y)
                {
                    element = frontElment;
                    clickNum += 1;
                }
                else if (mousePointInLine.X <= endElement.X + endElement.Width && mousePointInLine.X >= endElement.X &&
                    mousePointInLine.Y <= endElement.Y + endElement.Height && mousePointInLine.Y >= endElement.Y)
                {
                    element = endElement;
                    clickNum += 1;
                }
                if (clickNum == 2)
                {
                    if (frontElment.ZIndex > endElement.ZIndex)
                    {
                        element = frontElment;
                    }
                    else if (frontElment.ZIndex < endElement.ZIndex)
                    {
                        element = endElement;
                    }
                }
                if (clickNum == 0)
                {
                    e.Handled = true;
                    return;
                }

            }
            FrameworkElement currentFramework = (FrameworkElement)sender;
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                currentFramework.CaptureMouse();
            }
            else
            {
                currentFramework.ReleaseMouseCapture();
                if (this._adorner != null || (_addReceiveInfo != null && _myScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen))
                {
                    e.Handled = false;
                }
                else
                {
                    e.Handled = true;
                }
                return;
            }

            if (this._adorner != null)
            {
                e.Handled = false;
                return;
            }
            else
            {
                if ((Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))) ||
       (Keyboard.GetKeyStates(Key.RightCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.RightCtrl) == (KeyStates.Down | KeyStates.Toggled))))
                {
                }
                else if (_isMouseLeftButtonDown == true && element.EleType == ElementType.receive && element.ElementSelectedState != SelectedState.None)
                {
                    //虚构选中箱体的区域
                    _selectedReceiveArea = new Rect();
                    if (_selectedElementCollection != null && _selectedElementCollection.Count != 0)
                    {
                        double changedValue = Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, _myScreenLayer.IncreaseOrDecreaseIndex);
                        #region 1.计算选中箱体的区域
                        foreach (int groupName in _currentSelectedElement.Keys)
                        {
                            Rect currentSelectedRect = _currentSelectedElement[groupName].SelectedElementRect;
                            if (currentSelectedRect.Height != 0 && currentSelectedRect.Width != 0)
                            {
                                if (_selectedReceiveArea == new Rect())
                                {
                                    _selectedReceiveArea = currentSelectedRect;
                                }
                                else
                                {
                                    _selectedReceiveArea = Rect.Union(_selectedReceiveArea, currentSelectedRect);
                                }
                            }
                        }
                        #endregion
                        #region 2.生成虚构的箱体移动区域
                        //拖动的区域
                        this._dragScope = _itemsControl as FrameworkElement;

                        //是否可以拖放
                        this._dragScope.AllowDrop = true;
                        draghandler = new MouseEventHandler(DragScope_PreviewDragOver);
                        //加载处理拖放的路由事件
                        this._dragScope.MouseMove += draghandler;
                        this._dragScope.PreviewMouseMove += draghandler;
                        //鼠标跟随效果的装饰器
                        Point adornerMousePoint = new Point();
                        adornerMousePoint = e.GetPosition(this);
                        adornerMousePoint = this.TranslatePoint(adornerMousePoint, _itemsControl);
                        //已经是缩放后的真实值
                        _virtualMoveDifValue = new Point(adornerMousePoint.X - _selectedReceiveArea.X, adornerMousePoint.Y - _selectedReceiveArea.Y);
                        if (_myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation)
                        {
                            _virtualMoveDifValue.X -= _myScreenLayer.X;
                            _virtualMoveDifValue.Y -= _myScreenLayer.Y;
                        }
                        //_virtualMoveDifValue.X = Math.Round(_virtualMoveDifValue.X);
                        //_virtualMoveDifValue.Y = Math.Round(_virtualMoveDifValue.Y);
                        this._adorner = new DragAdorner(this._dragScope, _selectedReceiveArea.Width, _selectedReceiveArea.Height, adornerMousePoint, 0.5);
                        //装饰器的位置
                        this._adorner.LeftOffset = _selectedReceiveArea.X * changedValue;
                        this._adorner.TopOffset = _selectedReceiveArea.Y * changedValue;
                        if (_myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation)
                        {
                            this._adorner.LeftOffset += _myScreenLayer.X * changedValue;
                            this._adorner.TopOffset += _myScreenLayer.Y * changedValue;
                        }
                        this._adorner.Height = _selectedReceiveArea.Height;
                        this._adorner.Width = _selectedReceiveArea.Width;

                        this._layer = AdornerLayer.GetAdornerLayer(this._dragScope as Visual);
                        this._layer.Add(this._adorner);


                        //显示位置的装饰器
                        this._locationAdorner = new DragAdorner(this._dragScope, this._adorner);
                        //this._locationAdorner.TopOffset = adornerMousePoint.Y-20;
                        //this._locationAdorner.LeftOffset = adornerMousePoint.X;
                        this._locationAdorner.LeftOffset = _selectedReceiveArea.X * changedValue;
                        this._locationAdorner.TopOffset = _selectedReceiveArea.Y * changedValue;
                        if (_myScreenLayer.OperateEnviron == OperatEnvironment.AdjustSenderLocation ||
                            _myScreenLayer.OperateEnviron == OperatEnvironment.AdjustScreenLocation)
                        {
                            this._locationAdorner.LeftOffset += _myScreenLayer.X * changedValue;
                            this._locationAdorner.TopOffset += _myScreenLayer.Y * changedValue;
                        }
                        this._layer.Add(this._locationAdorner);

                        return;
                        #endregion
                    }
                }
            }
            if (_addReceiveInfo != null && _myScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen)
            {
                e.Handled = false;
                return;
            }
            if (_myScreenLayer != null && _myScreenLayer.CLineType == ConnectLineType.Manual)
            {
                this.Cursor = Cursors.Hand;
                e.Handled = true;
                return;
            }
            #region 空格+鼠标移动屏体
            if ((Keyboard.GetKeyStates(Key.Space) == KeyStates.Down || (Keyboard.GetKeyStates(Key.Space) == (KeyStates.Down | KeyStates.Toggled))))
            {
                Layer_MouseMove(sender, e, _myScreenLayer);
                e.Handled = true;
                return;
            }
            #endregion

            #region 条件

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                currentFramework.CaptureMouse();
            }
            else
            {
                currentFramework.ReleaseMouseCapture();
                e.Handled = true;
                return;
            }
            List<IElement> selectedElementList = new List<IElement>();
            Point mousePoint = e.GetPosition(currentFramework);
            if (element.EleType == ElementType.receive && element.ElementSelectedState == SelectedState.None)
            {
                if (Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))
                {
                    //有可能是框选
                }
                else
                {
                    e.Handled = true;
                    return;
                }

            }

            if ((!_isMouseLeftButtonDown) || element.ParentElement.IsLocked)
            {
                e.Handled = true;
                return;
            }
            #endregion

            #region 鼠标框选处理

            if (((Keyboard.GetKeyStates(Key.LeftCtrl) == KeyStates.Down || (Keyboard.GetKeyStates(Key.LeftCtrl) == (KeyStates.Down | KeyStates.Toggled))) && element.EleType == ElementType.receive) ||
                element.EleType == ElementType.screen ||
                  element.EleType == ElementType.groupframe)
            {

                Rect oldRect = new Rect();
                if (((IRectElement)element.ParentElement).OperateEnviron == OperatEnvironment.DesignScreen)
                {
                    #region 移除前一个(框选的矩形zorder==-1)
                    for (int elementIndex = 0; elementIndex < _myScreenLayer.ElementCollection.Count; elementIndex++)
                    {
                        if (!(_myScreenLayer.ElementCollection[elementIndex] is RectElement))
                        {
                            continue;
                        }
                        if (((RectElement)_myScreenLayer.ElementCollection[elementIndex]).ZOrder == -1)
                        {
                            IRectElement re = (RectElement)_myScreenLayer.ElementCollection[elementIndex];
                            _myScreenLayer.ElementCollection.RemoveAt(elementIndex);
                            oldRect = new Rect(re.X, re.Y, re.Width, re.Height);
                        }
                    }
                    #endregion
                    Point mouseMovePointInThis = e.GetPosition(this);
                    mouseMovePointInThis.X = mouseMovePointInThis.X;
                    mouseMovePointInThis.Y = mouseMovePointInThis.Y;
                    Point mouseMovePointInItemsControl = this.TranslatePoint(mouseMovePointInThis, _itemsControl);
                    if (mouseMovePointInItemsControl.X > SmartLCTViewModeBase.MaxScreenWidth)
                    {
                        mouseMovePointInItemsControl.X = SmartLCTViewModeBase.MaxScreenWidth;
                    }
                    if (mouseMovePointInItemsControl.Y > SmartLCTViewModeBase.MaxScreenHeight)
                    {
                        mouseMovePointInItemsControl.Y = SmartLCTViewModeBase.MaxScreenHeight;
                    }
                    if (mouseMovePointInItemsControl.X < 0)
                    {
                        mouseMovePointInItemsControl.X = 0;
                    }
                    if (mouseMovePointInItemsControl.Y < 0)
                    {
                        mouseMovePointInItemsControl.Y = 0;
                    }
                    Point mouseLeftDownPointInItemControl = _mouseLeftDownPointInThis;

                    double height = Math.Abs(mouseMovePointInItemsControl.Y - mouseLeftDownPointInItemControl.Y);
                    double width = Math.Abs(mouseMovePointInItemsControl.X - mouseLeftDownPointInItemControl.X);

                    RectElement rect = new RectElement(mouseLeftDownPointInItemControl.X, mouseLeftDownPointInItemControl.Y, width, height, _myScreenLayer, -1);

                    if (mouseMovePointInItemsControl.X > mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y > mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseLeftDownPointInItemControl.X;
                        rect.Y = mouseLeftDownPointInItemControl.Y;

                    }
                    else if (mouseMovePointInItemsControl.X > mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y < mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseLeftDownPointInItemControl.X;
                        rect.Y = mouseMovePointInItemsControl.Y;
                    }
                    else if (mouseMovePointInItemsControl.X < mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y > mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseMovePointInItemsControl.X;
                        rect.Y = mouseLeftDownPointInItemControl.Y;
                    }
                    else if (mouseMovePointInItemsControl.X < mouseLeftDownPointInItemControl.X && mouseMovePointInItemsControl.Y < mouseLeftDownPointInItemControl.Y)
                    {
                        rect.X = mouseMovePointInItemsControl.X;
                        rect.Y = mouseMovePointInItemsControl.Y;
                    }
                    Thickness margin = new Thickness(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
                    rect.Margin = margin;
                    rect.ZOrder = -1;
                    rect.BackgroundBrush = Brushes.Gray;
                    rect.Opacity = 0.5;
                    rect.ZIndex = 8;
                    rect.MyLockAndVisibleButtonVisible = Visibility.Hidden;
                    rect.ElementSelectedState = SelectedState.FrameSelected;
                    rect.EleType = ElementType.frameSelected;
                    _myScreenLayer.ElementCollection.Add(rect);
                    _isFrameSelected = true;

                    Point minPoint = new Point(0, 0);
                    Point maxPoint = new Point(this.ActualWidth, this.ActualHeight);
                    minPoint = this.TranslatePoint(minPoint, _itemsControl);
                    maxPoint = this.TranslatePoint(maxPoint, _itemsControl);
                    //判断移动的方向
                    if (oldRect != new Rect())
                    {
                        //向右框选
                        if (oldRect.X == rect.X && oldRect.Width < rect.Width && rect.X + rect.Width > maxPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + rect.X + rect.Width - maxPoint.X);
                        }
                        else if (oldRect.X + oldRect.Width == rect.X + rect.Width && oldRect.Width > rect.Width && rect.X > maxPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + rect.X - maxPoint.X);
                        }
                        //向左框选
                        if (oldRect.X + oldRect.Width == rect.X + rect.Width && oldRect.X > rect.X && rect.X < minPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset - (minPoint.X - rect.X));
                        }
                        else if (oldRect.X == rect.X && oldRect.Width > rect.Width && rect.X + rect.Width < minPoint.X)
                        {
                            _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset - (minPoint.X - rect.X - rect.Width));
                        }
                        //向下框选
                        if (oldRect.Y == rect.Y && oldRect.Height < rect.Height && rect.Y + rect.Height > maxPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + rect.Y + rect.Height - maxPoint.Y);
                        }
                        else if (oldRect.Y + oldRect.Height == rect.Y + rect.Height && oldRect.Height > rect.Height && rect.Y > maxPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + rect.Y - maxPoint.Y);
                        }
                        //向上框选
                        if (oldRect.Y + oldRect.Height == rect.Y + rect.Height && oldRect.Y > rect.Y && rect.Y < minPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset - (minPoint.Y - rect.Y));
                        }
                        else if (oldRect.Y == rect.Y && oldRect.Height > rect.Height && rect.Y + rect.Height < minPoint.Y)
                        {
                            _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset - (minPoint.Y - rect.Y - rect.Height));
                        }
                    }

                    e.Handled = true;
                    return;
                }
            }
            #endregion
            e.Handled = true;
        }