public MainWindow_VM() { string msg = "显示屏连线配置"; CommonStaticMethod.GetLanguageString(msg, "Lang_ScrCfg_ScreenName", out msg); WindowRealTitle = msg; MyScreen.ElementCollection = MyScreen.ElementCollection; MyScreen.EleType = ElementType.baseScreen; MyScreen.OperateEnviron = OperatEnvironment.DesignScreen; if (!this.IsInDesignMode) { ScannerTypeCollection = _globalParams.ScannerConfigCollection; SenderConfigCollection = _globalParams.SenderConfigCollection; LangItemCollection = _globalParams.LangItemCollection; if (_globalParams.SenderConfigCollection != null && _globalParams.SenderConfigCollection.Count != 0) { CurrentSenderConfigInfo = _globalParams.SenderConfigCollection[0]; } else { SenderConfigInfo info = new SenderConfigInfo(); info.SenderTypeName = "MCTRL500"; info.PortCount = 4; CurrentSenderConfigInfo = info; } if (_globalParams.SenderAndPortPicCollection != null && _globalParams.SenderAndPortPicCollection.Count != 0) { SenderAndPortPicCollection = _globalParams.SenderAndPortPicCollection; } } else { LangItemCollection.Add(new LangItemData() { LangDisplayName = "中文", LangFlag = "zh-CN", IsSelected = false }); } if (!this.IsInDesignMode) { #region 初始化显示屏的发送卡信息 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())); #endregion SenderRealParametersValue = new SenderRealParameters(); SenderRealParametersValue.Element = new RectElement(); SenderRealParametersValue = SenderRealParametersValue; #region 注册消息 Messenger.Default.Register<SelectedLayerAndElement>(this, MsgToken.MSG_SELECTEDLAYERANDELEMENT_CHANGED, OnSelectedLayerAndElementChanged); Messenger.Default.Register<int>(this, MsgToken.MSG_INCREASEORDECREASEINDEX, OnIncreaseOrDecreaseIndexChanged); #endregion #region 显示屏 RectLayer myRectLayer3 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth + SmartLCTViewModeBase.ScrollWidth, SmartLCTViewModeBase.MaxScreenHeight + SmartLCTViewModeBase.ScrollWidth, MyScreen, 0, ElementType.baselayer, 0); myRectLayer3.OperateEnviron = OperatEnvironment.DesignScreen; RectLayer Layer3_sender1 = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, myRectLayer3, 3, ElementType.screen, 0); Layer3_sender1.OperateEnviron = OperatEnvironment.DesignScreen; myRectLayer3.ElementSelectedState = SelectedState.None; myRectLayer3.ElementCollection.Add(Layer3_sender1); MyScreen.ElementCollection.Add(myRectLayer3); SelectedScreenLayer = myRectLayer3; #endregion #region 显示屏映射 RectLayer screenLocationRectLayer = new RectLayer(0, 0, 2000 * 4, 1000 * 4, null, 0, ElementType.baselayer, 0); screenLocationRectLayer.OperateEnviron = OperatEnvironment.AdjustScreenLocation; ScreenLocationRectLayer = screenLocationRectLayer; #endregion #region 新建 RectLayer newLayer = new RectLayer(0, 0, SmartLCTViewModeBase.MaxScreenWidth, SmartLCTViewModeBase.MaxScreenHeight, MyScreen, -1, ElementType.newLayer, -1); MyScreen.ElementCollection.Add(newLayer); #endregion #region 定义命令执行函数 CmdNewWizard = new RelayCommand(OnCmdWizardProject); CmdNewEmptyProject = new RelayCommand(OnCmdNewEmptyProject); CmdNewLayer = new RelayCommand<RectLayer>(OnCmdNewLayer, CanCmdNewLayer); CmdMenuNewLayer = new RelayCommand(OnCmdMenuNewLayer); CmdDeleteLayer = new RelayCommand<IElement>(OnCmdDeleteLayer, CanCmdDeleteLayer); //CmdSaveSysConfigFile = new RelayCommand(OnCmdSaveSysConfigFile); CmdSaveSysConfigFile = new RelayCommand(OnOtherSaveSysConfigFile); CmdOtherSaveSysConfigFile = new RelayCommand(OnOtherSaveSysConfigFile); CmdOpenConfigFile = new RelayCommand(OnCmdOpenConfigFile); CmdClose = new RelayCommand(OnCmdClose); CmdExit = new RelayCommand<CancelEventArgs>(OnCmdExit); CmdSelectedTreeViewValueWithSender = new RelayCommand<SenderConnectInfo>(OnCmdSelectedTreeViewValueWithSender); CmdSelectedTreeViewValueWithPort = new RelayCommand<PortConnectInfo>(OnCmdSelectedTreeViewValueWithPort); CmdShowSystemCheckDlg = new RelayCommand(OnCmdShowSystemCheckDlg); CmdShowSendDisplayInfoDlg = new RelayCommand(OnCmdShowSendDisplayInfoDlg); CmdShowScanBoardConfigManager = new RelayCommand(OnCmdShowScanBoardConfigManager); CmdShowEDIDManager = new RelayCommand(OnCmdShowEDIDManager); CmdShowBrightAdjust = new RelayCommand(OnCmdShowBrightAdjust); CmdStartTestTool = new RelayCommand(OnCmdStartTestTool); CmdStartCalculator = new RelayCommand(OnCmdStartCalculator); CmdChangedSkin = new RelayCommand<SkinType>(OnCmdChangedSkin); CmdChangedLang = new RelayCommand<string>(OnCmdChangedLang); #endregion ScreenMapLocationVisible = Visibility.Collapsed; SenderVisible = Visibility.Collapsed; } }
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; } }
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; } }
/// <summary> /// 切换设计界面和调整映射位置界面 /// </summary> private void OnSelectedEnvironmentChanged() { List<int> senderIndexList = new List<int>(); int senderIndex; _oldSenderCount = _senderCount; int senderCount = Function.FindSenderCount(MyScreen.SenderConnectInfoList, out senderIndex); _senderCount = senderCount; if (_oldSenderCount != senderCount) { //发送卡个数更改,则map置为初始值 for (int i = 0; i < MyScreen.ElementCollection.Count; i++) { if (MyScreen.ElementCollection[i].EleType == ElementType.newLayer) { continue; } RectLayer screen = (RectLayer)((RectLayer)MyScreen.ElementCollection[i]).ElementCollection[0]; Function.InitMapLocation(screen); } } if (SelectedEnvironMentIndex == 0) { ScreenMapLocationVisible = Visibility.Collapsed; SenderVisible = Visibility.Collapsed; ScanVisible = Visibility.Collapsed; CustomScanVisible = Visibility.Collapsed; if (MyScreen!=null && MyScreen.ElementCollection!=null) { if (MyScreen.ElementCollection.Count <= 1) { ScreenVisible = Visibility.Collapsed; } else { ScreenVisible = Visibility.Visible; } } else { ScreenVisible = Visibility.Collapsed; } PleaseSelElmentVisible = Visibility.Hidden; } else if (SelectedEnvironMentIndex == 1) { //查看用了多少个发送卡 #region 单发送卡 if (senderCount == 0) { ScreenVisible = Visibility.Collapsed; ScanVisible = Visibility.Collapsed; CustomScanVisible = Visibility.Collapsed; PleaseSelElmentVisible = Visibility.Hidden; SenderVisible = Visibility.Collapsed; ScreenMapLocationVisible = Visibility.Collapsed; ScreenLocationRectLayer = new RectLayer(0, 0, SmartLCTViewModeBase.DviViewBoxWidth, SmartLCTViewModeBase.DviViewBoxHeight, null, 0, ElementType.baselayer, 0); } else if (senderCount == 1) { ScreenMapLocationVisible = Visibility.Visible; ScreenVisible = Visibility.Collapsed; ScanVisible = Visibility.Collapsed; CustomScanVisible = Visibility.Collapsed; PleaseSelElmentVisible = Visibility.Hidden; int selectedIndex = -1; for (int i = 0; i < ScreenMapRealParametersValue.RectLayerCollection.Count; i++) { if (ScreenMapRealParametersValue.RectLayerCollection[i].ElementSelectedState != SelectedState.None) { selectedIndex = ScreenMapRealParametersValue.RectLayerCollection[i].ConnectedIndex; break; } } #region 显示屏映射(测试界面数据) ScreenLocationRectLayer.ElementCollection.Clear(); RectLayer screenLocationRectLayer = new RectLayer(0, 0, SmartLCTViewModeBase.DviViewBoxWidth, SmartLCTViewModeBase.DviViewBoxHeight, null, 0, ElementType.baselayer, 0); screenLocationRectLayer.OperateEnviron = OperatEnvironment.AdjustScreenLocation; //显示屏移动区域的Layer(没有DVI则由发送卡最大带载决定) Size screenLayerSize = MyScreen.SenderConnectInfoList[senderIndex].DviSize; RectLayer screenBaseRectLayer = new RectLayer(0, 0, screenLayerSize.Width, screenLayerSize.Height, screenLocationRectLayer, 0, ElementType.screen, 0); screenBaseRectLayer.OperateEnviron = OperatEnvironment.AdjustScreenLocation; //由每个屏的发送卡带载生成各个显示屏带载 for (int i = 0; i < MyScreen.ElementCollection.Count; i++) { if (MyScreen.ElementCollection[i].ConnectedIndex < 0) { continue; } RectLayer screenRectLayer = ((RectLayer)(((RectLayer)MyScreen.ElementCollection[i]).ElementCollection[0])); Rect screenRect = screenRectLayer.SenderConnectInfoList[senderIndex].LoadSize; Point screenMapLocation = new Point(); for (int n = 0; n < screenRectLayer.SenderConnectInfoList[senderIndex].PortConnectInfoList.Count; n++) { if (screenRectLayer.SenderConnectInfoList[senderIndex].PortConnectInfoList[n].LoadSize.Width != 0 && screenRectLayer.SenderConnectInfoList[senderIndex].PortConnectInfoList[n].LoadSize.Height != 0) { screenMapLocation = screenRectLayer.SenderConnectInfoList[senderIndex].PortConnectInfoList[n].MapLocation; break; } } if (screenRect.Width == 0 || screenRect.Height == 0) { continue; } RectElement screen = new RectElement(screenMapLocation.X, screenMapLocation.Y, screenRect.Width, screenRect.Height, screenBaseRectLayer, i); screen.OperateEnviron = OperatEnvironment.AdjustScreenLocation; screen.ConnectedIndex = MyScreen.ElementCollection[i].ConnectedIndex; screen.Opacity = 0.5; string msg = ""; CommonStaticMethod.GetLanguageString("显示屏", "Lang_Global_Screen", out msg); screen.DisplayName = msg + (screen.ConnectedIndex + 1); screenBaseRectLayer.ElementCollection.Add(screen); } screenLocationRectLayer.ElementCollection.Add(screenBaseRectLayer); screenLocationRectLayer.SenderIndex = senderIndex; int increaseOrDecreaseIndex = GetIncreaseOrDecreaseIndex(senderIndex, ((RectLayer)screenLocationRectLayer.ElementCollection[0])); ((RectLayer)screenLocationRectLayer.ElementCollection[0]).IncreaseOrDecreaseIndex = increaseOrDecreaseIndex; Point newLocation=GetDviCenterPoint(increaseOrDecreaseIndex, ((RectLayer)screenLocationRectLayer.ElementCollection[0])); ((RectLayer)screenLocationRectLayer.ElementCollection[0]).X = newLocation.X; ((RectLayer)screenLocationRectLayer.ElementCollection[0]).Y = newLocation.Y; ScreenLocationRectLayer = screenLocationRectLayer; MyScreen.SenderConnectInfoList[senderIndex].IncreaseOrDecreaseIndex = increaseOrDecreaseIndex; MyScreen.SenderConnectInfoList[senderIndex].IsStatIncreaseOrDecreaseIndex = true; ScreenMapLocationVisible = Visibility.Visible; ScreenMapRealParameters p = new ScreenMapRealParameters(); p.SenderLoadRectLayer = screenBaseRectLayer; p.RectLayerCollection = screenBaseRectLayer.ElementCollection; p.RectLayerType = ElementType.screen; if (screenBaseRectLayer.ElementCollection.Count != 0) { if (selectedIndex != -1) { int realIndex = -1; for (int i = 0; i < screenBaseRectLayer.ElementCollection.Count; i++) { if (screenBaseRectLayer.ElementCollection[i].ConnectedIndex == selectedIndex) { realIndex = i; break; } } if (realIndex != -1) { SenderRealParameters senderRealPara = new SenderRealParameters(); senderRealPara.Element = (IRectElement)screenBaseRectLayer.ElementCollection[realIndex]; senderRealPara.Element.ElementSelectedState = SelectedState.Selected; senderRealPara.EleType = ElementType.screen; SenderRealParametersValue = senderRealPara; SenderVisible = Visibility.Visible; } else { SenderVisible = Visibility.Collapsed; } } else { SenderVisible = Visibility.Collapsed; } } else { SenderVisible = Visibility.Collapsed; } ScreenMapRealParametersValue = p; PleaseSelElmentVisible = Visibility.Hidden; #endregion } #endregion #region 多发送卡 else if (senderCount > 1) { #region 选中的网口 IRectElement selectedPort = new RectElement(); if (_currentScreen != null) { selectedPort.SenderIndex = _currentScreen.SenderIndex; selectedPort.PortIndex = _currentScreen.PortIndex; selectedPort.OperateEnviron = OperatEnvironment.AdjustSenderLocation; selectedPort.ConnectedIndex = _currentScreen.ConnectedIndex; } if (selectedPort.SenderIndex >= 0 && selectedPort.PortIndex < 0) { RectLayer screenLayer = (RectLayer)((RectLayer)MyScreen.ElementCollection[selectedPort.ConnectedIndex]).ElementCollection[0]; ObservableCollection<PortConnectInfo> portConnectInfoList = screenLayer.SenderConnectInfoList[selectedPort.SenderIndex].PortConnectInfoList; for (int m = 0; m < portConnectInfoList.Count; m++) { if (portConnectInfoList[m].LoadSize.Height == 0 && portConnectInfoList[m].LoadSize.Width == 0) { continue; } selectedPort.PortIndex = m; break; } } else if (selectedPort.SenderIndex < 0 && selectedPort.PortIndex < 0) { for (int i = 0; i < MyScreen.ElementCollection.Count; i++) { if (selectedPort.SenderIndex >= 0 && selectedPort.PortIndex >= 0) { break; } if (MyScreen.ElementCollection[i].EleType == ElementType.newLayer) { continue; } RectLayer screenLayer = (RectLayer)((RectLayer)MyScreen.ElementCollection[i]).ElementCollection[0]; for (int j = 0; j < screenLayer.SenderConnectInfoList.Count; j++) { if (selectedPort.SenderIndex >= 0 && selectedPort.PortIndex >= 0) { break; } if (screenLayer.SenderConnectInfoList[j].LoadSize.Height == 0 && screenLayer.SenderConnectInfoList[j].LoadSize.Width == 0) { continue; } ObservableCollection<PortConnectInfo> portConnectInfoList = screenLayer.SenderConnectInfoList[j].PortConnectInfoList; for (int m = 0; m < portConnectInfoList.Count; m++) { if (portConnectInfoList[m].LoadSize.Height == 0 && portConnectInfoList[m].LoadSize.Width == 0) { continue; } selectedPort = new RectElement(); selectedPort.ConnectedIndex = i; selectedPort.SenderIndex = j; selectedPort.PortIndex = m; break; } } } } #endregion ScreenMapLocationVisible = Visibility.Visible; ScreenVisible = Visibility.Collapsed; ScanVisible = Visibility.Collapsed; CustomScanVisible = Visibility.Collapsed; PleaseSelElmentVisible = Visibility.Hidden; #region 全部发送卡的带载(用于缩略图的大小) Rect senderLoadSizeSum = new Rect(); for (int i = 0; i < MyScreen.SenderConnectInfoList.Count; i++) { if (MyScreen.SenderConnectInfoList[i].LoadSize.Height == 0 && MyScreen.SenderConnectInfoList[i].LoadSize.Width == 0) { continue; } if (senderLoadSizeSum == new Rect()) { senderLoadSizeSum = MyScreen.SenderConnectInfoList[i].LoadSize; } else { senderLoadSizeSum = Rect.Union(senderLoadSizeSum, MyScreen.SenderConnectInfoList[i].LoadSize); } } #endregion #region 缩略图数据 RectLayer senderMapRectLayer = new RectLayer(0, 0, senderLoadSizeSum.Width, senderLoadSizeSum.Height, null, 0, ElementType.baselayer, 0); senderMapRectLayer.OperateEnviron = OperatEnvironment.AdjustSenderLocation; RectLayer screenBaseRectLayer = new RectLayer(0, 0, senderLoadSizeSum.Width, senderLoadSizeSum.Height, senderMapRectLayer, 0, ElementType.screen, 0); screenBaseRectLayer.OperateEnviron = OperatEnvironment.AdjustSenderLocation; //每个发送卡在所有显示屏中的网口带载 生成显示屏(缩略图中显示所有发送卡的网口) for (int m = 0; m < MyScreen.SenderConnectInfoList.Count; m++) { //发送卡m在所有显示屏中的网口带载 for (int i = 0; i < MyScreen.ElementCollection.Count; i++) { if (MyScreen.ElementCollection[i].EleType == ElementType.newLayer) { continue; } RectLayer screenLayer = (RectLayer)((RectLayer)MyScreen.ElementCollection[i]).ElementCollection[0]; if (screenLayer.SenderConnectInfoList[m].LoadSize.Width == 0 && screenLayer.SenderConnectInfoList[m].LoadSize.Height == 0) { continue; } Rect senderLoadSize = screenLayer.SenderConnectInfoList[m].LoadSize; ObservableCollection<PortConnectInfo> portConnectInfoList = screenLayer.SenderConnectInfoList[m].PortConnectInfoList; ObservableCollection<IRectElement> portScreenCollection = new ObservableCollection<IRectElement>(); for (int n = 0; n < portConnectInfoList.Count; n++) { Rect portRect = portConnectInfoList[n].LoadSize; if (portRect.Width == 0 && portRect.Height == 0) { continue; } Point portMapLocation = portConnectInfoList[n].MapLocation; RectElement portScreen = new RectElement(portRect.X - senderLoadSize.X + portMapLocation.X, portRect.Y - senderLoadSize.Y + portMapLocation.Y, portRect.Width, portRect.Height, screenBaseRectLayer, screenBaseRectLayer.MaxZorder + 1); screenBaseRectLayer.MaxZorder += 1; portScreen.OperateEnviron = OperatEnvironment.AdjustSenderLocation; portScreen.ConnectedIndex = MyScreen.ElementCollection[i].ConnectedIndex; portScreen.SenderIndex = m; portScreen.PortIndex = portConnectInfoList[n].PortIndex; portScreen.DisplayName = GetMultiSenderDisplayString(portScreen.ConnectedIndex + 1, portScreen.SenderIndex + 1, portScreen.PortIndex + 1); screenBaseRectLayer.ElementCollection.Add(portScreen); portScreenCollection.Add(portScreen); } //一个显示屏使用了一个发送卡的多个网口,则生成的带载显示屏成为一个组(因为一个屏里一个发送卡的网口之间的相对位置是有效的) if (portScreenCollection.Count > 1) { Rect groupRect = Function.UnionRectCollection(portScreenCollection); RectElement groupElement = new RectElement(groupRect.X, groupRect.Y, groupRect.Width, groupRect.Height, screenBaseRectLayer, screenBaseRectLayer.MaxZorder + 1); screenBaseRectLayer.MaxZorder += 1; groupElement.EleType = ElementType.groupframe; groupElement.GroupName = screenBaseRectLayer.MaxGroupName + 1; screenBaseRectLayer.MaxGroupName += 1; groupElement.OperateEnviron = OperatEnvironment.DesignScreen; groupElement.ConnectedIndex = MyScreen.ElementCollection[i].ConnectedIndex; groupElement.SenderIndex = m; screenBaseRectLayer.ElementCollection.Add(groupElement); for (int j = 0; j < portScreenCollection.Count; j++) { portScreenCollection[j].GroupName = groupElement.GroupName; } } } } senderMapRectLayer.ElementCollection.Add(screenBaseRectLayer); SenderVisible = Visibility.Visible; #endregion #region 选中网口 RectElement currentSelectedScreen = new RectElement(); Size sender1LoadSize = MyScreen.SenderConnectInfoList[selectedPort.SenderIndex].DviSize; ScreenLocationRectLayer.ElementCollection.Clear(); RectLayer screenLocationRectLayer = new RectLayer(0, 0, SmartLCTViewModeBase.DviViewBoxWidth, SmartLCTViewModeBase.DviViewBoxHeight, null, 0, ElementType.baselayer, -1); screenLocationRectLayer.OperateEnviron = OperatEnvironment.AdjustSenderLocation; RectLayer screenBaseloaRectLayer = new RectLayer(0, 0, sender1LoadSize.Width, sender1LoadSize.Height, screenLocationRectLayer, 0, ElementType.screen, -1); screenBaseloaRectLayer.OperateEnviron = OperatEnvironment.AdjustSenderLocation; ObservableCollection<IRectElement> portCollection = new ObservableCollection<IRectElement>(); for (int j = 0; j < screenBaseRectLayer.ElementCollection.Count; j++) { IRectElement currentPortScreen = (IRectElement)screenBaseRectLayer.ElementCollection[j]; if (currentPortScreen.PortIndex < 0) { continue; } if (currentPortScreen.SenderIndex == selectedPort.SenderIndex && currentPortScreen.PortIndex == selectedPort.PortIndex) { RectLayer currentScreen = (RectLayer)((RectLayer)MyScreen.ElementCollection[currentPortScreen.ConnectedIndex]).ElementCollection[0]; RectElement e = (RectElement)((RectElement)screenBaseRectLayer.ElementCollection[j]).Clone(); e.ParentElement = screenBaseloaRectLayer; screenBaseRectLayer.ElementCollection[j].ElementSelectedState = SelectedState.Selected; e.ElementSelectedState = SelectedState.Selected; e.EleType = ElementType.receive; e.DisplayName = GetMultiSenderDisplayString(e.ConnectedIndex + 1, e.SenderIndex + 1, e.PortIndex + 1); screenBaseloaRectLayer.ElementCollection.Add(e); portCollection.Add(e); SenderRealParameters senderRealPara = new SenderRealParameters(); senderRealPara.Element = e; senderRealPara.EleType = ElementType.port; SenderRealParametersValue = senderRealPara; //网口基本信息 currentSelectedScreen = e; } else if (currentPortScreen.SenderIndex == selectedPort.SenderIndex) { RectLayer currentScreen = (RectLayer)((RectLayer)MyScreen.ElementCollection[currentPortScreen.ConnectedIndex]).ElementCollection[0]; RectElement e = (RectElement)((RectElement)screenBaseRectLayer.ElementCollection[j]).Clone(); e.ParentElement = screenBaseloaRectLayer; e.EleType = ElementType.receive; e.DisplayName = GetMultiSenderDisplayString(e.ConnectedIndex + 1, e.SenderIndex + 1, e.PortIndex + 1); screenBaseloaRectLayer.ElementCollection.Add(e); } } for (int m = 0; m < screenBaseRectLayer.ElementCollection.Count; m++) { if (screenBaseRectLayer.ElementCollection[m].EleType == ElementType.groupframe) { ObservableCollection<IRectElement> portList = new ObservableCollection<IRectElement>(); for (int j = 0; j < screenBaseloaRectLayer.ElementCollection.Count; j++) { //同一个屏下面的同一张发送卡下的网口用组框框起来 if (((IRectElement)screenBaseloaRectLayer.ElementCollection[j]).ConnectedIndex == screenBaseRectLayer.ElementCollection[m].ConnectedIndex && ((IRectElement)screenBaseloaRectLayer.ElementCollection[j]).SenderIndex == ((IRectElement)screenBaseRectLayer.ElementCollection[m]).SenderIndex) { portList.Add((IRectElement)screenBaseloaRectLayer.ElementCollection[j]); } } if (portList.Count < 2) { continue; } Rect groupRect = Function.UnionRectCollection(portList); RectElement groupElement = (RectElement)((RectElement)screenBaseRectLayer.ElementCollection[m]).Clone(); groupElement.X = groupRect.X; groupElement.Y = groupRect.Y; groupElement.Width = groupRect.Width; groupElement.Height = groupRect.Height; groupElement.ParentElement = screenBaseloaRectLayer; screenBaseloaRectLayer.ElementCollection.Add(groupElement); } } screenLocationRectLayer.ElementCollection.Add(screenBaseloaRectLayer); screenLocationRectLayer.SenderIndex = selectedPort.SenderIndex; int increaseOrDecreaseIndex = GetIncreaseOrDecreaseIndex(selectedPort.SenderIndex, ((RectLayer)screenLocationRectLayer.ElementCollection[0])); ((RectLayer)screenLocationRectLayer.ElementCollection[0]).IncreaseOrDecreaseIndex = increaseOrDecreaseIndex; Point newLocation = GetDviCenterPoint(increaseOrDecreaseIndex, ((RectLayer)screenLocationRectLayer.ElementCollection[0])); ((RectLayer)screenLocationRectLayer.ElementCollection[0]).X = newLocation.X; ((RectLayer)screenLocationRectLayer.ElementCollection[0]).Y = newLocation.Y; ScreenLocationRectLayer = screenLocationRectLayer; MyScreen.SenderConnectInfoList[selectedPort.SenderIndex].IncreaseOrDecreaseIndex = increaseOrDecreaseIndex; MyScreen.SenderConnectInfoList[selectedPort.SenderIndex].IsStatIncreaseOrDecreaseIndex = true; ScreenMapRealParameters p = new ScreenMapRealParameters(); p.SenderLoadRectLayer = screenBaseloaRectLayer; p.RectLayerCollection = screenBaseRectLayer.ElementCollection; p.RectLayerType = ElementType.sender; ScreenMapRealParametersValue = p; CurrentScreen = currentSelectedScreen; #endregion PleaseSelElmentVisible = Visibility.Hidden; } //开始设置映射位置 for (int i = 0; i < MyScreen.ElementCollection.Count; i++) { if (MyScreen.ElementCollection[i].EleType == ElementType.newLayer) { continue; } RectLayer screenlayer = (RectLayer)((RectLayer)MyScreen.ElementCollection[i]).ElementCollection[0]; } #endregion Function.UpdateSenderConnectInfo(MyScreen.SenderConnectInfoList, MyScreen); } }
private void IniSendCard() { 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())); SenderRealParametersValue = new SenderRealParameters(); SenderRealParametersValue.Element = new RectElement(); SenderRealParametersValue = SenderRealParametersValue; }