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 _menuItems = new List(); private static List _menuDataItems = new List(); public WgCfgMenuItems(List 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 GetMenuItems() { return _menuItems; } public static FilePath? GetSelectItemData() { foreach (var k in _menuDataItems) { if (_selItems == "filePath_" + k.CfgPath) { return k; } } return null; } } }