103 lines
3.3 KiB
C#
103 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Collections;
|
|
|
|
namespace NetMonitorClient
|
|
{
|
|
public partial class Netzmonitor : Form
|
|
{
|
|
private enum netsetter
|
|
{
|
|
Auto,
|
|
IpAuto,
|
|
Ip,
|
|
DnsAuto,
|
|
Dns,
|
|
WinsAuto,
|
|
Wins
|
|
}
|
|
private ServiceControl sc;
|
|
public Netzmonitor()
|
|
{
|
|
InitializeComponent();
|
|
InitNetworks();
|
|
this.sc = new ServiceControl("NetMonitorServer");
|
|
}
|
|
|
|
private void Netzmonitor_Resize(object sender, System.EventArgs e)
|
|
{
|
|
if (this.WindowState == FormWindowState.Minimized)
|
|
{
|
|
this.ShowInTaskbar = false;
|
|
this.WindowState = FormWindowState.Minimized;
|
|
}
|
|
}
|
|
|
|
private void trayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
{
|
|
this.WindowState = FormWindowState.Normal;
|
|
this.ShowInTaskbar = true;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
private void showPopup(bool p, string titel, string text)
|
|
{
|
|
this.trayIcon.BalloonTipTitle = titel;
|
|
if (p)
|
|
{
|
|
this.trayIcon.BalloonTipIcon = ToolTipIcon.Info;
|
|
this.trayIcon.BalloonTipText = text + " gesetzt";
|
|
}
|
|
else
|
|
{
|
|
this.trayIcon.BalloonTipIcon = ToolTipIcon.Error;
|
|
this.trayIcon.BalloonTipText = text + " nicht gesetzt";
|
|
}
|
|
this.StatusbarLabel.Text = this.trayIcon.BalloonTipText;
|
|
this.trayIcon.ShowBalloonTip(200);
|
|
}
|
|
|
|
private void ProgramMenuDateiNetzwerkeAnsehen_Click(object sender, EventArgs e)
|
|
{
|
|
new EditNetworks(EditNetworks.Options.Show).ShowDialog(this);
|
|
}
|
|
}
|
|
}
|