NetTunnelWindows/NetTunnelApp/ServerMenuItems.cs

67 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace NetTunnelApp;
public class ServerMenuItems
{
private static string _selItems = "";
private List<ToolStripMenuItem> _menuItems = new List<ToolStripMenuItem>();
public ServerMenuItems(List<VirtualMathineConfig> vmList)
{
if (_menuItems.Count > 0)
{
_menuItems.Clear();
}
foreach (var cfg in vmList)
{
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = cfg.vmName;
item.Name = cfg.vmId.ToString();
item.Click += delegate(object sender, EventArgs e)
{
var control = (ToolStripMenuItem)sender;
_selItems = control.Name;
foreach (var v in _menuItems)
{
v.Checked = (_selItems == v.Name);
}
};
_menuItems.Add(item);
}
}
public List<ToolStripMenuItem> GetMenuItems()
{
return _menuItems;
}
}
public class UserClientCfg
{
///< 用户接入网关控制 ID
public int scgCtrlAppId;
///< 用户接入网关隧道 ID
public int scgTunnelAppId;
///< 用户客户端公钥
public string cliPrivateKey;
///< 用户客户端隧道IP地址
public string cliAddress;
///< 用户虚拟机配置列表
public List<VirtualMathineConfig> vmList;
public UserClientCfg()
{
vmList = new List<VirtualMathineConfig>();
}
}