69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace NetTunnelApp
|
|
{
|
|
internal class WgCfgMenuItems
|
|
{
|
|
private static string _selItems = "";
|
|
|
|
private List<ToolStripMenuItem> _menuItems = new List<ToolStripMenuItem>();
|
|
|
|
private static List<FilePath> _menuDataItems = new List<FilePath>();
|
|
|
|
public WgCfgMenuItems(List<FilePath> wgCfgArrays)
|
|
{
|
|
if (_menuItems.Count > 0)
|
|
{
|
|
_menuItems.Clear();
|
|
}
|
|
_menuDataItems.Clear();
|
|
_menuDataItems.AddRange(wgCfgArrays);
|
|
|
|
foreach (var cfg in wgCfgArrays)
|
|
{
|
|
ToolStripMenuItem item = new ToolStripMenuItem();
|
|
|
|
item.Text = Path.GetFileName(cfg.CfgPath);
|
|
item.Name = "filePath_" + cfg.CfgPath;
|
|
item.Click += delegate(object sender, EventArgs e)
|
|
{
|
|
var control = (ToolStripMenuItem)sender;
|
|
_selItems = control.Name;
|
|
|
|
foreach (var v in _menuItems)
|
|
{
|
|
v.Checked = (_selItems == v.Name);
|
|
}
|
|
};
|
|
|
|
item.Checked = cfg.curUsed > 0;
|
|
_menuItems.Add(item);
|
|
}
|
|
}
|
|
|
|
public List<ToolStripMenuItem> GetMenuItems()
|
|
{
|
|
return _menuItems;
|
|
}
|
|
|
|
public static FilePath? GetSelectItemData()
|
|
{
|
|
foreach (var k in _menuDataItems)
|
|
{
|
|
if (_selItems == "filePath_" + k.CfgPath)
|
|
{
|
|
return k;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |