Пример #1
0
        private void OnCmdSelectedTreeViewValueWithPort(PortConnectInfo portInfo)
        {
            if (IsAddingReceive)
            {
                return;
            }
            portInfo.IsSelected = true;

            if (SelectedScreenLayer != null && SelectedScreenLayer.SenderConnectInfoList != null && SelectedScreenLayer.SenderConnectInfoList.Count != 0)
            {
                if (SelectedScreenLayer.SenderConnectInfoList[portInfo.SenderIndex].PortConnectInfoList != null &&
                    SelectedScreenLayer.SenderConnectInfoList[portInfo.SenderIndex].PortConnectInfoList.Count != 0)
                {
                    PortConnectInfo portConnectInfo = SelectedScreenLayer.SenderConnectInfoList[portInfo.SenderIndex].PortConnectInfoList[portInfo.PortIndex];
                    Function.SetElementCollectionState(SelectedScreenLayer.ElementCollection, SelectedState.None);
                    Function.SetElementCollectionState(portConnectInfo.ConnectLineElementList, SelectedState.Selected);
                }
            }
        }
        private void OnScreenMapRealParams()
        {
            //生成相应的显示屏按钮
            _height = ScreenMapRealParams.SenderLoadRectLayer.Height;
            _width = ScreenMapRealParams.SenderLoadRectLayer.Width;
           
            if (_myRadioButGrid == null)
            {
                return;
            }
            _myRadioButGrid.Children.Clear();
            _senderCheckBox.Clear();
            if (ScreenMapRealParams.RectLayerCollection != null && ScreenMapRealParams.RectLayerCollection.Count != 0)
            {

                if (ScreenMapRealParams.RectLayerType == ElementType.sender)
                {
                    ObservableCollection<SenderConnectInfo> senderAndPortInfo = new ObservableCollection<SenderConnectInfo>();
                    #region 有多少发送卡及发送卡下的网口
                    for (int i = 0; i < ScreenMapRealParams.RectLayerCollection.Count; i++)
                    {
                        if (ScreenMapRealParams.RectLayerCollection[i].EleType == ElementType.groupframe)
                        {
                            continue;
                        }
                        //是否存在此发送卡
                        bool isHave = false;
                        for (int j = 0; j < senderAndPortInfo.Count; j++)
                        {
                            if (senderAndPortInfo[j].SenderIndex == ((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).SenderIndex ||
                                ((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).SenderIndex<0)
                            {
                                isHave = true;
                                break;
                            }
                        }
                        if (!isHave)
                        {
                            SenderConnectInfo senderInfo=new SenderConnectInfo();
                            senderInfo.SenderIndex=((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).SenderIndex;
                            senderAndPortInfo.Add(senderInfo);
                        }
                    }
                    for (int i = 0; i < ScreenMapRealParams.RectLayerCollection.Count; i++)
                    {
                        if (ScreenMapRealParams.RectLayerCollection[i].EleType == ElementType.groupframe)
                        {
                            continue;
                        }
                        if (((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).SenderIndex < 0)
                        {
                            continue;
                        }
                        for (int j = 0; j < senderAndPortInfo.Count; j++)
                        {
                            if (senderAndPortInfo[j].SenderIndex == ((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).SenderIndex)
                            {
                                //是否有该网口
                                bool isHavePort = false;
                                for (int m = 0; m < senderAndPortInfo[j].PortConnectInfoList.Count; m++)
                                {
                                    if (senderAndPortInfo[j].PortConnectInfoList == null)
                                    {
                                        senderAndPortInfo[j].PortConnectInfoList = new ObservableCollection<PortConnectInfo>();
                                        isHavePort = true; ;
                                        break;
                                    }
                                    if (senderAndPortInfo[j].PortConnectInfoList[m].PortIndex == ((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).PortIndex)
                                    {
                                        isHavePort = true;
                                        break;
                                    }

                                }
                                if (!isHavePort)
                                {
                                    PortConnectInfo portInfo = new PortConnectInfo();
                                    portInfo.PortIndex = ((IRectElement)ScreenMapRealParams.RectLayerCollection[i]).PortIndex;
                                    portInfo.MaxConnectElement = (RectElement)ScreenMapRealParams.RectLayerCollection[i];
                                    senderAndPortInfo[j].PortConnectInfoList.Add(portInfo);
                                }
                                break;
                            }
                        }
                    }
                    #endregion
                    _myRadioButGrid.Height = 8 * (ScreenMapRealParams.RectLayerCollection.Count + senderAndPortInfo.Count) + 17 * (ScreenMapRealParams.RectLayerCollection.Count+senderAndPortInfo.Count)+(senderAndPortInfo.Count-1)*10;
                    #region  生成按钮
                    int addIndex = 0;
                    for (int m = 0; m < senderAndPortInfo.Count; m++)
                    {
                        CheckBox senderBut = new CheckBox();
                        addIndex += 1;

                        string msg = "";
                        CommonStaticMethod.GetLanguageString("发送卡", "Lang_Global_SendingBoard", out msg);
                        senderBut.Content = msg + " " + (senderAndPortInfo[m].SenderIndex+ 1);
                        senderBut.Foreground = Brushes.White;
                       
                        senderBut.Command = new RelayCommand<IRectElement>(OnCmdSenderBut);
                        Thickness margin = new Thickness();
                        margin.Left = 10;
                        margin.Top = 8 * addIndex + 17 * (addIndex-1)+10*m;
                        senderBut.Margin = margin;
                        senderBut.HorizontalAlignment = HorizontalAlignment.Left;
                        senderBut.VerticalAlignment = VerticalAlignment.Top;
                        _myRadioButGrid.Children.Add(senderBut);
                        _senderCheckBox.Add(senderAndPortInfo[m].SenderIndex, senderBut);
                         for (int j = 0; j < senderAndPortInfo[m].PortConnectInfoList.Count; j++)
                         {
                             if (j == 0)
                             {
                                 senderBut.CommandParameter = senderAndPortInfo[m].PortConnectInfoList[j].MaxConnectElement;
                             }
                             CheckBox portBut = new CheckBox();
                             addIndex += 1;

                             CommonStaticMethod.GetLanguageString("网口", "Lang_Global_NetPort", out msg);

                             portBut.Content = msg + " " + (senderAndPortInfo[m].PortConnectInfoList[j].PortIndex + 1);
                             portBut.Foreground = Brushes.White;
                             portBut.Command = new RelayCommand<IRectElement>(OnCmdPortBut);
                             portBut.Tag = senderAndPortInfo[m].PortConnectInfoList[j].MaxConnectElement;
                             portBut.CommandParameter = senderAndPortInfo[m].PortConnectInfoList[j].MaxConnectElement;
                             portBut.HorizontalAlignment = HorizontalAlignment.Left;
                             portBut.VerticalAlignment = VerticalAlignment.Top;
                             Thickness portmargin = new Thickness();
                             portmargin.Left = 30;
                             portmargin.Top = 8 * addIndex + 17 * (addIndex - 1)+10*m;
                             portBut.Margin = portmargin;
                             Binding myBinding = new Binding("ElementSelectedState");
                             SelectedStateConverterIsSelected convert = new SelectedStateConverterIsSelected();
                             myBinding.Converter = convert;
                             myBinding.Source = senderAndPortInfo[m].PortConnectInfoList[j].MaxConnectElement;
                             myBinding.Mode = BindingMode.TwoWay;
                             if (senderAndPortInfo[m].PortConnectInfoList[j].MaxConnectElement.ElementSelectedState != SelectedState.None)
                             {
                                 portBut.IsChecked = true;
                                 senderBut.IsChecked = true;
                             }
                             else
                             {
                                 portBut.IsChecked = false;
                             }
                             _myRadioButGrid.Children.Add(portBut);
                         }
                       
                    }
                    #endregion
                }
                if (ScreenMapRealParams.RectLayerType == ElementType.screen)
                {
                    _myRadioButGrid.Height = 8 * (ScreenMapRealParams.RectLayerCollection.Count) + 17 * (ScreenMapRealParams.RectLayerCollection.Count)+(ScreenMapRealParams.RectLayerCollection.Count-1)*7;
                    for (int i = 0; i < ScreenMapRealParams.RectLayerCollection.Count; i++)
                    {
                        IRectElement layer = (IRectElement)ScreenMapRealParams.RectLayerCollection[i];
                        CheckBox screenBut = new CheckBox();
                        string butContent = "";

                        string msg = "";
                        CommonStaticMethod.GetLanguageString("显示屏", "Lang_Global_Screen", out msg);

                        butContent = msg + " " + (layer.ConnectedIndex + 1);
                        layer.DisplayName = butContent;
                        if (layer.ElementSelectedState == SelectedState.Selected)
                        {
                            screenBut.IsChecked = true;
                        }
                        else
                        {
                            screenBut.IsChecked = false;
                        }
                        screenBut.Content = butContent;
                        screenBut.Foreground = Brushes.White;
                        screenBut.HorizontalAlignment = HorizontalAlignment.Left;
                        screenBut.VerticalAlignment = VerticalAlignment.Top;
                        screenBut.Command = new RelayCommand<CheckBox>(OnCmdScreenBut);
                        screenBut.Tag = ScreenMapRealParams.RectLayerCollection[i];
                        screenBut.CommandParameter = screenBut;
                        Thickness margin = new Thickness();
                        margin.Left = 10;
                        margin.Top = 8 * (i + 1) + 17 * i+i*7;
                        screenBut.Margin = margin;
                        _myRadioButGrid.Children.Add(screenBut);
                    }
                }
            }
            
            
        }
Пример #3
0
        private void OnCmdNewEmptyProject()
        {
            //保存当前工程
            string msg = "";
            CommonStaticMethod.GetLanguageString("是否保存?", "Lang_SmartLCT_VM_IsSave", out msg);
            MessageBoxResult result = ShowQuestionMessage(msg, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
            if (result == MessageBoxResult.Yes)
            {
                //SaveSysConfigFile(MyConfigurationData.ProjectLocationPath + "\\" + MyConfigurationData.ProjectName + ".xml");
                OnOtherSaveSysConfigFile();
            }
            else if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            //新建工程
            MyScreen.ElementCollection.Clear();
            //更新发送卡信息
            MyScreen.SenderConnectInfoList = new ObservableCollection<SenderConnectInfo>();
            ObservableCollection<PortConnectInfo> portConnectInfoList = new ObservableCollection<PortConnectInfo>();
            for (int i = 0; i < CurrentSenderConfigInfo.PortCount; i++)
            {
                PortConnectInfo portConnectInfo = new PortConnectInfo(i, 0, -1, null, null, new Rect());
                portConnectInfoList.Add(portConnectInfo);
            }
            SenderConnectInfo senderConnectIinfo = new SenderConnectInfo(0, portConnectInfoList, new Rect());
            MyScreen.SenderConnectInfoList.Add(senderConnectIinfo);

            RectLayer myRectLayer3 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth + SmartLCTViewModeBase.ScrollWidth, SmartLCTViewModeBase.MaxScreenHeight + SmartLCTViewModeBase.ScrollWidth, MyScreen, 0, ElementType.baselayer, 0);

            RectLayer Layer3_sender1 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, myRectLayer3, 3, ElementType.screen, 0);
            myRectLayer3.ElementSelectedState = SelectedState.None;
            myRectLayer3.ElementCollection.Add(Layer3_sender1);
            MyScreen.ElementCollection.Add(myRectLayer3);

            RectLayer newLayer = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, MyScreen, -1, ElementType.newLayer, -1);
            MyScreen.ElementCollection.Add(newLayer);
            if (SelectedEnvironMentIndex == 1)
            {
                SelectedEnvironMentIndex = 1;
            }

            //ConfigurationData ConfigData = new ConfigurationData();
            //ConfigData.OperateType = OperateScreenType.CreateScreen;
            //ConfigData.IsCreateEmptyProject = true;
            //ConfigData.SelectedScannerConfigInfo = null;
            //ConfigData.ProjectLocationPath = Function.GetDefaultCurrentProjectPath(_globalParams.RecentProjectPaths);
            //ConfigData.ProjectName = Function.GetDefaultProjectName(SmartLCTViewModeBase.DefaultProjectMainName, ".xml", ConfigData.ProjectLocationPath);
            //MyConfigurationData = ConfigData;
        }
Пример #4
0
        private void NewProjectCallBack(ConfigurationData data)
        {
            if (data != null)
            {
                //新建工程
                MyScreen.ElementCollection.Clear();
                //更新发送卡信息
                MyScreen.SenderConnectInfoList = new ObservableCollection<SenderConnectInfo>();
                ObservableCollection<PortConnectInfo> portConnectInfoList = new ObservableCollection<PortConnectInfo>();
                for (int i = 0; i < CurrentSenderConfigInfo.PortCount; i++)
                {
                    PortConnectInfo portConnectInfo = new PortConnectInfo(i, 0, -1, null, null, new Rect());
                    portConnectInfoList.Add(portConnectInfo);
                }
                SenderConnectInfo senderConnectIinfo = new SenderConnectInfo(0, portConnectInfoList, new Rect());
                MyScreen.SenderConnectInfoList.Add(senderConnectIinfo);

                RectLayer myRectLayer3 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth + SmartLCTViewModeBase.ScrollWidth, SmartLCTViewModeBase.MaxScreenHeight + SmartLCTViewModeBase.ScrollWidth, MyScreen, 0, ElementType.baselayer, 0);

                RectLayer Layer3_sender1 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, myRectLayer3, 3, ElementType.screen, 0);
                myRectLayer3.ElementSelectedState = SelectedState.None;
                myRectLayer3.ElementCollection.Add(Layer3_sender1);
                MyScreen.ElementCollection.Add(myRectLayer3);

                RectLayer newLayer = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, MyScreen, -1, ElementType.newLayer, -1);
                MyScreen.ElementCollection.Add(newLayer);
                MyConfigurationData = data;
                if (SelectedEnvironMentIndex == 1)
                {
                    SelectedEnvironMentIndex = 1;
                }
            }
        }
Пример #5
0
        private void OnCmdDelete()
        {
            ObservableCollection<IElement> deleteCollection = new ObservableCollection<IElement>();
            ObservableCollection<IElement> addCollection = new ObservableCollection<IElement>();
            ObservableCollection<ConnectIconVisibilityInfo> connectIconVisibleCollection = new ObservableCollection<ConnectIconVisibilityInfo>();
            _elementMoveInfo.Clear();
            _elementSizeInfo.Clear();
            for (int i = 0; i < _selectedElementCollection.Count; i++)
            {
                Point oldPoint = new Point();
                oldPoint.X = _selectedElementCollection[i].X;
                oldPoint.Y = _selectedElementCollection[i].Y;
                _elementMoveInfo.Add(new ElementMoveInfo(_selectedElementCollection[i], new Point(), oldPoint));
            }
            for (int itemIndex = 0; itemIndex < _myScreenLayer.ElementCollection.Count; itemIndex++)
            {
                if (_myScreenLayer.ElementCollection[itemIndex].EleType != ElementType.receive)
                {
                    continue;
                }
                IRectElement element = (IRectElement)_myScreenLayer.ElementCollection[itemIndex];
                if (element.ConnectedIndex >= 0)
                {
                    ConnectIconVisibilityInfo info = new ConnectIconVisibilityInfo();
                    info.Element = element;
                    OldAndNewVisibility oldAndNewMaxmaxVisible = new OldAndNewVisibility();
                    oldAndNewMaxmaxVisible.OldValue = element.MaxConnectIndexVisibile;
                    OldAndNewVisibility oldAndNewMaxminVisible = new OldAndNewVisibility();
                    oldAndNewMaxminVisible.OldValue =element.MinConnectIndexVisibile;
                    info.OldAndNewMaxConnectIndexVisibile = oldAndNewMaxmaxVisible;
                    info.OldAndNewMinConnectIndexVisibile = oldAndNewMaxminVisible;
                    connectIconVisibleCollection.Add(info);

                }
            }
                foreach (int key in _currentSelectedElement.Keys)
                {
                    if (_currentSelectedElement[key].SelectedGroupElementList.Count != 0 && key != -1)
                    {
                        Point oldPoint = new Point();
                        oldPoint.X = _groupframeList[key].X;
                        oldPoint.Y = _groupframeList[key].Y;
                        _elementMoveInfo.Add(new ElementMoveInfo(_groupframeList[key], new Point(), oldPoint));
                        Size oldSize = new Size();
                        oldSize.Width = _groupframeList[key].Width;
                        oldSize.Height = _groupframeList[key].Height;
                        _elementSizeInfo.Add(new ElementSizeInfo(_groupframeList[key], new Size(), oldSize));
                    }
                }
            foreach(int elementIndex in _currentSelectedElement.Keys)
            {
                ObservableCollection<IRectElement> selectedGroupList = _currentSelectedElement[elementIndex].SelectedGroupElementList;
                Rect noSelectedElementRect = _currentSelectedElement[elementIndex].NoSelectedElementRect;
                for (int i = 0; i < selectedGroupList.Count; i++)
                {
                    #region 删除
                    if (selectedGroupList[i].EleType == ElementType.receive)
                    {
                        #region 处理连线
                        RectElement rect = (RectElement)selectedGroupList[i];
                        PortConnectInfo portConnectInfo = new PortConnectInfo();
                        if (rect.SenderIndex != -1 && rect.PortIndex != -1)
                        {
                            portConnectInfo = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[rect.PortIndex];
                        }
                        if (rect.FrontLine == null && rect.EndLine == null)
                        {
                            //更新Map值(发送卡带载的x,y的改变,会影响给发送卡下网口的映射位置)
                            //记录删除前发送卡的带载的x,y
                            Point oldSenderPoint = new Point();
                            if (rect.SenderIndex >= 0 && rect.PortIndex >= 0)
                            {
                                oldSenderPoint = new Point(_myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize.X, _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize.Y);
                            }

                            portConnectInfo.ConnectLineElementList.Remove(rect);
                            portConnectInfo.MaxConnectElement = null;
                            portConnectInfo.MaxConnectIndex = -1;
                            deleteCollection.Add(rect);
                            _myScreenLayer.ElementCollection.Remove(rect);

                            if (_myScreenLayer.IsStartSetMapLocation && rect.SenderIndex>=0 && rect.PortIndex>=0)
                            {
                                //更新该发送卡的带载
                                portConnectInfo.LoadSize = Function.UnionRectCollection(portConnectInfo.ConnectLineElementList);
                                if(portConnectInfo.LoadSize.Height==0 && portConnectInfo.LoadSize.Width==0)
                                {
                                    portConnectInfo.MapLocation=new Point();
                                }
                                _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize = Function.UnionRectCollection(_myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList);
                                Rect newSenderLoadSize = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize;
                                Point newSenderPoint=new Point();
                                Point difSenderPint=new Point();
                                if(newSenderLoadSize.Width==0 && newSenderLoadSize.Height==0)
                                {
                                    //发送卡带载的xy有变化的话更新该发送卡下所有网口的Map
                                    //更新网口的map
                                    for (int j = 0; j < _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList.Count; j++)
                                    {
                                        PortConnectInfo portConnect = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[j];
                                        portConnect.MapLocation = new Point();
                                    }
                                }
                                else
                                {
                                    newSenderPoint = new Point(newSenderLoadSize.X, newSenderLoadSize.Y);
                                    difSenderPint = new Point(newSenderLoadSize.X - oldSenderPoint.X, newSenderLoadSize.Y - oldSenderPoint.Y);
                                    //发送卡带载的xy有变化的话更新该发送卡下所有网口的Map
                                    if (difSenderPint.Y != 0 || difSenderPint.X != 0)
                                    {
                                        //更新网口的map
                                        for (int j = 0; j < _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList.Count; j++)
                                        {
                                            PortConnectInfo portConnect = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[j];
                                            if (portConnect.LoadSize.Height != 0 && portConnect.LoadSize.Width != 0)
                                            {
                                                Point newmapLocation = new Point(portConnect.MapLocation.X + difSenderPint.X, portConnect.MapLocation.Y + difSenderPint.Y);
                                                portConnect.MapLocation = newmapLocation;
                                            }
                                        }
                                    }
                                }

                            }

                            continue;
                        }
                        if (rect.EndLine != null)
                        {
                            rect.EndLine.EndElement.FrontLine = null;
                            deleteCollection.Add(rect.EndLine);
                            _myScreenLayer.ElementCollection.Remove(rect.EndLine);
                            rect.EndLine = null;
                        }
                        if (rect.FrontLine != null)
                        {
                            rect.FrontLine.FrontElement.EndLine = null;
                            deleteCollection.Add(rect.FrontLine);
                            _myScreenLayer.ElementCollection.Remove(rect.FrontLine);
                            rect.FrontLine = null;
                        }
                        deleteCollection.Add(rect);

                        if (portConnectInfo.MaxConnectIndex != rect.ConnectedIndex)
                        {
                            List<IRectElement> connectList = portConnectInfo.ConnectLineElementList.ToList<IRectElement>();
                            connectList.Sort(delegate(IRectElement first, IRectElement second)
                            {
                                return first.ConnectedIndex.CompareTo(second.ConnectedIndex);
                            });
                            int currentIndex = connectList.IndexOf(rect);
                            connectList[currentIndex + 1].ConnectedIndex = connectList[currentIndex + 1].ConnectedIndex;
                            if (currentIndex == 0)
                            {
                                ((RectElement)connectList[currentIndex + 1]).MinConnectIndexVisibile = Visibility.Visible;
                                ((RectElement)connectList[currentIndex + 1]).MaxConnectIndexVisibile = Visibility.Hidden;
                            }
                            if(connectList[currentIndex+1].FrontLine!=null)
                            addCollection.Add(connectList[currentIndex + 1].FrontLine);
                        }
                        else
                        {
                            List<IRectElement> connectList = portConnectInfo.ConnectLineElementList.ToList<IRectElement>();
                            connectList.Sort(delegate(IRectElement first, IRectElement second)
                            {
                                return first.ConnectedIndex.CompareTo(second.ConnectedIndex);
                            });
                            if (connectList.Count == 1)
                            {
                                portConnectInfo.MaxConnectIndex = -1;
                                portConnectInfo.MaxConnectElement = null;
                                rect.MinConnectIndexVisibile = Visibility.Hidden;
                                rect.MaxConnectIndexVisibile = Visibility.Hidden;
                            }
                            else
                            {
                                portConnectInfo.MaxConnectIndex = connectList[connectList.Count - 2].ConnectedIndex;
                                portConnectInfo.MaxConnectElement = (RectElement)connectList[connectList.Count - 2];
                                if (connectList.Count > 2)
                                {
                                    ((RectElement)connectList[connectList.Count - 2]).MaxConnectIndexVisibile = Visibility.Visible;
                                }
                            }
                        }
                        //更新Map值(发送卡带载的x,y的改变,会影响给发送卡下网口的映射位置)
                        //记录删除前发送卡的带载的x,y
                        Point oldSenderPoints = new Point(_myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize.X, _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize.Y);
                        portConnectInfo.ConnectLineElementList.Remove(rect);
                        _myScreenLayer.ElementCollection.Remove(rect);
                        if (_myScreenLayer.IsStartSetMapLocation)
                        {
                            //更新该发送卡的带载
                            portConnectInfo.LoadSize = Function.UnionRectCollection(portConnectInfo.ConnectLineElementList);
                            if (portConnectInfo.LoadSize.Height == 0 && portConnectInfo.LoadSize.Width == 0)
                            {
                                portConnectInfo.MapLocation = new Point();
                            }
                            _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize = Function.UnionRectCollection(_myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList);
                            Rect newSenderLoadSizes = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].LoadSize;
                            Point newSenderPoints = new Point();
                            Point difSenderPints = new Point();
                            if (newSenderLoadSizes.Height == 0 && newSenderLoadSizes.Width == 0)
                            {
                                //发送卡带载的xy有变化的话更新该发送卡下所有网口的Map
                                //更新网口的map
                                for (int j = 0; j < _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList.Count; j++)
                                {
                                    PortConnectInfo portConnect = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[j];
                                    portConnect.MapLocation = new Point();
                                }
                            }
                            else
                            {
                                newSenderPoints = new Point(newSenderLoadSizes.X, newSenderLoadSizes.Y);
                                difSenderPints = new Point(newSenderPoints.X - oldSenderPoints.X, newSenderPoints.Y - oldSenderPoints.Y);
                                //发送卡带载的xy有变化的话更新该发送卡下所有网口的Map
                                if (difSenderPints.Y != 0 || difSenderPints.X != 0)
                                {
                                    //更新网口的map
                                    for (int j = 0; j < _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList.Count; j++)
                                    {
                                        PortConnectInfo portConnect = _myScreenLayer.SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[j];
                                        if (portConnect.LoadSize.Height != 0 && portConnect.LoadSize.Width != 0)
                                        {
                                            Point newmapLocation = new Point(portConnect.MapLocation.X + difSenderPints.X, portConnect.MapLocation.Y + difSenderPints.Y);
                                            portConnect.MapLocation = newmapLocation;
                                        }
                                    }
                                }
                            }

                        }
                        #endregion
                    }
                    #endregion
                }

                for (int itemIndex = 0; itemIndex < connectIconVisibleCollection.Count; itemIndex++)
                {
                    ConnectIconVisibilityInfo info=connectIconVisibleCollection[itemIndex];
                    if (_myScreenLayer.ElementCollection.Contains(info.Element))
                    {
                        info.OldAndNewMaxConnectIndexVisibile.NewValue = info.Element.MaxConnectIndexVisibile;
                        info.OldAndNewMinConnectIndexVisibile.NewValue = info.Element.MinConnectIndexVisibile;
                    }
                    else
                    {
                        info.OldAndNewMaxConnectIndexVisibile.NewValue = Visibility.Hidden;
                        info.OldAndNewMinConnectIndexVisibile.NewValue = Visibility.Hidden;
                    }
                }
                    //组框大小和位置=该组内没有选中的接收卡大矩形
                    if (elementIndex != -1)
                    {
                        if (noSelectedElementRect.Width == 0 && noSelectedElementRect.Height == 0)
                        {
                            deleteCollection.Add(_groupframeList[elementIndex]);
                            _myScreenLayer.ElementCollection.Remove(_groupframeList[elementIndex]);
                            _groupframeList.Remove(elementIndex);
                        }
                        else
                        {
                            _groupframeList[elementIndex].X = noSelectedElementRect.X;
                            _groupframeList[elementIndex].Y = noSelectedElementRect.Y;
                            _groupframeList[elementIndex].Width = noSelectedElementRect.Width;
                            _groupframeList[elementIndex].Height = noSelectedElementRect.Height;
                        }
                    }
                    else
                    {
                        if (noSelectedElementRect.Width == 0 && noSelectedElementRect.Height == 0)
                        {
                            _groupframeList.Remove(elementIndex);
                        }
                    }
            }
            AddAction addAction = new AddAction(_myScreenLayer, addCollection);
            DeleteAction deleteAction = new DeleteAction(_myScreenLayer, deleteCollection);
            for(int m=0;m<addCollection.Count;m++)
            {
                if (m < 0)
                {
                    m = 0;
                }
                if(addCollection[m] is LineElement)
                {
                    LineElement addLine=(LineElement)addCollection[m];
                    for (int n = 0; n < deleteCollection.Count; n++)
                    {
                        if(deleteCollection[n] is LineElement)
                        {
                            LineElement deleteLine=(LineElement)deleteCollection[n];
                             if(addLine.FrontElement.SenderIndex==deleteLine.FrontElement.SenderIndex
                                 && addLine.FrontElement.PortIndex==deleteLine.FrontElement.PortIndex
                                 && addLine.FrontElement.ConnectedIndex==deleteLine.FrontElement.ConnectedIndex
                                 && addLine.EndElement.ConnectedIndex == deleteLine.EndElement.ConnectedIndex)
                             {
                                 addCollection.Remove(addLine);
                                 m = m - 1;
                                 deleteCollection.Remove(deleteLine);
                                 n = n - 1;

                             }
                        }

                    }
                }
            }
            ObservableCollection<ElementMoveInfo> elementMoveInfo = new ObservableCollection<ElementMoveInfo>();
            for (int i = 0; i < _elementMoveInfo.Count; i++)
            {
                Point newPoint = new Point();
                newPoint.X = _elementMoveInfo[i].Element.X;
                newPoint.Y = _elementMoveInfo[i].Element.Y;
                elementMoveInfo.Add(new ElementMoveInfo(_elementMoveInfo[i].Element, newPoint, _elementMoveInfo[i].OldPoint));
            }
            ElementMoveAction moveAction = new ElementMoveAction(elementMoveInfo);
            ObservableCollection<ElementSizeInfo> elementSizeInfo = new ObservableCollection<ElementSizeInfo>();
            for (int j = 0; j < _elementSizeInfo.Count; j++)
            {
                Size newSize = new Size();
                newSize.Width = _elementSizeInfo[j].Element.Width;
                newSize.Height = _elementSizeInfo[j].Element.Height;
                elementSizeInfo.Add(new ElementSizeInfo(_elementSizeInfo[j].Element, newSize, _elementSizeInfo[j].OldSize));
            }
            ElementSizeAction sizeAction = new ElementSizeAction(elementSizeInfo);
            ConnectIconVisibilityAction connectIconAction = new ConnectIconVisibilityAction(connectIconVisibleCollection);
            using (Transaction.Create(SmartLCTActionManager))
            {
                SmartLCTActionManager.RecordAction(moveAction);
                SmartLCTActionManager.RecordAction(sizeAction);
                SmartLCTActionManager.RecordAction(deleteAction);
                SmartLCTActionManager.RecordAction(addAction);
                SmartLCTActionManager.RecordAction(connectIconAction);
            }
            GetCurrentElementInfo();
            SelectedLayerAndElementChanged();
        }
 private void UpdateSenderConnectInfo(RectLayer layer,SenderConnectInfo senderConnectInfo)
 {
     senderConnectInfo.IsExpand = false;
     senderConnectInfo.IsSelected = false;
     senderConnectInfo.LoadSize = new Rect();
     senderConnectInfo.MapLocation = new Point();
     senderConnectInfo.MaxLoadArea = Function.CalculateSenderLoadSize(senderConnectInfo.PortConnectInfoList.Count, 60, 24);
     for (int m = 0; m < senderConnectInfo.PortConnectInfoList.Count; m++)
     {
        //更新后箱体网口号不存在,则删除连线信息
         if (senderConnectInfo.PortConnectInfoList[m].PortIndex >= CurrentSenderConfigInfo.PortCount)
         {
             if (senderConnectInfo.PortConnectInfoList[m].ConnectLineElementList != null)
             {
                 ObservableCollection<IRectElement> connectLineElementList = senderConnectInfo.PortConnectInfoList[m].ConnectLineElementList;
                 for (int i = 0; i < connectLineElementList.Count; i++)
                 {
                     if (connectLineElementList[i].FrontLine != null)
                     {
                         layer.ElementCollection.Remove(connectLineElementList[i].FrontLine);
                     }
                     if (connectLineElementList[i].EndLine != null)
                     {
                         layer.ElementCollection.Remove(connectLineElementList[i].EndLine);
                     }
                     connectLineElementList[i].ConnectedIndex = -1;
                     connectLineElementList[i].SenderIndex = -1;
                     connectLineElementList[i].PortIndex = -1;
                 }
                 senderConnectInfo.PortConnectInfoList[m].ConnectLineElementList.Clear();
             }
             senderConnectInfo.PortConnectInfoList[m].MaxConnectIndex = -1;
             senderConnectInfo.PortConnectInfoList[m].MaxConnectElement = null;
             senderConnectInfo.PortConnectInfoList[m].LoadSize = new Rect();
             senderConnectInfo.PortConnectInfoList[m].IsSelected = false;
             senderConnectInfo.PortConnectInfoList[m].MaxLoadArea = Function.CalculatePortLoadSize(60, 24);
             senderConnectInfo.PortConnectInfoList.RemoveAt(m);
             m = m - 1;
         }
     }
     if (senderConnectInfo.PortConnectInfoList.Count < CurrentSenderConfigInfo.PortCount)
     {
         int addPortCount = CurrentSenderConfigInfo.PortCount - senderConnectInfo.PortConnectInfoList.Count;
         for (int i = 0; i < addPortCount; i++)
         {
             PortConnectInfo portConnectInfo = new PortConnectInfo(senderConnectInfo.PortConnectInfoList.Count, senderConnectInfo .SenderIndex,- 1, null, null, new Rect());
             senderConnectInfo.PortConnectInfoList.Add(portConnectInfo);
         }
     }
 }
        private void OnCurrentSenderConfigInfo()
        {
            if (ScreenRealParams != null && ScreenRealParams.ScreenLayer != null && ScreenRealParams.ScreenLayer.SenderConnectInfoList != null)
            {
                RectLayer removeLayer = (RectLayer)ScreenRealParams.ScreenLayer;
                while (removeLayer != null && removeLayer.EleType != ElementType.baseScreen)
                {
                    removeLayer = (RectLayer)removeLayer.ParentElement;
                }
                if (removeLayer == null)
                {
                    return;
                }
                
                for (int j = 0; j < removeLayer.ElementCollection.Count; j++)
                {
                    if (removeLayer.ElementCollection[j].EleType == ElementType.newLayer)
                    {
                        continue; 
                    }
                    RectLayer reLayer = (RectLayer)((RectLayer)removeLayer.ElementCollection[j]).ElementCollection[0];
                    for (int m = 0; m < removeLayer.SenderConnectInfoList.Count; m++)
                        UpdateSenderConnectInfo(reLayer, reLayer.SenderConnectInfoList[m]);

                }
                for (int i = 0; i < removeLayer.SenderConnectInfoList.Count; i++)
                {
                    for (int j = 0; j < removeLayer.SenderConnectInfoList[i].PortConnectInfoList.Count; j++)
                    {
                        ObservableCollection<PortConnectInfo> portConnectInfoList = removeLayer.SenderConnectInfoList[i].PortConnectInfoList;
                        if (portConnectInfoList[j].PortIndex >= CurrentSenderConfigInfo.PortCount)
                        {
                            portConnectInfoList.RemoveAt(j);
                            j = j - 1;
                        }
                    }
                    if (removeLayer.SenderConnectInfoList[i].PortConnectInfoList.Count < CurrentSenderConfigInfo.PortCount)
                    {
                        int addPortCount = CurrentSenderConfigInfo.PortCount - removeLayer.SenderConnectInfoList[i].PortConnectInfoList.Count;
                        for (int m = 0; m < addPortCount; m++)
                        {
                            PortConnectInfo portConnectInfo = new PortConnectInfo(removeLayer.SenderConnectInfoList[i].PortConnectInfoList.Count, removeLayer.SenderConnectInfoList[i].SenderIndex, - 1, null, null, new Rect());
                            removeLayer.SenderConnectInfoList[i].PortConnectInfoList.Add(portConnectInfo);
                        }
                    }
                }
                //更新网口和发送卡带载
                for (int j = 0; j < removeLayer.ElementCollection.Count; j++)
                {
                    if (removeLayer.ElementCollection[j].EleType == ElementType.newLayer)
                    {
                        continue;
                    }
                    RectLayer reLayer = (RectLayer)((RectLayer)removeLayer.ElementCollection[j]).ElementCollection[0];
                    Function.UpdateSenderConnectInfo(reLayer.SenderConnectInfoList,removeLayer);
                }
                   // Function.UpdateSenderConnectInfo(removeLayer.SenderConnectInfoList, removeLayer);
                if (_portCanvas != null)
                {
                    _portCanvas.Children.Clear();
                    for (int i = 0; i < CurrentSenderConfigInfo.PortCount; i++)
                    {
                        AddPortIndex(i);
                    }
                    ScreenRealParams.ScreenLayer.CurrentPortIndex = -1;
                }
            }
        }