Sockets PowerShell GUI观察多个套接字连接

Sockets PowerShell GUI观察多个套接字连接,sockets,powershell,user-interface,Sockets,Powershell,User Interface,我发现很多例子都很长,但我认为可以用更短的方式完成 我需要一个GUI,它可以显示和启用我需要adimn的多个套接字连接选项 一开始我想我有: # Load external assemblies [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")

我发现很多例子都很长,但我认为可以用更短的方式完成

我需要一个GUI,它可以显示和启用我需要adimn的多个套接字连接选项

一开始我想我有:

    # Load external assemblies
    [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing")
            $OnLoadForm_StateCorrection = {
                $form1.WindowState = $InitialFormWindowState
            }

    $myGUI   = New-Object System.Windows.Forms.Form
    $myGUI.Text = "Socket-Traffic"
    $myGUI.Name = "myGUI"
    $myGUI.DataBindings.DefaultDataSourceUpdateMode = 0
    $myGUI.ForeColor = [System.Drawing.Color]::FromArgb(255,0,0,255) 
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 332
    $System_Drawing_Size.Height = 264
    $myGUI.ClientSize = $System_Drawing_Size
现在我有了包含变量和连接的所有相关信息的哈希列表。群组只需能够访问其哈希:

  $Sockets = $HASH1,$HASH2,$HASH3,$HASH4 # all hasches have a [string] ID: $HASH1.ID = $port
  $n = 0 # do I need that?
  foreach ($h in $Sockets) { 
     makeTab $myGUI $h $n
     $n++
  }
我心目中的功能应该是这样开始的:

  function makeTab {
     param (
        [parameter(Mandatory=$true)]
          [PSObject] $gui,
        [parameter(Mandatory=$true)]
          [PSObject] $hashTable, # with all info to connect and vars. 
        [parameter(Mandatory=$true)]
          [int] $noTab 
     )
     ... ??
  }
每个套接字选项卡必须具有以下内部组:

按钮后面的所有函数调用单击如下:
$x_OnClick={Write host”按钮已单击,执行…}

s.o.可以起草一个例子吗?之后,我可以确定组中各种按钮的大小和位置。
提前非常感谢

Gooly

如果您能够使用PowerSHell 3.0或更高版本,那么您可以使用WPF,其中的表单就是类似XML的文本。您可以在visual designer中创建XML表单,如visual Studio Express。 像这样:

  1) Send-a-Line Groupe 
     a) Line to enter test meant to sent.
     b) Button to send  # no 'cancle'
  2) Login-Groupe: 
     a) status: Login=Green.ico, Connected=Orange.ico, nothing=red.ico
     b) Button: Login (connect & login)
     c) Button: Logout (Logout & disconnect)
  3) Logging-Groupe:
     a) last 2 Lines been sent
     b) last 2 line received
  4) Status Groupe
     a) text lines with var. info. about the connection
     b) text lines with var. info. about the connection
     ...
  Global - Finally
     a) Button to Exit the script with logout & disconnect all socket connections...