public SaveProfileForm(string name,
                               bool ipv4Enabled,
                               List <NetworkInterface.IPHostAddress> ipv4Address,
                               List <NetworkInterface.IPGatewayAddress> ipv4Gateway,
                               List <string> ipv4DnsServer,
                               bool dhcpIP,
                               bool dhcpDns,
                               bool netbios,
                               int ipv4Mtu,
                               bool ipv6Enabled,
                               List <NetworkInterface.IPHostAddress> ipv6Address,
                               List <NetworkInterface.IPGatewayAddress> ipv6Gateway,
                               List <string> ipv6DnsServer,
                               bool routerDiscovery,
                               int ipv6Mtu,
                               int interfaceMetric,
                               Config.InterfaceDataUsage interfaceDataUsage)
        {
            InitializeComponent();
            textBox1.Text = name;
            TreeNode item;

            if (ipv4Enabled)
            {
                TreeNode ipv4Node = treeView1.Nodes.Add("IPv4");
                ipv4Node.Checked = true;
                if (!dhcpIP && ipv4Address.Count > 0)
                {
                    TreeNode node = ipv4Node.Nodes.Add("Local Address & Subnet Mask");
                    foreach (NetworkInterface.IPHostAddress ip in ipv4Address)
                    {
                        item         = node.Nodes.Add("ipv4LocalAddress", ip.Address + " - " + ip.Subnet);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                if (!dhcpIP && ipv4Gateway.Count > 0)
                {
                    TreeNode node = ipv4Node.Nodes.Add("Gateway Address & Metric");
                    foreach (NetworkInterface.IPGatewayAddress ip in ipv4Gateway)
                    {
                        item         = node.Nodes.Add("ipv4GatewayAddress", ip.Address + " - " + ip.GatewayMetric);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                if (!dhcpDns && ipv4DnsServer.Count > 0)
                {
                    TreeNode node = ipv4Node.Nodes.Add("DNS Server");
                    foreach (string ip in ipv4DnsServer)
                    {
                        item         = node.Nodes.Add("ipv4DnsAddress", ip);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                {
                    item         = ipv4Node.Nodes.Add("dhcp", "DHCP: " + ((NetworkInterface.Dhcp)(Convert.ToInt32(dhcpIP) + Convert.ToInt32(dhcpDns))).GetDescription());
                    item.Checked = true;
                    item.Tag     = (NetworkInterface.Dhcp)(Convert.ToInt32(dhcpIP) + Convert.ToInt32(dhcpDns));
                }
                {
                    item         = ipv4Node.Nodes.Add("netbios", "NetBIOS: " + ((NetworkInterface.Netbios)(netbios ? 1 : 2)).GetDescription());
                    item.Checked = true;
                    item.Tag     = (NetworkInterface.Netbios)(netbios ? 1 : 2);
                }
                {
                    item         = ipv4Node.Nodes.Add("ipv4Mtu", "MTU: " + ipv4Mtu);
                    item.Checked = true;
                    item.Tag     = ipv4Mtu;
                }
            }
            if (ipv6Enabled)
            {
                TreeNode ipv6Node = treeView1.Nodes.Add("IPv6");
                ipv6Node.Checked = true;
                if (ipv6Address.Count > 0)
                {
                    TreeNode node = ipv6Node.Nodes.Add("Local Address & Subnet Prefix Length");
                    foreach (NetworkInterface.IPHostAddress ip in ipv6Address)
                    {
                        item         = node.Nodes.Add("ipv6LocalAddress", ip.Address + " - " + ip.Subnet);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                if (ipv6Gateway.Count > 0)
                {
                    TreeNode node = ipv6Node.Nodes.Add("Gateway Address & Metric");
                    foreach (NetworkInterface.IPGatewayAddress ip in ipv6Gateway)
                    {
                        item         = node.Nodes.Add("ipv6GatewayAddress", ip.Address + " - " + ip.GatewayMetric);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                if (ipv6DnsServer.Count > 0)
                {
                    TreeNode node = ipv6Node.Nodes.Add("DNS Server");
                    foreach (string ip in ipv6DnsServer)
                    {
                        item         = node.Nodes.Add("ipv6DnsAddress", ip);
                        item.Checked = true;
                        item.Tag     = ip;
                    }
                }
                {
                    item         = ipv6Node.Nodes.Add("ipv6RouterDiscovery", "Router Discovery: " + ((NetworkInterface.RouterDiscovery)Convert.ToInt32(routerDiscovery)).GetDescription());
                    item.Checked = true;
                    item.Tag     = (NetworkInterface.RouterDiscovery)Convert.ToInt32(routerDiscovery);
                }
                {
                    item         = ipv6Node.Nodes.Add("ipv6Mtu", "MTU: " + ipv6Mtu);
                    item.Checked = true;
                    item.Tag     = ipv6Mtu;
                }
            }
            item         = treeView1.Nodes.Add("interfaceMetric", "Interface Metric: " + interfaceMetric);
            item.Checked = true;
            item.Tag     = interfaceMetric;

            item         = treeView1.Nodes.Add("interfaceDataUsage", "Data Usage: " + (interfaceDataUsage.Track ? "Tracked, reset " + Enum.GetName(typeof(Config.InterfaceDataUsage.ResetIntervals), interfaceDataUsage.ResetInterval) + (interfaceDataUsage.ResetInterval == Config.InterfaceDataUsage.ResetIntervals.Daily ? " at " + interfaceDataUsage.MomentOfTheDayForReset : (interfaceDataUsage.ResetInterval == Config.InterfaceDataUsage.ResetIntervals.Weekly ? " on " + Enum.GetName(typeof(DayOfWeek), interfaceDataUsage.DayOfTheWeekForReset) : (interfaceDataUsage.ResetInterval == Config.InterfaceDataUsage.ResetIntervals.Monthly ? " on " + interfaceDataUsage.DayOfTheMonthForReset : ""))) : "Not tracked"));
            item.Checked = true;
            item.Tag     = interfaceDataUsage;

            treeView1.ExpandAll();
            loadMode.SelectedIndex = 0;
        }
Beispiel #2
0
        public ControlPanelForm()
        {
            if (Instance != null)
            {
                Instance.WindowState = FormWindowState.Normal;
                Instance.Activate();
                return;
            }
            Instance = this;
            Global.BusyForms.Enqueue(busyForm);
            InitializeComponent();
            int interfaceHeight = 260;
            int interfaceWidth  = 750;
            // resize
            Size      minimumSize     = new Size(interfaceWidth + 26, (interfaceHeight + 6) * Global.NetworkInterfaces.Count + 78);
            Rectangle screenRectangle = RectangleToScreen(ClientRectangle);
            int       titleBarHeight  = screenRectangle.Top - Top;
            int       borderThickness = screenRectangle.Left - Left;
            Rectangle workingArea     = Screen.GetWorkingArea(this);
            Size      clientSize      = new Size();

            if (minimumSize.Width > workingArea.Width - 2 * borderThickness)
            {
                clientSize.Width = workingArea.Width - 2 * borderThickness;
            }
            else
            {
                clientSize.Width = minimumSize.Width;
            }
            if (minimumSize.Height > workingArea.Height - titleBarHeight - borderThickness)
            {
                clientSize.Height = workingArea.Height - titleBarHeight - borderThickness;
            }
            else
            {
                clientSize.Height = minimumSize.Height;
            }
            AutoScrollMinSize = new System.Drawing.Size(minimumSize.Width, minimumSize.Height);
            ClientSize        = new Size(clientSize.Width, clientSize.Height);

            // populate
            int i = 0;

            foreach (NetworkInterface nic in Global.NetworkInterfaces.Values)
            {
                GroupBox groupBox = new GroupBox();
                groupBox.Name        = "interface" + nic.Guid;
                groupBox.Tag         = nic.Guid;
                groupBox.Width       = interfaceWidth;
                groupBox.Height      = interfaceHeight;
                groupBox.Location    = new Point(13, 68 + interfaceHeight * i);
                groupBox.Anchor      = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
                groupBox.MinimumSize = new System.Drawing.Size(interfaceWidth, interfaceHeight);
                groupBox.Controls.Add(CreateLabel(nic.Name, 10, 15, 340, true, "name"));
                groupBox.Controls["name"].Anchor = AnchorStyles.Left;
                if (!Global.Config.Gadget.HiddenInterfaces.Contains(nic.Guid))
                {
                    groupBox.Controls["name"].Font = new System.Drawing.Font(DefaultFont, FontStyle.Bold);
                }
                if (Global.InternetInterface != Guid.Empty)
                {
                    if (nic.Guid == Global.InternetInterface)
                    {
                        groupBox.Controls["name"].ForeColor = Color.Blue;
                        toolTip1.SetToolTip(groupBox.Controls["name"], "Internet (remote network connections) goes through this interface");
                    }
                }
                groupBox.Controls.Add(CreateListView("ipProperties"));
                Button button = new Button();
                button.Name     = "interfaceTools";
                button.Text     = "Interface tools";
                button.Location = new Point(360, 15);
                button.Anchor   = AnchorStyles.Right;
                button.Width    = 100;
                button.Height   = 20;
                ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
                ToolStripItem    toolStripItem;
                toolStripItem        = contextMenuStrip.Items.Add("Configure");
                toolStripItem.Click += new EventHandler((s, e) => { new ConfigureInterface.ConfigureInterfaceForm(nic.Guid); });
                toolStripItem        = contextMenuStrip.Items.Add("Make primary");
                toolStripItem.Click += new EventHandler((s, e) => {
                    DialogResult result = MessageBox.Show(
                        "This will configure all network interfaces so that \"" + nic.Name + "\" has the smallest metrics values of all, which will cause remote connectios to go through this interface when there are multiple NICs with a default gateway.\n\nDo you want to continue ?",
                        "Make an interface primary",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        MakeInterfacePrimary(nic.Guid);
                    }
                });
                toolStripItem.MouseHover += new EventHandler((s, e) =>
                {
                    new BalloonTip(
                        "Make an interface primary",
                        "This will configure all network interfaces so that \"" + nic.Name + "\" has the smallest metrics values of all, which will cause remote connectios to go through this interface when there are multiple NICs with a default gateway."
                        , button, BalloonTip.ICON.INFO, 100000, false, false,
                        (short)(button.PointToScreen(Point.Empty).X + button.Width / 2),
                        (short)(button.PointToScreen(Point.Empty).Y + button.Height * 2.5));
                });
                toolStripItem.MouseLeave += new EventHandler((s, e) => { BalloonTip.CloseAll(); });
                Config.InterfaceDataUsage interfaceDataUsage = Global.Config.DataUsage.FirstOrDefault(d => d.InterfaceGuid == nic.Guid);
                if (interfaceDataUsage != null)
                {
                    toolStripItem        = contextMenuStrip.Items.Add("Reset data usage");
                    toolStripItem.Click += new EventHandler((s, e) => {
                        DialogResult result = MessageBox.Show(
                            "Are you sure you want to reset current tracked data usage for \"" + nic.Name + "\"?", "Data uage reset confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            Interlocked.Exchange(ref interfaceDataUsage.PreviousSessionsReceivedBytes, 0);
                            Interlocked.Exchange(ref interfaceDataUsage.PreviousSessionsSentBytes, 0);
                            interfaceDataUsage.LastReset = DateTime.Now;
                            Global.Config.Save();
                        }
                    });
                }

                // TODO: add speed, lattency test and network map
                //toolStripItem = contextMenuStrip.Items.Add("Test performance");
                //toolStripItem.Click += new EventHandler((s,e) => new InterfacePerformance.InterfacePerformanceForm(nic));
                //contextMenuStrip.Items.Add("Test lattency").Enabled = false;
                button.Click += new EventHandler((s, e) => { contextMenuStrip.Show((Control)s, 0, ((Control)s).Height); });
                groupBox.Controls.Add(button);
                groupBox.Controls.Add(CreateLabel("Adapter GUID:", 360, 40, 120));
                groupBox.Controls.Add(CreateLabel("Description:", 360, 55, 120));
                groupBox.Controls.Add(CreateLabel("Type:", 360, 70, 120));
                groupBox.Controls.Add(CreateLabel("Interface Index:", 360, 85, 120));
                groupBox.Controls.Add(CreateLabel("MAC Address", 360, 100, 120));
                groupBox.Controls.Add(CreateLabel("Interface Metric:", 360, 115, 120));
                groupBox.Controls.Add(CreateLabel("Lowest IPv4 metrics", 360, 145, 120, false, "lowestMetrics"));
                groupBox.Controls["lowestMetrics"].Font = new System.Drawing.Font(DefaultFont, FontStyle.Underline);
                groupBox.Controls.Add(CreateLabel("Gateway Metric:", 360, 160, 120));
                groupBox.Controls.Add(CreateLabel("Route Metric:", 360, 175, 120));
                groupBox.Controls.Add(CreateLabel("Public IPv4:", 360, 220, 120));
                groupBox.Controls.Add(CreateLabel("Public IPv6:", 360, 235, 120));
                groupBox.Controls.Add(CreateLabel(nic.Guid.ToString().ToUpper(), 480, 40, 265, true));
                groupBox.Controls.Add(CreateLabel(nic.Description, 480, 55, 265, true));
                groupBox.Controls.Add(CreateLabel(nic.Type.GetDescription(), 480, 70, 265, true));
                groupBox.Controls.Add(CreateLabel(nic.Index.ToString(), 480, 85, 120, true));
                groupBox.Controls.Add(CreateLabel(nic.Mac, 480, 100, 120, true));
                groupBox.Controls.Add(CreateLabel(nic.InterfaceMetric.ToString(), 480, 115, 120, true));
                groupBox.Controls.Add(CreateLabel(nic.IPv4Gateway.Count != 0 ? nic.IPv4Gateway.Min(x => x.GatewayMetric).ToString() : "", 480, 160, 120, true));
                groupBox.Controls.Add(CreateLabel(nic.IPv4Gateway.Count != 0 ? nic.IPv4Gateway.Min(x => x.GatewayMetric + nic.InterfaceMetric).ToString() : "", 480, 175, 120, true));
                groupBox.Controls.Add(CreateLabel(nic.PublicIPv4, 480, 220, 265, true, "publicIPv4"));
                groupBox.Controls.Add(CreateLabel(nic.PublicIPv6, 480, 235, 265, true, "publicIPv6"));
                groupBox.Controls.Add(CreateLabel("Download:", 600, 85, 65, false, "", Color.FromArgb(0x9b, 0x87, 0x0c)));
                groupBox.Controls.Add(CreateLabel("0 B/s", 600, 100, 65, false, "downByte", Color.FromArgb(0x9b, 0x87, 0x0c)));
                groupBox.Controls.Add(CreateLabel("0 b/s", 600, 115, 65, false, "downBit", Color.FromArgb(0x9b, 0x87, 0x0c)));
                groupBox.Controls.Add(CreateLabel(Unit.AutoScale(nic.TotalReceivedBytes(), "B"), 600, 205, 65, false, "totalDown", Color.FromArgb(0x9b, 0x87, 0x0c)));
                groupBox.Controls.Add(CreateLabel("Upload:", 665, 85, 65, false, "", Color.Green, ContentAlignment.MiddleRight));
                groupBox.Controls.Add(CreateLabel("0 B/s", 665, 100, 65, false, "upByte", Color.Green, ContentAlignment.MiddleRight));
                groupBox.Controls.Add(CreateLabel("0 b/s", 665, 115, 65, false, "upBit", Color.Green, ContentAlignment.MiddleRight));
                groupBox.Controls.Add(CreateLabel(Unit.AutoScale(nic.TotalSentdBytes(), "B"), 665, 205, 65, false, "totalUp", Color.Green, ContentAlignment.MiddleRight));
                groupBox.Controls.Add(CreateLabel("Total:", 650, 190, 65));
                groupBox.Controls.Add(CreateGraph("graph", 600, 145));
                // interface event subscriptions
                EventHandler <TextEventArgs> handler = new EventHandler <TextEventArgs>((s, e) =>
                {
                    try
                    {
                        Invoke(new Action(() =>
                        {
                            if (nic.Guid == ((WinLib.Network.NetworkInterface)s).Guid)
                            {
                                groupBox.Controls["publicIPv4"].Text = e.Text;
                            }
                        }));
                    }
                    catch { }
                });
                nic.PublicIPv4Changed += handler;
                publicIPv4Subscriptions.Add(nic, handler);

                handler = new EventHandler <TextEventArgs>((s, e) =>
                {
                    try
                    {
                        Invoke(new Action(() =>
                        {
                            if (nic.Guid == ((WinLib.Network.NetworkInterface)s).Guid)
                            {
                                groupBox.Controls["publicIPv6"].Text = e.Text;
                            }
                        }));
                    }
                    catch { }
                });
                nic.PublicIPv6Changed += handler;
                publicIPv6Subscriptions.Add(nic, handler);

                handler = new EventHandler <TextEventArgs>((s, e) =>
                {
                    try
                    {
                        Invoke(new Action(() =>
                        {
                            if (nic.IPv4Address.Any(a => a.Address == e.Text))
                            {
                                groupBox.Controls["name"].ForeColor = Color.Aqua;
                                toolTip1.SetToolTip(groupBox.Controls["name"], "Internet (remote network connections) goes through this interface");
                                Global.InternetInterface = nic.Guid;
                            }
                            else
                            {
                                groupBox.Controls["name"].ForeColor = Color.Black;
                                toolTip1.SetToolTip(groupBox.Controls["name"], "");
                            }
                        }));
                    }
                    catch { }
                });
                WinLib.Network.NetworkInterface.InternetInterfaceChanged += handler;
                internetInterfaceSubscriptions.Add(handler);

                Controls.Add(groupBox);
                i++;
            }
            ClientSize = new Size(ClientSize.Width + 70, ClientSize.Height);
            Location   = new Point(workingArea.Left + workingArea.Width / 2 - Width / 2, workingArea.Top + workingArea.Height / 2 - Height / 2);
            Show();
        }
        private void Save_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                new BalloonTip("Warning", "Profile name can't be empty", textBox1, BalloonTip.ICON.WARNING);
                return;
            }
            DialogResult result;

            if (Global.Config.InterfaceProfiles.Where((i) => i.Name == textBox1.Text).Count() > 0)
            {
                result = MessageBox.Show(this, "There is already a profile with this name \"" + textBox1.Text + "\".\nDo you want to overwrite it?", "Profile duplicate", MessageBoxButtons.YesNo);
                if (result.CompareTo(DialogResult.No) == 0)
                {
                    return;
                }
            }
            ProfileName = textBox1.Text;
            LoadMode    = (Config.InterfaceProfile.LoadingMode)loadMode.SelectedIndex;
            TreeNode[] nodes = treeView1.Nodes.Find("ipv4LocalAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv4Address.Add((NetworkInterface.IPHostAddress)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("ipv4GatewayAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv4Gateway.Add((NetworkInterface.IPGatewayAddress)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("ipv4DnsAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv4DnsServer.Add((string)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("dhcp", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    DhcpEnabled = (NetworkInterface.Dhcp)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("netbios", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    NetbiosEnabled = (NetworkInterface.Netbios)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("ipv4Mtu", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv4Mtu = (int)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("ipv6LocalAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv6Address.Add((NetworkInterface.IPHostAddress)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("ipv6GatewayAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv6Gateway.Add((NetworkInterface.IPGatewayAddress)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("ipv6DnsAddress", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv6DnsServer.Add((string)node.Tag);
                }
            }
            nodes = treeView1.Nodes.Find("ipv6RouterDiscovery", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    RouterDiscovery = (NetworkInterface.RouterDiscovery)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("ipv6Mtu", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    IPv6Mtu = (int)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("interfaceMetric", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    InterfaceMetric = (int)node.Tag;
                }
            }
            nodes = treeView1.Nodes.Find("interfaceDataUsage", true);
            foreach (TreeNode node in nodes)
            {
                if (node.Checked)
                {
                    InterfaceDataUsage = (Config.InterfaceDataUsage)node.Tag;
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Beispiel #4
0
 private void Load_Click(object sender, EventArgs e)
 {
     LoadMode = (Config.InterfaceProfile.LoadingMode)loadMode.SelectedIndex;
     TreeNode[] nodes = treeView1.Nodes.Find("ipv4LocalAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv4Address.Add((NetworkInterface.IPHostAddress)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("ipv4GatewayAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv4Gateway.Add((NetworkInterface.IPGatewayAddress)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("ipv4DnsAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv4DnsServer.Add((string)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("dhcp", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             DhcpEnabled = (NetworkInterface.Dhcp)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("netbios", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             NetbiosEnabled = (NetworkInterface.Netbios)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("ipv4Mtu", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv4Mtu = (int)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("ipv6LocalAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv6Address.Add((NetworkInterface.IPHostAddress)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("ipv6GatewayAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv6Gateway.Add((NetworkInterface.IPGatewayAddress)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("ipv6DnsAddress", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv6DnsServer.Add((string)node.Tag);
         }
     }
     nodes = treeView1.Nodes.Find("ipv6RouterDiscovery", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             RouterDiscovery = (NetworkInterface.RouterDiscovery)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("ipv6Mtu", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             IPv6Mtu = (int)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("interfaceMetric", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             InterfaceMetric = (int)node.Tag;
         }
     }
     nodes = treeView1.Nodes.Find("interfaceDataUsage", true);
     foreach (TreeNode node in nodes)
     {
         if (node.Checked)
         {
             InterfaceDataUsage = (Config.InterfaceDataUsage)node.Tag;
         }
     }
     //foreach (ListViewItem item in listView1.Items)
     //{
     //    if (item.SubItems[0].Text != "")
     //        property = item.SubItems[0].Text;
     //    if (!item.Checked)
     //        continue;
     //    if (property == "IPv4 Address & Mask")
     //        IPv4Address.Add(new string[] { item.SubItems[1].Text, item.SubItems[2].Text });
     //    if (property == "IPv4 Gateway & Metric")
     //        IPv4Gateway.Add(new string[] { item.SubItems[1].Text, item.SubItems[2].Text });
     //    if (property == "IPv4 DNS Server")
     //        IPv4DnsServer.Add( item.SubItems[1].Text );
     //    if (property == "DHCP Enabled")
     //        if (item.SubItems[1].Text == "Disabled")
     //            DhcpEnabled = NetworkInterface.Dhcp.Disabled;
     //        else if (item.SubItems[1].Text == "IP only")
     //            DhcpEnabled = NetworkInterface.Dhcp.IPOnly;
     //        else if (item.SubItems[1].Text == "IP & DNS")
     //            DhcpEnabled = NetworkInterface.Dhcp.IPnDns;
     //    if (property == "NetBIOS over TCP/IP")
     //        NetbiosEnabled = (NetworkInterface.Netbios)Enum.Parse(typeof(NetworkInterface.Netbios), item.SubItems[1].Text);
     //    if (property == "IPv4 MTU")
     //        IPv4Mtu = int.Parse(item.SubItems[1].Text);
     //    if (property == "IPv6 Address & Mask")
     //        IPv6Address.Add(new string[] { item.SubItems[1].Text, item.SubItems[2].Text });
     //    if (property == "IPv6 Gateway & Metric")
     //        IPv6Gateway.Add(new string[] { item.SubItems[1].Text, item.SubItems[2].Text });
     //    if (property == "IPv6 DNS Server")
     //        IPv6DnsServer.Add(item.SubItems[1].Text);
     //    if (property == "Router Discovery")
     //        RouterDiscovery = (NetworkInterface.RouterDiscovery)Enum.Parse(typeof(NetworkInterface.RouterDiscovery), item.SubItems[1].Text);
     //    if (property == "IPv6 MTU")
     //        IPv6Mtu = int.Parse(item.SubItems[1].Text);
     //    if (property == "Interface Metric")
     //        InterfaceMetric = int.Parse(item.SubItems[1].Text);
     //}
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }