using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Windows.Forms; namespace NetMonitorClient { partial class Netzmonitor { private void setNetworkAuto(string adapter, string name) { setNetwork(netsetter.Auto, null, null, null, adapter, name, null, null); } private void setNetworkIpAuto(string adapter, string name) { setNetwork(netsetter.IpAuto, null, null, null, adapter, name, null, null); } private void setNetworkIp(string ip, string subnet, string gateway, string adapter, string name) { setNetwork(netsetter.Ip, ip, subnet, gateway, adapter, name, null, null); } private void setNetworkDnsAuto(string adapter, string name) { setNetwork(netsetter.DnsAuto, null, null, null, adapter, name, null, null); } private void setNetworkDns(string dns, string adapter, string name) { setNetwork(netsetter.Dns, null, null, null, adapter, name, dns, null); } private void setNetworkWinsAuto(string adapter, string name) { setNetwork(netsetter.WinsAuto, null, null, null, adapter, name, null, null); } private void setNetworkWins(string wins, string adapter, string name) { setNetwork(netsetter.Wins, null, null, null, adapter, name, null, wins); } private void setNetwork(netsetter option, string ip, string subnet, string gateway, string adapter, string name, string dns, string wins) { bool status = false; String text = ""; if (option == netsetter.Ip) { text = "Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkIp(ip, subnet, gateway, adapter); } if (option == netsetter.Auto) { text = "Netzwerk auf Auto"; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkAuto(adapter); } if (option == netsetter.IpAuto) { text = "Ip auf Auto"; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkIpAuto(adapter); } if (option == netsetter.DnsAuto) { text = "Dns auf Auto"; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkDnsAuto(adapter); } if (option == netsetter.WinsAuto) { text = "Wins auf Auto"; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkWinsAuto(adapter); } if (option == netsetter.Dns) { text = "Dns: " + dns; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkDNS(dns, adapter); } if (option == netsetter.Wins) { text = "Wins: " + wins; this.StatusLog.Items.Add("Gesendet: " + text); Application.DoEvents(); status = this.sc.setNetworkWINS(wins, adapter); } this.StatusLog.Items.Add("Antwort: " + ((status) ? "Ok" : "Fehler")); Application.DoEvents(); this.showPopup(status, name, text); Application.DoEvents(); } private void InitNetworks() { this.networkini = new InIReader("network.ini"); // // trayMenu // this.trayMenu.Items.AddRange(new ToolStripItem[] {this.trayMenuNetzwerk}); this.trayMenu.Name = "trayMenu"; this.trayMenu.Size = new System.Drawing.Size(153, 48); // // trayMenuNetzwerk // this.trayMenuNetzwerk.Name = "trayMenuNetzwerk"; this.trayMenuNetzwerk.Size = new System.Drawing.Size(152, 22); this.trayMenuNetzwerk.Text = "Netzwerk"; ArrayList networks = networkini.getSections(); ToolStripItem[] tsi = new ToolStripItem[networks.Count]; int i=0; foreach (String net in networks) { ToolStripMenuItem TrayItemNet = new ToolStripMenuItem(); TrayItemNet.Name = net; TrayItemNet.Size = new System.Drawing.Size(152, 22); TrayItemNet.Text = networkini.getValue(net, "Name"); TrayItemNet.Click += new System.EventHandler(this.TrayMenuNet_Click); tsi[i++] = TrayItemNet; } this.trayMenuNetzwerk.DropDownItems.AddRange(tsi); this.ProgramMenuNetzwerke.DropDownItems.AddRange(tsi); this.trayIcon.Icon = Properties.Resources.icon_ok; } } }