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);
                    }
                }
            }
            
            
        }
Example #2
0
        private void OnSenderConnectInfoCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                #region 添加
                IElement layer = this;
                while (layer != null && layer.EleType != ElementType.baseScreen)
                {
                    layer = layer.ParentElement;
                }
                if (layer == null)
                {
                    return;
                }
                ObservableCollection<SenderConnectInfo> newdata = new ObservableCollection<SenderConnectInfo>();
                int portCount = 0;

                for (int i = 0; i < e.NewItems.Count; i++)
                {

                    ObservableCollection<PortConnectInfo> portList = new ObservableCollection<PortConnectInfo>();
                    SenderConnectInfo info = e.NewItems[i] as SenderConnectInfo;
                    portCount = info.PortConnectInfoList.Count;
                    for (int j = 0; j < info.PortConnectInfoList.Count; j++)
                    {
                        portList.Add(new PortConnectInfo(info.PortConnectInfoList[j].PortIndex, info.SenderIndex, - 1, null, null, new Rect()));
                    }
                    SenderConnectInfo newInfo = new SenderConnectInfo(info.SenderIndex, portList, new Rect());

                    newdata.Add(newInfo);
                }
                RectLayer myScreen = (RectLayer)layer;
                if (EleType == ElementType.screen)
                {
                    for (int i = 0; i < newdata.Count; i++)
                    {
                        bool ishave = false;
                        for (int n = 0; n < myScreen.SenderConnectInfoList.Count; n++)
                        {
                            if (myScreen.SenderConnectInfoList[n].SenderIndex == newdata[i].SenderIndex)
                            {
                                ishave = true;
                                break;
                            }
                        }
                        if (!ishave && myScreen.SenderConnectInfoList.Count != SenderConnectInfoList.Count)
                        {

                            myScreen.SenderConnectInfoList.Add(newdata[i]);
                        }
                    }
                    for (int i = 0; i < myScreen.ElementCollection.Count; i++)
                    {
                        if (myScreen.ElementCollection[i].EleType == ElementType.newLayer)
                        {
                            continue;
                        }
                        for (int j = 0; j < newdata.Count; j++)
                        {

                            if (((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Count == SenderConnectInfoList.Count)
                            {
                                continue;
                            }
                            bool ishave = false;
                            for (int n = 0; n < ((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Count; n++)
                            {
                                if (((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList[n].SenderIndex == newdata[j].SenderIndex)
                                {
                                    ishave = true;
                                    break;
                                }
                            }
                            if (!ishave)
                                ((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Add(newdata[j]);
                        }
                    }
                }
                else if (EleType == ElementType.baseScreen)
                {
                    for (int i = 0; i < myScreen.ElementCollection.Count; i++)
                    {
                        if (myScreen.ElementCollection[i].EleType == ElementType.newLayer)
                        {
                            continue;
                        }
                        for (int j = 0; j < newdata.Count; j++)
                        {
                            if (((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Count == SenderConnectInfoList.Count)
                            {
                                continue;
                            }
                            bool ishave = false;
                            for (int n = 0; n < ((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Count; n++)
                            {
                                if (((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList[n].SenderIndex == newdata[j].SenderIndex)
                                {
                                    ishave = true;
                                    break;
                                }
                            }
                            if (!ishave)
                                ((RectLayer)((RectLayer)myScreen.ElementCollection[i]).ElementCollection[0]).SenderConnectInfoList.Add(newdata[j]);
                        }
                    }
                }
                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                #region 移除
                IElement removeElement = this;
                if (EleType != ElementType.baseScreen)
                {
                    return;
                }

                RectLayer removeLayer=(RectLayer)removeElement;

                    for (int i = 0; i < removeLayer.ElementCollection.Count; i++)
                    {
                        if (removeLayer.ElementCollection[i].EleType == ElementType.newLayer)
                        {
                            continue;
                        }
                        RectLayer reLayer = (RectLayer)((RectLayer)removeLayer.ElementCollection[i]).ElementCollection[0];
                        for (int m = 0; m < reLayer.SenderConnectInfoList.Count; m++)
                        {
                            if (reLayer.SenderConnectInfoList[m].SenderIndex == CurrentSenderIndex)
                            {
                                UpdateSenderConnectInfo(reLayer, reLayer.SenderConnectInfoList[m]);

                                reLayer.SenderConnectInfoList.RemoveAt(m);

                                break;
                            }
                        }
                        for (int m = 0; m < reLayer.SenderConnectInfoList.Count; m++)
                        {
                            if (reLayer.SenderConnectInfoList[m].SenderIndex > CurrentSenderIndex)
                            {
                                //有连线的接收卡connectIndex-1;
                                for (int n = 0; n < reLayer.SenderConnectInfoList[m].PortConnectInfoList.Count; n++)
                                {
                                    ObservableCollection<IRectElement> connectElementList = reLayer.SenderConnectInfoList[m].PortConnectInfoList[n].ConnectLineElementList;
                                    if (connectElementList == null)
                                    {
                                        continue;
                                    }
                                    for (int u = 0; u < connectElementList.Count; u++)
                                    {
                                        connectElementList[u].SenderIndex -= 1;
                                    }
                                }
                                reLayer.SenderConnectInfoList[m].SenderIndex -= 1;
                            }
                        }
                    }
                #endregion
                NotifyPropertyChanged(GetPropertyName(o => this.ElementCollection));
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                #region 修改
                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                #region 重置

                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Move)
            {

            }
        }
Example #3
0
        private void UpdateSenderConnectInfo(RectLayer layer,SenderConnectInfo senderConnectInfo)
        {
            senderConnectInfo.IsExpand = false;
            senderConnectInfo.IsSelected = false;
            for (int m = 0; m < senderConnectInfo.PortConnectInfoList.Count; m++)
            {
                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].IsSelected = false;
            }
        }
        private void OnElementCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
        {

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                #region 添加
                IElement newElement = (IElement)e.NewItems[0];
                //if (newElement.GetType().BaseType == typeof(ILineElement))
                //{
                //    Debug.WriteLine("--------------YES------------");
                //}

                if (EleType == ElementType.baseScreen && newElement.EleType == ElementType.baselayer)
                {
                    RectLayer newLayer = (RectLayer)((RectLayer)newElement).ElementCollection[0];
                    ObservableCollection<SenderConnectInfo> senderInfoList = new ObservableCollection<SenderConnectInfo>();
                    for (int i = 0; i < SenderConnectInfoList.Count; i++)
                    {
                        ObservableCollection<PortConnectInfo> portConnectList = SenderConnectInfoList[i].PortConnectInfoList;
                        ObservableCollection<PortConnectInfo> newportConnectList = new ObservableCollection<PortConnectInfo>();
                        for (int j = 0; j < portConnectList.Count; j++)
                        {
                            newportConnectList.Add(new PortConnectInfo(portConnectList[j].PortIndex, SenderConnectInfoList[i].SenderIndex ,- 1, null, null, new Rect()));
                        }
                        SenderConnectInfo newsenderConnectInfo = new SenderConnectInfo(SenderConnectInfoList[i].SenderIndex, newportConnectList, new Rect());
                        senderInfoList.Add(newsenderConnectInfo);
                    }
                    newLayer.SenderConnectInfoList = senderInfoList;
                }
                #endregion
                if (EleType == ElementType.screen)
                {
                    #region 更新带载区域信息
                    Function.UpdateSenderConnectInfo(SenderConnectInfoList, this);
                    #endregion
                }  
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                #region 移除
                //var elements = sender as ObservableCollection<IElement>;
                //var result = elements.Any(element => element.GetType().BaseType == typeof(ILineElement));
                //if (result)
                //{
                //    Debug.WriteLine("--------------YES------------");
                //}
                //else
                //{
                //    Debug.WriteLine("--------------NO------------");
                //}
                #endregion
                NotifyPropertyChanged(GetPropertyName(o => this.ElementCollection));
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                #region 修改
                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                #region 重置

                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Move)
            {

            }

        }
Example #5
0
        private void OnElementCollectionChange(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                #region 添加
                IElement newElement = (IElement)e.NewItems[0];
                if (EleType == ElementType.baseScreen && newElement.EleType == ElementType.baselayer)
                {
                    RectLayer newLayer = (RectLayer)((RectLayer)newElement).ElementCollection[0];
                    ObservableCollection<SenderConnectInfo> senderInfoList = new ObservableCollection<SenderConnectInfo>();
                    for (int i = 0; i < SenderConnectInfoList.Count; i++)
                    {
                        ObservableCollection<PortConnectInfo> portConnectList = SenderConnectInfoList[i].PortConnectInfoList;
                        ObservableCollection<PortConnectInfo> newportConnectList = new ObservableCollection<PortConnectInfo>();
                        for (int j = 0; j < portConnectList.Count; j++)
                        {
                            newportConnectList.Add(new PortConnectInfo(portConnectList[j].PortIndex, SenderConnectInfoList[i].SenderIndex ,- 1, null, null, new Rect()));
                        }
                        SenderConnectInfo newsenderConnectInfo = new SenderConnectInfo(SenderConnectInfoList[i].SenderIndex, newportConnectList, new Rect());
                        senderInfoList.Add(newsenderConnectInfo);
                    }
                    newLayer.SenderConnectInfoList = senderInfoList;
                }
                #endregion
                if (EleType == ElementType.screen)
                {
                    #region 更新带载区域信息
                    Function.UpdateSenderConnectInfo(SenderConnectInfoList, this);
                    #endregion
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                #region 移除

                #endregion
                NotifyPropertyChanged(GetPropertyName(o => this.ElementCollection));
            }
            else if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                #region 修改
                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                #region 重置

                #endregion
            }
            else if (e.Action == NotifyCollectionChangedAction.Move)
            {

            }
        }
Example #6
0
        private void OnCmdSelectedTreeViewValueWithSender(SenderConnectInfo senderInfo)
        {
            if (IsAddingReceive)
            {
                return;
            }
            Function.SetElementCollectionState(SelectedScreenLayer.ElementCollection, SelectedState.None);
            if (SelectedScreenLayer != null && SelectedScreenLayer.SenderConnectInfoList != null && SelectedScreenLayer.SenderConnectInfoList.Count != 0)
            {
                SenderConnectInfo senderConnectInfo = SelectedScreenLayer.SenderConnectInfoList[senderInfo.SenderIndex];
                for (int i = 0; i < senderConnectInfo.PortConnectInfoList.Count; i++)
                {
                    senderInfo.IsSelected = true;

                    Function.SetElementCollectionState(senderConnectInfo.PortConnectInfoList[i].ConnectLineElementList, SelectedState.Selected);

                }
            }
        }
Example #7
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;
        }
Example #8
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;
                }
            }
        }
 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 OnAddSenderIndex()
 {
     List<int> senderIndexList = new List<int>();
     int addSenderIndex = -1;
     for (int senderIndex = 0; senderIndex < ScreenRealParams.ScreenLayer.SenderConnectInfoList.Count; senderIndex++)
     {
         senderIndexList.Add(ScreenRealParams.ScreenLayer.SenderConnectInfoList[senderIndex].SenderIndex);
     }
     if (senderIndexList.Count != 0)
     {
         senderIndexList.Sort(delegate(int first, int second)
         {
             return first.CompareTo(second);
         });
         addSenderIndex = senderIndexList[senderIndexList.Count - 1] + 1;
     }
     else
     {
         addSenderIndex = 0;
     }
     SenderConnectInfo senderConnectInfo = new SenderConnectInfo();
     ObservableCollection<PortConnectInfo> portConnectList = new ObservableCollection<PortConnectInfo>();
     for (int i = 0; i < CurrentSenderConfigInfo.PortCount; i++)
     {
         portConnectList.Add(new PortConnectInfo(i, addSenderIndex, - 1, null, null, new Rect()));
     }
     senderConnectInfo.SenderIndex = addSenderIndex;
     senderConnectInfo.PortConnectInfoList = portConnectList;
     ScreenRealParams.ScreenLayer.SenderConnectInfoList.Insert(addSenderIndex,senderConnectInfo);
     AddSenderIndex(addSenderIndex);
     SetSenderTogButSelectedState(_senderCanvas, addSenderIndex);
     ScreenRealParams.ScreenLayer.CurrentSenderIndex = addSenderIndex;
     ScreenRealParams.ScreenLayer.CurrentPortIndex = 0;
     SetPortTogButSelectedState(_portCanvas, 0);
     ScreenRealParams.ScreenLayer.CurrentPortIndex = ScreenRealParams.ScreenLayer.CurrentPortIndex;
     ScreenRealParams.ScreenLayer.CurrentSenderIndex = ScreenRealParams.ScreenLayer.CurrentSenderIndex;
 }