Пример #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;
            }
        }
Пример #2
0
        public Window2_VM()
        {
            CmdTest = new RelayCommand(OnCmdTest);
            RectLayer layer = new RectLayer(20, 30, 100, 110, new RectLayer(), 0, ElementType.None,0);
            
            SenderRealParameters rp = new SenderRealParameters();
            rp.Element = layer;
            MyRectLayer = rp;
            if (!this.IsInDesignMode)
            {
                ScannerTypeCollection.Add(new ScannerCofigInfo() { DisplayName = "aa", ScanBdProp = new ScanBoardProperty() });
                ScannerTypeCollection.Add(new ScannerCofigInfo() { DisplayName = "bb", ScanBdProp = new ScanBoardProperty() });

                PortRealParameters param = new PortRealParameters();
                RectLayer rectLayer = new RectLayer();

                SelectedElementCollection = new ObservableCollection<IRectElement>();

                RectElement element = new RectElement(0, 0, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                element = new RectElement(15, 20, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                element = new RectElement(18, 20, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                element = new RectElement(0, 60, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                element = new RectElement(30, 0, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                element = new RectElement(30, 60, 10, 10, rectLayer, 0);
                rectLayer.ElementCollection.Add(element);
                SelectedElementCollection.Add(element);

                param.PortLayer = rectLayer;
                PortRealParams = param;


                PortRealParams.SelectedElementCollection = SelectedElementCollection;


                rectLayer = new RectLayer();
                ScannerRealParameters scanParam = new ScannerRealParameters();
                scanParam.ScannerElement = new RectElement(30, 60, 10, 10, rectLayer, 0);
                scanParam.ScannerConfig = new ScannerCofigInfo() { DisplayName = "aa", ScanBdProp = new ScanBoardProperty() };
                ScannerRealParams = scanParam;
            }
        }