From 9cecf092c6349ce094d797cb47cea729888b63d2 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Wed, 9 Jun 2010 22:28:48 +0000 Subject: [PATCH] =?UTF-8?q?Netzwerkeditor=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetMonitorClient/EditNetworks.Designer.cs | 380 +++++++++++++++++++++- NetMonitorClient/EditNetworks.cs | 195 +++++++++++ NetMonitorClient/EditNetworks.resx | 123 +++++++ NetMonitorClient/Form1.Designer.cs | 86 ++--- NetMonitorClient/Form1.cs | 30 +- NetMonitorClient/NetMonitorClient.csproj | 3 + NetMonitorClient/Networks.cs | 87 +++++ 7 files changed, 855 insertions(+), 49 deletions(-) create mode 100644 NetMonitorClient/EditNetworks.resx diff --git a/NetMonitorClient/EditNetworks.Designer.cs b/NetMonitorClient/EditNetworks.Designer.cs index e99d90b..1e2d9ff 100644 --- a/NetMonitorClient/EditNetworks.Designer.cs +++ b/NetMonitorClient/EditNetworks.Designer.cs @@ -28,11 +28,387 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.BoxGateway = new System.Windows.Forms.MaskedTextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.BoxSubnet = new System.Windows.Forms.MaskedTextBox(); + this.BoxDns = new System.Windows.Forms.MaskedTextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.BoxIpAdresse = new System.Windows.Forms.MaskedTextBox(); + this.BoxWins = new System.Windows.Forms.MaskedTextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.NetworksList = new System.Windows.Forms.ListBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.BoxName = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.RadioWinsManu = new System.Windows.Forms.RadioButton(); + this.RadioWinsAuto = new System.Windows.Forms.RadioButton(); + this.RadioDnsManu = new System.Windows.Forms.RadioButton(); + this.RadioDnsAuto = new System.Windows.Forms.RadioButton(); + this.RadioIpManu = new System.Windows.Forms.RadioButton(); + this.RadioIpAuto = new System.Windows.Forms.RadioButton(); + this.RadioAllManu = new System.Windows.Forms.RadioButton(); + this.RadioAllAuto = new System.Windows.Forms.RadioButton(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.SuspendLayout(); + // + // BoxGateway + // + this.BoxGateway.Location = new System.Drawing.Point(9, 58); + this.BoxGateway.Mask = "000/000/000/000"; + this.BoxGateway.Name = "BoxGateway"; + this.BoxGateway.Size = new System.Drawing.Size(93, 20); + this.BoxGateway.TabIndex = 6; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 42); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(49, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Gateway"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 81); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(30, 13); + this.label4.TabIndex = 7; + this.label4.Text = "DNS"; + // + // BoxSubnet + // + this.BoxSubnet.Location = new System.Drawing.Point(124, 19); + this.BoxSubnet.Mask = "00"; + this.BoxSubnet.Name = "BoxSubnet"; + this.BoxSubnet.Size = new System.Drawing.Size(23, 20); + this.BoxSubnet.TabIndex = 4; + // + // BoxDns + // + this.BoxDns.Location = new System.Drawing.Point(9, 97); + this.BoxDns.Mask = "000/000/000/000"; + this.BoxDns.Name = "BoxDns"; + this.BoxDns.Size = new System.Drawing.Size(93, 20); + this.BoxDns.TabIndex = 8; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(106, 22); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(12, 13); + this.label2.TabIndex = 3; + this.label2.Text = "/"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 120); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(31, 13); + this.label5.TabIndex = 9; + this.label5.Text = "Wins"; + // + // BoxIpAdresse + // + this.BoxIpAdresse.Location = new System.Drawing.Point(9, 19); + this.BoxIpAdresse.Mask = "000/000/000/000"; + this.BoxIpAdresse.Name = "BoxIpAdresse"; + this.BoxIpAdresse.Size = new System.Drawing.Size(93, 20); + this.BoxIpAdresse.TabIndex = 1; + // + // BoxWins + // + this.BoxWins.Location = new System.Drawing.Point(9, 137); + this.BoxWins.Mask = "000/000/000/000"; + this.BoxWins.Name = "BoxWins"; + this.BoxWins.Size = new System.Drawing.Size(93, 20); + this.BoxWins.TabIndex = 10; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 3); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(58, 13); + this.label1.TabIndex = 2; + this.label1.Text = "IP Adresse"; + // + // NetworksList + // + this.NetworksList.FormattingEnabled = true; + this.NetworksList.Location = new System.Drawing.Point(9, 12); + this.NetworksList.Name = "NetworksList"; + this.NetworksList.Size = new System.Drawing.Size(116, 238); + this.NetworksList.TabIndex = 0; + this.NetworksList.SelectedIndexChanged += new System.EventHandler(this.NetworksList_SelectedIndexChanged); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(131, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(213, 238); + this.tabControl1.TabIndex = 11; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.BoxName); + this.tabPage1.Controls.Add(this.label10); + this.tabPage1.Controls.Add(this.label1); + this.tabPage1.Controls.Add(this.BoxDns); + this.tabPage1.Controls.Add(this.BoxSubnet); + this.tabPage1.Controls.Add(this.BoxWins); + this.tabPage1.Controls.Add(this.label2); + this.tabPage1.Controls.Add(this.BoxGateway); + this.tabPage1.Controls.Add(this.label4); + this.tabPage1.Controls.Add(this.BoxIpAdresse); + this.tabPage1.Controls.Add(this.label5); + this.tabPage1.Controls.Add(this.label3); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(205, 212); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Manuell"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // BoxName + // + this.BoxName.Location = new System.Drawing.Point(9, 177); + this.BoxName.Name = "BoxName"; + this.BoxName.Size = new System.Drawing.Size(93, 20); + this.BoxName.TabIndex = 12; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(6, 160); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(35, 13); + this.label10.TabIndex = 11; + this.label10.Text = "Name"; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.RadioWinsManu); + this.tabPage2.Controls.Add(this.RadioWinsAuto); + this.tabPage2.Controls.Add(this.RadioDnsManu); + this.tabPage2.Controls.Add(this.RadioDnsAuto); + this.tabPage2.Controls.Add(this.RadioIpManu); + this.tabPage2.Controls.Add(this.RadioIpAuto); + this.tabPage2.Controls.Add(this.RadioAllManu); + this.tabPage2.Controls.Add(this.RadioAllAuto); + this.tabPage2.Controls.Add(this.label6); + this.tabPage2.Controls.Add(this.label7); + this.tabPage2.Controls.Add(this.label8); + this.tabPage2.Controls.Add(this.label9); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(205, 212); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Auto"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // RadioWinsManu + // + this.RadioWinsManu.AutoSize = true; + this.RadioWinsManu.Location = new System.Drawing.Point(63, 136); + this.RadioWinsManu.Name = "RadioWinsManu"; + this.RadioWinsManu.Size = new System.Drawing.Size(62, 17); + this.RadioWinsManu.TabIndex = 21; + this.RadioWinsManu.TabStop = true; + this.RadioWinsManu.Tag = "0"; + this.RadioWinsManu.Text = "Manuell"; + this.RadioWinsManu.UseVisualStyleBackColor = true; + // + // RadioWinsAuto + // + this.RadioWinsAuto.AutoSize = true; + this.RadioWinsAuto.Location = new System.Drawing.Point(9, 136); + this.RadioWinsAuto.Name = "RadioWinsAuto"; + this.RadioWinsAuto.Size = new System.Drawing.Size(47, 17); + this.RadioWinsAuto.TabIndex = 20; + this.RadioWinsAuto.TabStop = true; + this.RadioWinsAuto.Tag = "1"; + this.RadioWinsAuto.Text = "Auto"; + this.RadioWinsAuto.UseVisualStyleBackColor = true; + // + // RadioDnsManu + // + this.RadioDnsManu.AutoSize = true; + this.RadioDnsManu.Location = new System.Drawing.Point(63, 97); + this.RadioDnsManu.Name = "RadioDnsManu"; + this.RadioDnsManu.Size = new System.Drawing.Size(62, 17); + this.RadioDnsManu.TabIndex = 19; + this.RadioDnsManu.TabStop = true; + this.RadioDnsManu.Tag = "0"; + this.RadioDnsManu.Text = "Manuell"; + this.RadioDnsManu.UseVisualStyleBackColor = true; + // + // RadioDnsAuto + // + this.RadioDnsAuto.AutoSize = true; + this.RadioDnsAuto.Location = new System.Drawing.Point(9, 97); + this.RadioDnsAuto.Name = "RadioDnsAuto"; + this.RadioDnsAuto.Size = new System.Drawing.Size(47, 17); + this.RadioDnsAuto.TabIndex = 18; + this.RadioDnsAuto.TabStop = true; + this.RadioDnsAuto.Tag = "1"; + this.RadioDnsAuto.Text = "Auto"; + this.RadioDnsAuto.UseVisualStyleBackColor = true; + // + // RadioIpManu + // + this.RadioIpManu.AutoSize = true; + this.RadioIpManu.Location = new System.Drawing.Point(63, 61); + this.RadioIpManu.Name = "RadioIpManu"; + this.RadioIpManu.Size = new System.Drawing.Size(62, 17); + this.RadioIpManu.TabIndex = 17; + this.RadioIpManu.TabStop = true; + this.RadioIpManu.Tag = "0"; + this.RadioIpManu.Text = "Manuell"; + this.RadioIpManu.UseVisualStyleBackColor = true; + // + // RadioIpAuto + // + this.RadioIpAuto.AutoSize = true; + this.RadioIpAuto.Location = new System.Drawing.Point(9, 61); + this.RadioIpAuto.Name = "RadioIpAuto"; + this.RadioIpAuto.Size = new System.Drawing.Size(47, 17); + this.RadioIpAuto.TabIndex = 16; + this.RadioIpAuto.TabStop = true; + this.RadioIpAuto.Tag = "1"; + this.RadioIpAuto.Text = "Auto"; + this.RadioIpAuto.UseVisualStyleBackColor = true; + // + // RadioAllManu + // + this.RadioAllManu.AutoSize = true; + this.RadioAllManu.Location = new System.Drawing.Point(63, 20); + this.RadioAllManu.Name = "RadioAllManu"; + this.RadioAllManu.Size = new System.Drawing.Size(62, 17); + this.RadioAllManu.TabIndex = 15; + this.RadioAllManu.TabStop = true; + this.RadioAllManu.Tag = "0"; + this.RadioAllManu.Text = "Manuell"; + this.RadioAllManu.UseVisualStyleBackColor = true; + // + // RadioAllAuto + // + this.RadioAllAuto.AutoSize = true; + this.RadioAllAuto.Location = new System.Drawing.Point(9, 20); + this.RadioAllAuto.Name = "RadioAllAuto"; + this.RadioAllAuto.Size = new System.Drawing.Size(47, 17); + this.RadioAllAuto.TabIndex = 14; + this.RadioAllAuto.Tag = "1"; + this.RadioAllAuto.Text = "Auto"; + this.RadioAllAuto.UseVisualStyleBackColor = true; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 3); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(29, 13); + this.label6.TabIndex = 10; + this.label6.Text = "Alles"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(6, 81); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(30, 13); + this.label7.TabIndex = 12; + this.label7.Text = "DNS"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(6, 120); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(31, 13); + this.label8.TabIndex = 13; + this.label8.Text = "Wins"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 42); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(58, 13); + this.label9.TabIndex = 11; + this.label9.Text = "IP Adresse"; + // + // EditNetworks + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Text = "EditNetworks"; + this.AutoSize = true; + this.ClientSize = new System.Drawing.Size(349, 256); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.NetworksList); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "EditNetworks"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Netzwerke Ansehen/Editieren"; + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.MaskedTextBox BoxGateway; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.MaskedTextBox BoxSubnet; + private System.Windows.Forms.MaskedTextBox BoxDns; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.MaskedTextBox BoxIpAdresse; + private System.Windows.Forms.MaskedTextBox BoxWins; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ListBox NetworksList; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.RadioButton RadioWinsManu; + private System.Windows.Forms.RadioButton RadioWinsAuto; + private System.Windows.Forms.RadioButton RadioDnsManu; + private System.Windows.Forms.RadioButton RadioDnsAuto; + private System.Windows.Forms.RadioButton RadioIpManu; + private System.Windows.Forms.RadioButton RadioIpAuto; + private System.Windows.Forms.RadioButton RadioAllManu; + private System.Windows.Forms.RadioButton RadioAllAuto; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox BoxName; + private System.Windows.Forms.Label label10; + } } \ No newline at end of file diff --git a/NetMonitorClient/EditNetworks.cs b/NetMonitorClient/EditNetworks.cs index 1cc388f..594be9f 100644 --- a/NetMonitorClient/EditNetworks.cs +++ b/NetMonitorClient/EditNetworks.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using System.Collections; namespace NetMonitorClient { @@ -20,7 +21,14 @@ namespace NetMonitorClient Read, Write } + internal enum AMMode + { + Auto, + Manu, + Disable + } private RWFlag acess; + private InIReader networkini; public EditNetworks(Options option) { if (option == Options.Show) @@ -28,6 +36,193 @@ namespace NetMonitorClient this.acess = RWFlag.Read; } InitializeComponent(); + ReadNetworksSettings(); + SetRWSettings(); + } + + private void SetRWSettings() + { + if (this.acess == RWFlag.Read) + { + this.BoxDns.ReadOnly = true; + this.BoxGateway.ReadOnly = true; + this.BoxIpAdresse.ReadOnly = true; + this.BoxName.ReadOnly = true; + this.BoxSubnet.ReadOnly = true; + this.BoxWins.ReadOnly = true; + this.Text = "Netzwerke Ansehen"; + this.RadioAllAuto.Enabled = false; + this.RadioAllManu.Enabled = false; + this.RadioDnsAuto.Enabled = false; + this.RadioDnsManu.Enabled = false; + this.RadioIpAuto.Enabled = false; + this.RadioIpManu.Enabled = false; + this.RadioWinsAuto.Enabled = false; + this.RadioWinsManu.Enabled = false; + } + } + + private void ReadNetworksSettings() + { + this.networkini = new InIReader("network.ini"); + ArrayList networks = this.networkini.getSections(); + foreach (String net in networks) + { + this.NetworksList.Items.Add(net); + } + } + + private void NetworksList_SelectedIndexChanged(object sender, EventArgs e) + { + ListBox Item = (ListBox)sender; + String name = networkini.getValue(Item.Text, "Name"); + String ip = networkini.getValue(Item.Text, "Ip"); + String subnet = networkini.getValue(Item.Text, "Subnet"); + String gateway = networkini.getValue(Item.Text, "Gateway"); + String dns = networkini.getValue(Item.Text, "Dns"); + String wins = networkini.getValue(Item.Text, "Wins"); + String adapter = networkini.getValue(Item.Text, "Adapter"); + this.BoxName.Text = name; + if (ip == "auto" && dns == "auto" && wins == "auto") + { + this.setAllMode(AMMode.Auto); + } + else + { + if (ip == "auto") + setIpMode(AMMode.Auto); + else + { + setIpMode(AMMode.Manu); + this.BoxIpAdresse.Text = ip; + this.BoxSubnet.Text = ConvSubnet(subnet); + this.BoxGateway.Text = gateway; + } + if (dns == "auto") + setDnsMode(AMMode.Auto); + else + { + setDnsMode(AMMode.Manu); + this.BoxDns.Text = dns; + } + if (wins == "auto") + setWinsMode(AMMode.Auto); + else + { + setWinsMode(AMMode.Manu); + this.BoxWins.Text = wins; + } + } + } + + private string ConvSubnet(string subnet) + { + String[] ips = subnet.Split('.'); + String Bits = ""; + foreach (String part in ips) + { + Bits += Convert.ToString(byte.Parse(part), 2).PadLeft(8, '0'); + } + int meng = 0; + foreach (char bit in Bits) + { + if (bit == '1') + meng++; + } + return meng.ToString(); + } + + private void setAllMode(AMMode mode) + { + if (mode == AMMode.Auto) + { + setIpMode(AMMode.Disable); + setDnsMode(AMMode.Disable); + setWinsMode(AMMode.Disable); + } + if (mode == AMMode.Manu) + { + setIpMode(AMMode.Manu); + setDnsMode(AMMode.Manu); + setWinsMode(AMMode.Manu); + } + } + + private void setWinsMode(AMMode mode) + { + if (mode == AMMode.Auto) + { + this.RadioWinsAuto.Checked = true; + this.RadioWinsManu.Checked = false; + this.BoxWins.Enabled = false; + this.BoxWins.Text = ""; + } + if (mode == AMMode.Disable) + { + this.RadioWinsManu.Checked = false; + this.RadioWinsAuto.Checked = false; + this.BoxWins.Enabled = false; + this.BoxWins.Text = ""; + } + if (mode == AMMode.Manu) + { + this.RadioWinsAuto.Checked = false; + this.RadioWinsManu.Checked = true; + this.BoxWins.Enabled = true; + } + } + + private void setDnsMode(AMMode mode) + { + if (mode == AMMode.Auto) + { + this.RadioDnsAuto.Checked = true; + this.RadioDnsManu.Checked = false; + this.BoxDns.Enabled = false; + this.BoxDns.Text = ""; + } + if (mode == AMMode.Disable) + { + this.RadioDnsManu.Checked = false; + this.RadioDnsAuto.Checked = false; + this.BoxDns.Enabled = false; + this.BoxDns.Text = ""; + } + if (mode == AMMode.Manu) + { + this.RadioDnsAuto.Checked = false; + this.RadioDnsManu.Checked = true; + this.BoxDns.Enabled = true; + } + } + + private void setIpMode(AMMode mode) + { + if (mode == AMMode.Auto) + { + this.RadioIpAuto.Checked = true; + this.RadioIpManu.Checked = false; + this.BoxIpAdresse.Enabled = false; + this.BoxIpAdresse.Text = ""; + this.BoxSubnet.Enabled = false; + this.BoxSubnet.Text = ""; + } + if (mode == AMMode.Disable) + { + this.RadioIpManu.Checked = false; + this.RadioIpAuto.Checked = false; + this.BoxIpAdresse.Enabled = false; + this.BoxIpAdresse.Text = ""; + this.BoxSubnet.Enabled = false; + this.BoxSubnet.Text = ""; + } + if (mode == AMMode.Manu) + { + this.RadioIpAuto.Checked = false; + this.RadioIpManu.Checked = true; + this.BoxIpAdresse.Enabled = true; + this.BoxSubnet.Enabled = true; + } } } } diff --git a/NetMonitorClient/EditNetworks.resx b/NetMonitorClient/EditNetworks.resx new file mode 100644 index 0000000..0faec9d --- /dev/null +++ b/NetMonitorClient/EditNetworks.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/NetMonitorClient/Form1.Designer.cs b/NetMonitorClient/Form1.Designer.cs index f78033c..8d4cb68 100644 --- a/NetMonitorClient/Form1.Designer.cs +++ b/NetMonitorClient/Form1.Designer.cs @@ -41,15 +41,16 @@ this.ProgramMenuDienst = new System.Windows.Forms.ToolStripMenuItem(); this.ProgramMenuDienstStarten = new System.Windows.Forms.ToolStripMenuItem(); this.ProgramMenuDienstStoppen = new System.Windows.Forms.ToolStripMenuItem(); + this.ProgramMenuNetzwerke = new System.Windows.Forms.ToolStripMenuItem(); this.Statusbar = new System.Windows.Forms.StatusStrip(); + this.StatusbarLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.StatusbarProgress = new System.Windows.Forms.ToolStripProgressBar(); + this.StatusbarDienst = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.trayMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.trayMenuNetzwerk = new System.Windows.Forms.ToolStripMenuItem(); - this.StatusbarLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.StatusbarDienst = new System.Windows.Forms.ToolStripStatusLabel(); - this.StatusbarProgress = new System.Windows.Forms.ToolStripProgressBar(); - this.ProgramMenuNetzwerke = new System.Windows.Forms.ToolStripMenuItem(); + this.StatusLog = new System.Windows.Forms.ListBox(); this.ProgramMenu.SuspendLayout(); this.Statusbar.SuspendLayout(); this.SuspendLayout(); @@ -62,7 +63,7 @@ this.ProgramMenuNetzwerke}); this.ProgramMenu.Location = new System.Drawing.Point(0, 0); this.ProgramMenu.Name = "ProgramMenu"; - this.ProgramMenu.Size = new System.Drawing.Size(284, 24); + this.ProgramMenu.Size = new System.Drawing.Size(459, 24); this.ProgramMenu.TabIndex = 0; this.ProgramMenu.Text = "menuStrip1"; // @@ -82,20 +83,20 @@ this.ProgramMenuDateiNetzwerkeAnsehen, this.ProgramMenuDateiNetzwerkeBearbeiten}); this.ProgramMenuDateiNetzwerke.Name = "ProgramMenuDateiNetzwerke"; - this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(129, 22); this.ProgramMenuDateiNetzwerke.Text = "Netzwerke"; // // ProgramMenuDateiNetzwerkeAnsehen // this.ProgramMenuDateiNetzwerkeAnsehen.Name = "ProgramMenuDateiNetzwerkeAnsehen"; - this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(130, 22); this.ProgramMenuDateiNetzwerkeAnsehen.Text = "Ansehen"; this.ProgramMenuDateiNetzwerkeAnsehen.Click += new System.EventHandler(this.ProgramMenuDateiNetzwerkeAnsehen_Click); // // ProgramMenuDateiNetzwerkeBearbeiten // this.ProgramMenuDateiNetzwerkeBearbeiten.Name = "ProgramMenuDateiNetzwerkeBearbeiten"; - this.ProgramMenuDateiNetzwerkeBearbeiten.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiNetzwerkeBearbeiten.Size = new System.Drawing.Size(130, 22); this.ProgramMenuDateiNetzwerkeBearbeiten.Text = "Bearbeiten"; // // ProgramMenuDateiEmail @@ -104,25 +105,25 @@ this.ProgramMenuDateiEmailAnsehen, this.ProgramMenuDateiEmailHinzufuegen}); this.ProgramMenuDateiEmail.Name = "ProgramMenuDateiEmail"; - this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(129, 22); this.ProgramMenuDateiEmail.Text = "E-Mail"; // // ProgramMenuDateiEmailAnsehen // this.ProgramMenuDateiEmailAnsehen.Name = "ProgramMenuDateiEmailAnsehen"; - this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(136, 22); this.ProgramMenuDateiEmailAnsehen.Text = "Ansehen"; // // ProgramMenuDateiEmailHinzufuegen // this.ProgramMenuDateiEmailHinzufuegen.Name = "ProgramMenuDateiEmailHinzufuegen"; - this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(136, 22); this.ProgramMenuDateiEmailHinzufuegen.Text = "Hinzufügen"; // // ProgramMenuDateiBeenden // this.ProgramMenuDateiBeenden.Name = "ProgramMenuDateiBeenden"; - this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(129, 22); this.ProgramMenuDateiBeenden.Text = "Beenden"; // // ProgramMenuDienst @@ -137,15 +138,21 @@ // ProgramMenuDienstStarten // this.ProgramMenuDienstStarten.Name = "ProgramMenuDienstStarten"; - this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(118, 22); this.ProgramMenuDienstStarten.Text = "Starten"; // // ProgramMenuDienstStoppen // this.ProgramMenuDienstStoppen.Name = "ProgramMenuDienstStoppen"; - this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(152, 22); + this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(118, 22); this.ProgramMenuDienstStoppen.Text = "Stoppen"; // + // ProgramMenuNetzwerke + // + this.ProgramMenuNetzwerke.Name = "ProgramMenuNetzwerke"; + this.ProgramMenuNetzwerke.Size = new System.Drawing.Size(74, 20); + this.ProgramMenuNetzwerke.Text = "Netzwerke"; + // // Statusbar // this.Statusbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -154,10 +161,27 @@ this.StatusbarDienst}); this.Statusbar.Location = new System.Drawing.Point(0, 240); this.Statusbar.Name = "Statusbar"; - this.Statusbar.Size = new System.Drawing.Size(284, 22); + this.Statusbar.Size = new System.Drawing.Size(459, 22); this.Statusbar.TabIndex = 1; this.Statusbar.Text = "statusStrip1"; // + // StatusbarLabel + // + this.StatusbarLabel.Name = "StatusbarLabel"; + this.StatusbarLabel.Size = new System.Drawing.Size(50, 17); + this.StatusbarLabel.Text = "Alles Ok"; + // + // StatusbarProgress + // + this.StatusbarProgress.Name = "StatusbarProgress"; + this.StatusbarProgress.Size = new System.Drawing.Size(50, 16); + // + // StatusbarDienst + // + this.StatusbarDienst.Name = "StatusbarDienst"; + this.StatusbarDienst.Size = new System.Drawing.Size(70, 17); + this.StatusbarDienst.Text = "Dienst Läuft"; + // // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; @@ -181,34 +205,21 @@ this.trayMenuNetzwerk.Name = "trayMenuNetzwerk"; this.trayMenuNetzwerk.Size = new System.Drawing.Size(32, 19); // - // StatusbarLabel + // StatusLog // - this.StatusbarLabel.Name = "StatusbarLabel"; - this.StatusbarLabel.Size = new System.Drawing.Size(50, 17); - this.StatusbarLabel.Text = "Alles Ok"; - // - // StatusbarDienst - // - this.StatusbarDienst.Name = "StatusbarDienst"; - this.StatusbarDienst.Size = new System.Drawing.Size(70, 17); - this.StatusbarDienst.Text = "Dienst Läuft"; - // - // StatusbarProgress - // - this.StatusbarProgress.Name = "StatusbarProgress"; - this.StatusbarProgress.Size = new System.Drawing.Size(50, 16); - // - // ProgramMenuNetzwerke - // - this.ProgramMenuNetzwerke.Name = "ProgramMenuNetzwerke"; - this.ProgramMenuNetzwerke.Size = new System.Drawing.Size(74, 20); - this.ProgramMenuNetzwerke.Text = "Netzwerke"; + this.StatusLog.FormattingEnabled = true; + this.StatusLog.HorizontalScrollbar = true; + this.StatusLog.Location = new System.Drawing.Point(12, 127); + this.StatusLog.Name = "StatusLog"; + this.StatusLog.Size = new System.Drawing.Size(435, 108); + this.StatusLog.TabIndex = 2; // // Netzmonitor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(284, 262); + this.ClientSize = new System.Drawing.Size(459, 262); + this.Controls.Add(this.StatusLog); this.Controls.Add(this.Statusbar); this.Controls.Add(this.ProgramMenu); this.MainMenuStrip = this.ProgramMenu; @@ -248,6 +259,7 @@ private System.Windows.Forms.ToolStripProgressBar StatusbarProgress; private System.Windows.Forms.ToolStripStatusLabel StatusbarDienst; private System.Windows.Forms.ToolStripMenuItem ProgramMenuNetzwerke; + private System.Windows.Forms.ListBox StatusLog; } } diff --git a/NetMonitorClient/Form1.cs b/NetMonitorClient/Form1.cs index db01b5f..0455491 100644 --- a/NetMonitorClient/Form1.cs +++ b/NetMonitorClient/Form1.cs @@ -12,6 +12,16 @@ namespace NetMonitorClient { public partial class Netzmonitor : Form { + private enum netsetter + { + Auto, + IpAuto, + Ip, + DnsAuto, + Dns, + WinsAuto, + Wins + } private ServiceControl sc; public Netzmonitor() { @@ -48,25 +58,25 @@ namespace NetMonitorClient if (ip == "auto" && dns == "auto" && wins == "auto") { - this.showPopup(this.sc.setNetworkAuto(adapter),name,"Netzwerk auf Auto"); + setNetworkAuto(adapter, name); } else { if (ip == "auto") - this.showPopup(this.sc.setNetworkIpAuto(adapter),name,"Ip auf Auto"); + setNetworkIpAuto(adapter, name); else - this.showPopup(this.sc.setNetworkIp(ip, subnet, gateway, adapter),name,"Ip: "+ip+";Subnet: "+subnet+";Gateway: "+gateway); - if(dns == "auto") - this.showPopup(this.sc.setNetworkDnsAuto(adapter),name,"Dns auf Auto"); + setNetworkIp(ip, subnet, gateway, adapter, name); + if (dns == "auto") + setNetworkDnsAuto(adapter, name); else - this.showPopup(this.sc.setNetworkDNS(dns, adapter),name,"Dns: "+dns); - if(wins == "auto") - this.showPopup(this.sc.setNetworkWinsAuto(adapter),name,"Wins auf Auto"); + setNetworkDns(dns, adapter, name); + if (wins == "auto") + setNetworkWinsAuto(adapter, name); else - this.showPopup(this.sc.setNetworkWINS(wins, adapter),name,"Wins: "+wins); + setNetworkWins(wins, adapter, name); } } - + private void showPopup(bool p, string titel, string text) { this.trayIcon.BalloonTipTitle = titel; diff --git a/NetMonitorClient/NetMonitorClient.csproj b/NetMonitorClient/NetMonitorClient.csproj index af5baa8..cda4d39 100644 --- a/NetMonitorClient/NetMonitorClient.csproj +++ b/NetMonitorClient/NetMonitorClient.csproj @@ -88,6 +88,9 @@ + + EditNetworks.cs + Form1.cs diff --git a/NetMonitorClient/Networks.cs b/NetMonitorClient/Networks.cs index 5d23023..f149cc0 100644 --- a/NetMonitorClient/Networks.cs +++ b/NetMonitorClient/Networks.cs @@ -9,6 +9,93 @@ 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");