87 lines
3.2 KiB
C#
87 lines
3.2 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 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")
|
|
{
|
|
this.showPopup(this.sc.setNetworkAuto(adapter),name,"Netzwerk auf Auto");
|
|
}
|
|
else
|
|
{
|
|
if (ip == "auto")
|
|
this.showPopup(this.sc.setNetworkIpAuto(adapter),name,"Ip auf Auto");
|
|
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");
|
|
else
|
|
this.showPopup(this.sc.setNetworkDNS(dns, adapter),name,"Dns: "+dns);
|
|
if(wins == "auto")
|
|
this.showPopup(this.sc.setNetworkWinsAuto(adapter),name,"Wins auf Auto");
|
|
else
|
|
this.showPopup(this.sc.setNetworkWINS(wins, adapter),name,"Wins: "+wins);
|
|
}
|
|
}
|
|
|
|
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.trayIcon.ShowBalloonTip(1000);
|
|
}
|
|
}
|
|
}
|