private void EnableBtnClick(object sender, RoutedEventArgs e)
        {
            switch (this.enableBtn.Content)
            {
            case "启用":
            case "更新":
                if (!UpdatePresentChannelInfo())
                {
                    break;
                }

                //启用或更新端口
                if (this.session != null)
                {
                    this.session.SetVirtualChannel(presentChannel.channelKey, presentChannel.vc);
                }
                break;

            case "删除":
                //删除指定的端口
                this.fileList.Items.Remove(presentChannel.tb);
                if (this.session != null)
                {
                    this.session.SetVirtualChannel(presentChannel.channelKey, null);
                }
                virtualChannels.Remove(presentChannel);

                if (virtualChannels.Count() == 0)
                {
                    presentChannel           = null;
                    this.codeTextBox.Text    = "";
                    this.fileName.Text       = "";
                    this.enableBtn.Content   = "启用";
                    this.enableBtn.IsEnabled = false;
                    this.buildBtn.IsEnabled  = false;
                }
                else
                {
                    this.presentChannel        = virtualChannels[0];
                    this.codeTextBox.Text      = this.presentChannel.channelName;
                    this.fileName.Text         = this.presentChannel.channelName;
                    this.enableBtn.Content     = "更新";
                    this.fileList.SelectedItem = presentChannel.tb;
                }
                break;
            }
        }
        private void ChannelChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.fileList.SelectedIndex == -1)
            {
                return;
            }

            TextBlock sTb = (TextBlock)this.fileList.SelectedItems[0];

            this.fileName.Text      = sTb.Text;
            this.buildBtn.IsEnabled = true;

            for (int i = 0; i < virtualChannels.Count(); i++)
            {
                if (virtualChannels[i].channelName.CompareTo(sTb.Text) == 0)
                {
                    VirtualChannelInfo cv = virtualChannels[i];
                    this.presentChannel   = cv;
                    this.codeTextBox.Text = cv.presentCode;
                    if (cv.presentCode.CompareTo(cv.lastUsableCode) == 0)
                    {
                        this.enableBtn.Content = "删除";
                    }
                    else
                    {
                        if (cv.lastUsableCode == null)
                        {
                            this.enableBtn.Content = "启用";
                        }
                        else
                        {
                            this.enableBtn.Content = "更新";
                        }
                    }
                    break;
                }
            }
            this.enableBtn.IsEnabled = true;
        }
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < virtualChannels.Count(); i++)
            {
                if (virtualChannels[i].channelName.CompareTo("NewChannel") == 0)
                {
                    MessageBox.Show("当前已有一个名为 NewChannel 的通道");
                    return;
                }
            }

            TextBlock tb = new TextBlock();

            tb.Text = "NewChannel";

            VirtualChannelInfo nvc = new VirtualChannelInfo();

            nvc.channelName = "NewChannel";
            nvc.channelKey  = System.Guid.NewGuid().ToString();
            nvc.tb          = tb;
            virtualChannels.Add(nvc);

            this.fileList.Items.Add(tb);
        }