Esempio n. 1
0
        private void OnSelectedLayerAndElementChanged(SelectedLayerAndElement selectedLayerAndElement)
        {
            IsAddingReceive = selectedLayerAndElement.IsAddingReceive;
            if (IsAddingReceive)
            {
                return;
            }
            SelectedScreenLayer = selectedLayerAndElement.SelectedLayer;
            if (SelectedScreenLayer.OperateEnviron == OperatEnvironment.DesignScreen)
            {
                _mainControlSize = selectedLayerAndElement.MainControlSize;
            }
            if (SelectedScreenLayer.OperateEnviron != OperatEnvironment.DesignScreen)
            {
                int senderIndex;
                int senderCount = Function.FindSenderCount(MyScreen.SenderConnectInfoList, out senderIndex);

                if (selectedLayerAndElement.SelectedElement.Count == 1)
                {
                    SenderVisible = Visibility.Visible;
                    if (senderCount == 1)
                    {
                        CurrentScreen = selectedLayerAndElement.SelectedElement[0];
                    }
                    else if (senderCount > 1)
                    {
                        CurrentScreen = selectedLayerAndElement.SelectedElement[0];
                        CurrentSenderScreen = selectedLayerAndElement.SelectedElement[0];
                        if (selectedLayerAndElement.fj == 2)
                        {
                            CurrentScreen = selectedLayerAndElement.CurrentRectElement;
                        }
                    }
                    PleaseSelElmentVisible = Visibility.Hidden;
                }
                else
                {

                    if (_senderCount == 1)
                    {
                        SenderRealParameters senderRealPara = new SenderRealParameters();
                        senderRealPara.Element = null;
                        SenderRealParametersValue = senderRealPara;
                        CurrentScreen = null;
                        SenderVisible = Visibility.Collapsed;
                    }
                    else if (_senderCount > 1)
                    {
                        //多发送的情况下单击选择了一个组
                        for (int i = 0; i < ScreenMapRealParametersValue.RectLayerCollection.Count; i++)
                        {
                            ScreenMapRealParametersValue.RectLayerCollection[i].ElementSelectedState = SelectedState.None;
                        }
                        for (int j = 0; j < selectedLayerAndElement.SelectedElement.Count; j++)
                        {
                            IRectElement selectedELement = selectedLayerAndElement.SelectedElement[j];
                            for (int i = 0; i < ScreenMapRealParametersValue.RectLayerCollection.Count; i++)
                            {
                                IRectElement rectelement = (IRectElement)ScreenMapRealParametersValue.RectLayerCollection[i];
                                if (rectelement.SenderIndex == selectedELement.SenderIndex && rectelement.PortIndex == selectedELement.PortIndex)
                                {
                                    rectelement.ElementSelectedState = SelectedState.Selected;
                                }
                            }
                        }
                        if (selectedLayerAndElement.SelectedElement.Count != 0)
                        {
                            CheckSenderIndex = -1;
                            CheckSenderIndex = selectedLayerAndElement.SelectedElement[0].SenderIndex;
                        }
                        if (selectedLayerAndElement.SelectedElement.Count > 1)
                        {
                            //找到移动的组
                            RectLayer screenLayer = (RectLayer)ScreenLocationRectLayer.ElementCollection[0];
                            for (int i = 0; i < screenLayer.ElementCollection.Count; i++)
                            {
                                if (screenLayer.ElementCollection[i].EleType == ElementType.groupframe &&
                                    screenLayer.ElementCollection[i].GroupName == selectedLayerAndElement.SelectedElement[0].GroupName)
                                {
                                    CurrentScreen = (IRectElement)screenLayer.ElementCollection[i];
                                    for (int j = 0; j < selectedLayerAndElement.SelectedElement.Count; j++)
                                    {
                                        IRectElement rect = selectedLayerAndElement.SelectedElement[j];
                                        rect.ElementSelectedState = SelectedState.Selected;
                                        ((RectLayer)((RectLayer)MyScreen.ElementCollection[rect.ConnectedIndex]).ElementCollection[0]).SenderConnectInfoList[rect.SenderIndex].PortConnectInfoList[rect.PortIndex].MapLocation = new Point(CurrentScreen.X,CurrentScreen.Y);
                                    }
                                    break;
                                }
                            }
                            SenderVisible = Visibility.Collapsed;
                        }
                        else
                        {
                            SenderVisible = Visibility.Visible;
                        }
                    }
                    PleaseSelElmentVisible = Visibility.Hidden;
                }
                return;
            }

            if (SelectedScreenLayer != null)
            {
                IncreaseOrDecreaseIndex = SelectedScreenLayer.IncreaseOrDecreaseIndex;
            }
            if (selectedLayerAndElement.SelectedLayer.EleType == ElementType.newLayer)
            {
                SenderVisible = Visibility.Collapsed;
                ScanVisible = Visibility.Collapsed;
                CustomScanVisible = Visibility.Collapsed;
                PleaseSelElmentVisible = Visibility.Hidden;
                ScreenVisible = Visibility.Collapsed;
                return;
            }
            if (selectedLayerAndElement.SelectedLayer == null)
            {
                SenderVisible = Visibility.Collapsed;
                ScanVisible = Visibility.Collapsed;
                CustomScanVisible = Visibility.Collapsed;
                PleaseSelElmentVisible = Visibility.Visible;
                ScreenVisible = Visibility.Collapsed;
                return;
            }
            _selectedLayerAndELment = selectedLayerAndElement;
            if (selectedLayerAndElement.SelectedLayer.EleType == ElementType.None)
            {
                SenderRealParameters rp = new SenderRealParameters();
                rp.Element = new RectLayer();

                SenderRealParametersValue = rp;
                ScreenVisible = Visibility.Collapsed;
                ScanVisible = Visibility.Collapsed;
                CustomScanVisible = Visibility.Collapsed;
                PleaseSelElmentVisible = Visibility.Visible;
            }
            else if (selectedLayerAndElement.SelectedLayer.EleType == ElementType.screen)
            {
                ScreenVisible = Visibility.Visible;
                SenderVisible = Visibility.Collapsed;
                if (selectedLayerAndElement.SelectedElement.Count == 1)
                {
                    ScannerRealParameters scannerParameters = new ScannerRealParameters();
                    scannerParameters.ScannerElement = selectedLayerAndElement.SelectedElement[0];
                    int groupname = selectedLayerAndElement.SelectedElement[0].GroupName;
                    if (groupname != -1)
                    {
                        scannerParameters.Groupframe = selectedLayerAndElement.GroupframeList[groupname];
                        scannerParameters.NoSelectedElementRect = selectedLayerAndElement.SelectedInfoList[groupname].NoSelectedElementRect;
                    }
                    object tag = selectedLayerAndElement.SelectedElement[0].Tag;
                    if (tag is ScannerCofigInfo)
                    {
                        scannerParameters.ScannerConfig = (ScannerCofigInfo)tag;
                        if (scannerParameters.ScannerConfig.ScanBdProp.StandardLedModuleProp.DriverChipType == ChipType.Unknown)
                        {
                            CustomScanVisible = Visibility.Visible;
                            ScanVisible = Visibility.Collapsed;
                        }
                        else
                        {
                            ScanVisible = Visibility.Visible;
                            CustomScanVisible = Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        scannerParameters.ScannerConfig = null;
                        ScanVisible = Visibility.Visible;
                        CustomScanVisible = Visibility.Collapsed;
                    }
                    ScannerRealParametersValue = scannerParameters;
                }
                else
                {
                    ScanVisible = Visibility.Collapsed;
                    CustomScanVisible = Visibility.Collapsed;
                }

                ScreenRealParameters screenParameters = new ScreenRealParameters();
                screenParameters.ScreenLayer = selectedLayerAndElement.SelectedLayer;
                screenParameters.SelectedElement = selectedLayerAndElement.SelectedElement;

                ScreenRealParametersValue = screenParameters;

                PleaseSelElmentVisible = Visibility.Hidden;
            }
            else
            {
                SenderVisible = Visibility.Collapsed;
                ScanVisible = Visibility.Collapsed;
                CustomScanVisible = Visibility.Collapsed;
                PleaseSelElmentVisible = Visibility.Visible;
                ScreenVisible = Visibility.Collapsed;
            }
        }
Esempio n. 2
0
        private void OnCreateScreenWithConfigurationData(ConfigurationData data)
        {
            string projectPath = data.ProjectLocationPath + "\\" + data.ProjectName + SmartLCTViewModeBase.ProjectExtension;

            if (data.OperateType == OperateScreenType.CreateScreenAndOpenConfigFile)
            {
                OpenConfigFileAndHandleData(projectPath);
                return;
            }
            SelectedLayerAndElement selectedLayerAndElement = new SelectedLayerAndElement();
            ObservableCollection<IRectElement> selectedElementCollection = new ObservableCollection<IRectElement>();
            Dictionary<int, IRectElement> groupframeList = new Dictionary<int, IRectElement>();
            RectLayer screen = (RectLayer)SelectedValue.ElementCollection[0];
            if (data.IsCreateEmptyProject)
            {
                    // 创建空工程
                    return;
            }

            CurrentSenderConfigInfo = data.SelectedSenderConfigInfo;
            //更新发送卡连线数据
            MyScreen.SenderConnectInfoList.Clear();
            ObservableCollection<PortConnectInfo> portConnectList = new ObservableCollection<PortConnectInfo>();
            for (int i = 0; i < CurrentSenderConfigInfo.PortCount; i++)
            {
                portConnectList.Add(new PortConnectInfo(i, 0, -1, null, null, new Rect()));
            }
            MyScreen.SenderConnectInfoList.Add(new SenderConnectInfo(0, portConnectList, new Rect()));

            #region 添加接收卡
            ObservableCollection<IElement> addCollection = new ObservableCollection<IElement>();
            Point pointInCanvas = new Point(0, 0);
            int cols = data.Cols;
            int rows = data.Rows;

            ScannerCofigInfo scanConfig = data.SelectedScannerConfigInfo;
            ScanBoardProperty scanBdProp = scanConfig.ScanBdProp;
            int width = scanBdProp.Width;
            int height = scanBdProp.Height;
            //每个网口行的整数倍和列的整数倍
            double rowIndex = -1;
            double colIndex = -1;
            //需要多少网口可以带载完
            Size portLoadPoint = Function.CalculatePortLoadSize(60, 24);
            double portLoadSize = portLoadPoint.Height * portLoadPoint.Width;
            //1、需要几个网口
            double portCount = Math.Ceiling(rows * cols / (portLoadSize / (height * width)));

            //2、计算每个网口的行列数(水平串线则是列的整数倍,垂直串线则是行的整数倍)
            while (true)
            {
                if (data.SelectedArrangeType == ArrangeType.LeftBottom_Hor
                    || data.SelectedArrangeType == ArrangeType.LeftTop_Hor
                    || data.SelectedArrangeType == ArrangeType.RightBottom_Hor
                    || data.SelectedArrangeType == ArrangeType.RightTop_Hor)//水平串线
                {
                    rowIndex = Math.Ceiling(rows * cols / portCount / cols);
                    if (rowIndex * cols * height * width > portLoadSize)
                    {
                        portCount += 1;
                        if (portCount > data.SelectedSenderConfigInfo.PortCount)
                        {
                            string msg = "";
                            CommonStaticMethod.GetLanguageString("超出带载,请重新设置!", "Lang_ScanBoardConfigManager_OverLoad", out msg);
                            ShowGlobalDialogMessage(msg, MessageBoxImage.Warning);
                            return;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    colIndex = Math.Ceiling(rows * cols / portCount / rows);
                    if (colIndex * rows * height * width > portLoadSize)
                    {
                        portCount += 1;
                        if (portCount > data.SelectedSenderConfigInfo.PortCount)
                        {
                            string msg = "";
                            CommonStaticMethod.GetLanguageString("超出带载,请重新设置!", "Lang_ScanBoardConfigManager_OverLoad", out msg);
                            ShowGlobalDialogMessage(msg, MessageBoxImage.Warning);
                            return;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            RectElement groupframe;
            if (cols == 1 && rows == 1)
            {
                groupframe = new RectElement(0, 0, width * cols, height * rows, null, -1);
                RectElement rectElement = new RectElement(0, 0, width * cols, height * rows, screen, screen.MaxZorder + 1);
                rectElement.EleType = ElementType.receive;
                screen.MaxZorder += 1;
                rectElement.Tag = scanConfig.Clone();
                rectElement.IsLocked = true;
                rectElement.ZIndex = 4;
                rectElement.GroupName = -1;
                rectElement.ElementSelectedState = SelectedState.None;
                rectElement.SenderIndex = 0;
                rectElement.PortIndex = 0;
                screen.ElementCollection.Add(rectElement);
                selectedElementCollection.Add(rectElement);
                addCollection.Add(rectElement);

            }
            else
            {
                for (int i = 0; i < cols; i++)
                {
                    for (int j = 0; j < rows; j++)
                    {
                        RectElement rectElement = new RectElement(width * i, height * j, width, height, screen, screen.MaxZorder + 1);
                        rectElement.EleType = ElementType.receive;
                        screen.MaxZorder += 1;
                        rectElement.Tag = scanConfig.Clone();
                        rectElement.IsLocked = true;
                        rectElement.ZIndex = 4;
                        rectElement.ElementSelectedState = SelectedState.None;
                        rectElement.SenderIndex = 0;
                        if (rowIndex != -1)
                        {
                            rectElement.PortIndex = (int)Math.Ceiling((j + 1) / rowIndex) - 1;
                        }
                        else if (colIndex != -1)
                        {
                            rectElement.PortIndex = (int)Math.Ceiling((i + 1) / colIndex) - 1;
                        }
                        screen.ElementCollection.Add(rectElement);
                        addCollection.Add(rectElement);
                        selectedElementCollection.Add(rectElement);

                    }
                }

            }

            ////记录添加
            //AddAction addAction = new AddAction(SelectedScreenLayer, addCollection);
            //SmartLCTActionManager.RecordAction(addAction);
            Dictionary<int, ObservableCollection<IRectElement>> eachPortElement = new Dictionary<int, ObservableCollection<IRectElement>>();
            for (int j = 0; j < portCount; j++)
            {
                eachPortElement.Add(j, new ObservableCollection<IRectElement>());
            }
            for (int i = 0; i < selectedElementCollection.Count; i++)
            {
                eachPortElement[selectedElementCollection[i].PortIndex].Add(selectedElementCollection[i]);
            }
            foreach (int key in eachPortElement.Keys)
            {
                if (eachPortElement[key].Count == 0)
                {
                    continue;
                }
                ScreenRealParameters screenRealPara = new ScreenRealParameters();
                screen.CurrentPortIndex = key;
                screen.CurrentSenderIndex = 0;
                screenRealPara.ScreenLayer = screen;
                screenRealPara.SelectedElement = eachPortElement[key];
                #region 每个网口添加组框
                Rect groupRect = new Rect();
                for (int i = 0; i < screenRealPara.SelectedElement.Count; i++)
                {
                    IRectElement rectElement = screenRealPara.SelectedElement[i];
                    rectElement.GroupName = screen.MaxGroupName + 1;
                    Rect rect = new Rect(rectElement.X, rectElement.Y, rectElement.Width, rectElement.Height);
                    if (i == 0)
                    {
                        groupRect = rect;
                    }
                    groupRect = Rect.Union(groupRect, rect);
                }
                groupframe = new RectElement(groupRect.X, groupRect.Y, groupRect.Width, groupRect.Height, screen, screen.MaxZorder + 1);
                groupframe.EleType = ElementType.groupframe;
                groupframe.ZIndex = 5;
                groupframe.GroupName = screen.MaxGroupName + 1;
                screen.MaxGroupName += 1;
                screen.MaxZorder += 1;
                groupframe.ElementSelectedState = SelectedState.SelectedAll;
                groupframeList.Add(groupframe.GroupName, groupframe);
                screen.ElementCollection.Add(groupframe);

                #endregion
                ScreenRealParametersValue = screenRealPara;
                SelectedArrangeType = data.SelectedArrangeType;
                IsConnectLine = !IsConnectLine;

            }
            #endregion
        }