private void AddPortIndex(int portIndex)
        {
            if (_portCanvas == null)
            {
                return; 
            }
            ToggleButton togBut = new ToggleButton();
            togBut.Width = 30;
            togBut.Height = 30;
            togBut.Content = (portIndex + 1).ToString();
            togBut.Command = new RelayCommand<ToggleButton>(OnToggleButtonWithPortCmd);
            togBut.SetResourceReference(ToggleButton.StyleProperty, "MyToggleButtonStyle");
            
            togBut.CommandParameter = togBut;
            Thickness margin = new Thickness();
            margin.Left = 10 + (togBut.Width + 15) * portIndex;
            margin.Top = 15;
            togBut.Margin = margin;

            //给网口加载图片
            int senderIndex =ScreenRealParams.ScreenLayer.CurrentSenderIndex;
            if (senderIndex == -1)
            {
                senderIndex = 0;
            }
            int colorIndex = 4 * senderIndex + portIndex+1;
            if (SenderAndPortPicCollection != null && SenderAndPortPicCollection.Count != 0)
            {
                if (!SenderAndPortPicCollection.Keys.Contains(colorIndex))
                {
                    colorIndex = 0;
                }
                ImageBrush imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri(SenderAndPortPicCollection[colorIndex].NoSelectedPicPath, UriKind.Absolute));
                imageBrush.Stretch = Stretch.Fill;//设置图像的显示格式
                togBut.Background = imageBrush;
            }

            _portCanvas.Children.Add(togBut);
        }
        private void AddSenderIndex(int senderIndex)
        {
            if (_senderCanvas == null)
            {
                return;
            }
            ToggleButton togBut = new ToggleButton();
            togBut.Width = 35;
            togBut.Height = 35;
            togBut.Content = (senderIndex + 1).ToString();
            togBut.Command = new RelayCommand<ToggleButton>(OnToggleButtonWithSenderCmd);
            togBut.SetResourceReference(ToggleButton.StyleProperty, "MyToggleButtonStyle");
            togBut.CommandParameter = togBut;
            Thickness margin = new Thickness();

            int iColumnNum = senderIndex / 5;
            int iRowNum = senderIndex%5;
            margin.Left = 10 + (togBut.Width + 15) * iRowNum;
            margin.Top = 15 + 35 * iColumnNum;
            //if (senderIndex < 5)
            //{
            //    margin.Left = 10 + (togBut.Width + 15) * senderIndex;
            //    margin.Top = 15;
            //}
            //else
            //{
            //    margin.Left = 10 + (togBut.Width + 15) * (senderIndex - 5);
            //    margin.Top = 50;
            //}

            togBut.Margin = margin;

            if (SenderAndPortPicCollection != null && SenderAndPortPicCollection.Count != 0)
            {
                ImageBrush imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri(SenderAndPortPicCollection[0].NoSelectedPicPath, UriKind.Absolute));
                imageBrush.Stretch = Stretch.Fill;//设置图像的显示格式
                togBut.Background = imageBrush;
            }   


            _senderCanvas.Children.Add(togBut);
            //int oldPortIndex = -1;
            //ClearPortIndex(out oldPortIndex);
            //for (int index = 0; index < CurrentSenderConfigInfo.PortCount; index++)
            //{
            //    AddPortIndex(index);
            //}
            //_currentPortIndex = oldPortIndex;
            //ScreenRealParams.ScreenLayer.CurrentPortIndex = _currentPortIndex;
        }