Ejemplo n.º 1
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;
     //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();
 }
Ejemplo n.º 2
0
 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;
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
Ejemplo n.º 3
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;
         }
     }
     //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();
 }
Ejemplo n.º 4
0
        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;
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }