Konsolenversion
This commit is contained in:
@@ -14,7 +14,8 @@ namespace NetMonitorClient
|
||||
{
|
||||
public enum Options
|
||||
{
|
||||
Show
|
||||
Show,
|
||||
Edit
|
||||
}
|
||||
internal enum RWFlag
|
||||
{
|
||||
@@ -35,6 +36,10 @@ namespace NetMonitorClient
|
||||
{
|
||||
this.acess = RWFlag.Read;
|
||||
}
|
||||
if (option == Options.Edit)
|
||||
{
|
||||
this.acess = RWFlag.Write;
|
||||
}
|
||||
InitializeComponent();
|
||||
ReadNetworksSettings();
|
||||
SetRWSettings();
|
||||
@@ -60,6 +65,24 @@ namespace NetMonitorClient
|
||||
this.RadioWinsAuto.Enabled = false;
|
||||
this.RadioWinsManu.Enabled = false;
|
||||
}
|
||||
if (this.acess == RWFlag.Write)
|
||||
{
|
||||
this.BoxDns.ReadOnly = false;
|
||||
this.BoxGateway.ReadOnly = false;
|
||||
this.BoxIpAdresse.ReadOnly = false;
|
||||
this.BoxName.ReadOnly = false;
|
||||
this.BoxSubnet.ReadOnly = false;
|
||||
this.BoxWins.ReadOnly = false;
|
||||
this.Text = "Netzwerke Ändern";
|
||||
this.RadioAllAuto.Enabled = true;
|
||||
this.RadioAllManu.Enabled = true;
|
||||
this.RadioDnsAuto.Enabled = true;
|
||||
this.RadioDnsManu.Enabled = true;
|
||||
this.RadioIpAuto.Enabled = true;
|
||||
this.RadioIpManu.Enabled = true;
|
||||
this.RadioWinsAuto.Enabled = true;
|
||||
this.RadioWinsManu.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadNetworksSettings()
|
||||
|
||||
Generated
+10
-9
@@ -83,21 +83,22 @@
|
||||
this.ProgramMenuDateiNetzwerkeAnsehen,
|
||||
this.ProgramMenuDateiNetzwerkeBearbeiten});
|
||||
this.ProgramMenuDateiNetzwerke.Name = "ProgramMenuDateiNetzwerke";
|
||||
this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(129, 22);
|
||||
this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiNetzwerke.Text = "Netzwerke";
|
||||
//
|
||||
// ProgramMenuDateiNetzwerkeAnsehen
|
||||
//
|
||||
this.ProgramMenuDateiNetzwerkeAnsehen.Name = "ProgramMenuDateiNetzwerkeAnsehen";
|
||||
this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(130, 22);
|
||||
this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(152, 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(130, 22);
|
||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Text = "Bearbeiten";
|
||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Click += new System.EventHandler(this.ProgramMenuDateiNetzwerkeBearbeiten_Click);
|
||||
//
|
||||
// ProgramMenuDateiEmail
|
||||
//
|
||||
@@ -105,25 +106,25 @@
|
||||
this.ProgramMenuDateiEmailAnsehen,
|
||||
this.ProgramMenuDateiEmailHinzufuegen});
|
||||
this.ProgramMenuDateiEmail.Name = "ProgramMenuDateiEmail";
|
||||
this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(129, 22);
|
||||
this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiEmail.Text = "E-Mail";
|
||||
//
|
||||
// ProgramMenuDateiEmailAnsehen
|
||||
//
|
||||
this.ProgramMenuDateiEmailAnsehen.Name = "ProgramMenuDateiEmailAnsehen";
|
||||
this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(136, 22);
|
||||
this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiEmailAnsehen.Text = "Ansehen";
|
||||
//
|
||||
// ProgramMenuDateiEmailHinzufuegen
|
||||
//
|
||||
this.ProgramMenuDateiEmailHinzufuegen.Name = "ProgramMenuDateiEmailHinzufuegen";
|
||||
this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(136, 22);
|
||||
this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiEmailHinzufuegen.Text = "Hinzufügen";
|
||||
//
|
||||
// ProgramMenuDateiBeenden
|
||||
//
|
||||
this.ProgramMenuDateiBeenden.Name = "ProgramMenuDateiBeenden";
|
||||
this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(129, 22);
|
||||
this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDateiBeenden.Text = "Beenden";
|
||||
//
|
||||
// ProgramMenuDienst
|
||||
@@ -138,13 +139,13 @@
|
||||
// ProgramMenuDienstStarten
|
||||
//
|
||||
this.ProgramMenuDienstStarten.Name = "ProgramMenuDienstStarten";
|
||||
this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(118, 22);
|
||||
this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDienstStarten.Text = "Starten";
|
||||
//
|
||||
// ProgramMenuDienstStoppen
|
||||
//
|
||||
this.ProgramMenuDienstStoppen.Name = "ProgramMenuDienstStoppen";
|
||||
this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(118, 22);
|
||||
this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(152, 22);
|
||||
this.ProgramMenuDienstStoppen.Text = "Stoppen";
|
||||
//
|
||||
// ProgramMenuNetzwerke
|
||||
|
||||
@@ -12,16 +12,6 @@ namespace NetMonitorClient
|
||||
{
|
||||
public partial class Netzmonitor : Form
|
||||
{
|
||||
private enum netsetter
|
||||
{
|
||||
Auto,
|
||||
IpAuto,
|
||||
Ip,
|
||||
DnsAuto,
|
||||
Dns,
|
||||
WinsAuto,
|
||||
Wins
|
||||
}
|
||||
private ServiceControl sc;
|
||||
public Netzmonitor()
|
||||
{
|
||||
@@ -48,33 +38,10 @@ namespace NetMonitorClient
|
||||
private void TrayMenuNet_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToolStripMenuItem Item = (ToolStripMenuItem)sender;
|
||||
String name = networkini.getValue(Item.Name, "Name");
|
||||
String ip = networkini.getValue(Item.Name, "Ip");
|
||||
String subnet = networkini.getValue(Item.Name, "Subnet");
|
||||
String gateway = networkini.getValue(Item.Name, "Gateway");
|
||||
String dns = networkini.getValue(Item.Name, "Dns");
|
||||
String wins = networkini.getValue(Item.Name, "Wins");
|
||||
String adapter = networkini.getValue(Item.Name, "Adapter");
|
||||
|
||||
if (ip == "auto" && dns == "auto" && wins == "auto")
|
||||
{
|
||||
setNetworkAuto(adapter, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip == "auto")
|
||||
setNetworkIpAuto(adapter, name);
|
||||
else
|
||||
setNetworkIp(ip, subnet, gateway, adapter, name);
|
||||
if (dns == "auto")
|
||||
setNetworkDnsAuto(adapter, name);
|
||||
else
|
||||
setNetworkDns(dns, adapter, name);
|
||||
if (wins == "auto")
|
||||
setNetworkWinsAuto(adapter, name);
|
||||
else
|
||||
setNetworkWins(wins, adapter, name);
|
||||
}
|
||||
Networksetter netsetter = new Networksetter(Item.Name, networkini, sc);
|
||||
netsetter.setNetwork();
|
||||
this.showPopup(netsetter.getPopupBool(), netsetter.getPopupTitel(), netsetter.getPopupText());
|
||||
this.StatusLog.Items.AddRange(netsetter.getLog().ToArray());
|
||||
}
|
||||
|
||||
private void showPopup(bool p, string titel, string text)
|
||||
@@ -98,5 +65,10 @@ namespace NetMonitorClient
|
||||
{
|
||||
new EditNetworks(EditNetworks.Options.Show).ShowDialog(this);
|
||||
}
|
||||
|
||||
private void ProgramMenuDateiNetzwerkeBearbeiten_Click(object sender, EventArgs e)
|
||||
{
|
||||
new EditNetworks(EditNetworks.Options.Edit).ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace NetMonitorClient
|
||||
{
|
||||
class InIReader
|
||||
public class InIReader
|
||||
{
|
||||
private StreamReader file;
|
||||
private ArrayList cont = new ArrayList();
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>E:\Programme\NetMonitor\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -86,6 +86,7 @@
|
||||
<Compile Include="Networks.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Networksetter.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="EditNetworks.resx">
|
||||
|
||||
@@ -9,93 +9,6 @@ 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");
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NetMonitorClient
|
||||
{
|
||||
public class Networksetter
|
||||
{
|
||||
private ServiceControl sc;
|
||||
private InIReader networkini;
|
||||
private string net_name;
|
||||
private List<string> loglist;
|
||||
|
||||
private bool Pstatus;
|
||||
private string Pname;
|
||||
private string Ptext;
|
||||
private enum netsetter
|
||||
{
|
||||
Auto,
|
||||
IpAuto,
|
||||
Ip,
|
||||
DnsAuto,
|
||||
Dns,
|
||||
WinsAuto,
|
||||
Wins
|
||||
}
|
||||
public Networksetter(string name, InIReader ini, ServiceControl serv)
|
||||
{
|
||||
this.net_name = name;
|
||||
this.networkini = ini;
|
||||
loglist = new List<string>();
|
||||
this.sc = serv;
|
||||
}
|
||||
public void setNetwork()
|
||||
{
|
||||
String name = networkini.getValue(net_name, "Name");
|
||||
String ip = networkini.getValue(net_name, "Ip");
|
||||
String subnet = networkini.getValue(net_name, "Subnet");
|
||||
String gateway = networkini.getValue(net_name, "Gateway");
|
||||
String dns = networkini.getValue(net_name, "Dns");
|
||||
String wins = networkini.getValue(net_name, "Wins");
|
||||
String adapter = networkini.getValue(net_name, "Adapter");
|
||||
|
||||
if (ip == "auto" && dns == "auto" && wins == "auto")
|
||||
{
|
||||
setNetworkAuto(adapter, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip == "auto")
|
||||
setNetworkIpAuto(adapter, name);
|
||||
else
|
||||
setNetworkIp(ip, subnet, gateway, adapter, name);
|
||||
if (dns == "auto")
|
||||
setNetworkDnsAuto(adapter, name);
|
||||
else
|
||||
setNetworkDns(dns, adapter, name);
|
||||
if (wins == "auto")
|
||||
setNetworkWinsAuto(adapter, name);
|
||||
else
|
||||
setNetworkWins(wins, adapter, name);
|
||||
}
|
||||
}
|
||||
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;
|
||||
List<string> text = new List<string>();
|
||||
if (option == netsetter.Ip)
|
||||
{
|
||||
text.Add("Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway);
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkIp(ip, subnet, gateway, adapter);
|
||||
}
|
||||
if (option == netsetter.Auto)
|
||||
{
|
||||
text.Add("Netzwerk auf Auto");
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkAuto(adapter);
|
||||
}
|
||||
if (option == netsetter.IpAuto)
|
||||
{
|
||||
text.Add("Ip auf Auto");
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkIpAuto(adapter);
|
||||
}
|
||||
if (option == netsetter.DnsAuto)
|
||||
{
|
||||
text.Add("Dns auf Auto");
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkDnsAuto(adapter);
|
||||
}
|
||||
if (option == netsetter.WinsAuto)
|
||||
{
|
||||
text.Add("Wins auf Auto");
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkWinsAuto(adapter);
|
||||
}
|
||||
if (option == netsetter.Dns)
|
||||
{
|
||||
text.Add("Dns: " + dns);
|
||||
loglist.Add("Gesendet: " + text);
|
||||
status = this.sc.setNetworkDNS(dns, adapter);
|
||||
}
|
||||
if (option == netsetter.Wins)
|
||||
{
|
||||
text.Add("Wins: " + wins);
|
||||
loglist.Add("Gesendet: " + text);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
status = this.sc.setNetworkWINS(wins, adapter);
|
||||
}
|
||||
loglist.Add("Antwort: " + ((status) ? "Ok" : "Fehler"));
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
setPopup(status, name, String.Join("\n",text.ToArray()));
|
||||
}
|
||||
|
||||
private void setPopup(bool status, string name, string text)
|
||||
{
|
||||
this.Pstatus = status;
|
||||
this.Pname = name;
|
||||
this.Ptext = text;
|
||||
}
|
||||
|
||||
internal bool getPopupBool()
|
||||
{
|
||||
return this.Pstatus;
|
||||
}
|
||||
|
||||
internal string getPopupTitel()
|
||||
{
|
||||
return this.Pname;
|
||||
}
|
||||
|
||||
internal string getPopupText()
|
||||
{
|
||||
return this.Ptext;
|
||||
}
|
||||
|
||||
public List<string> getLog()
|
||||
{
|
||||
return this.loglist;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using System.Net;
|
||||
|
||||
namespace NetMonitorClient
|
||||
{
|
||||
class ServiceControl
|
||||
public class ServiceControl
|
||||
{
|
||||
private UdpClient net_send;
|
||||
private IPEndPoint net_send_port;
|
||||
|
||||
Reference in New Issue
Block a user