netmonitor/NetMonitorClient/Form1.cs

76 lines
2.8 KiB
C#
Raw Normal View History

2010-04-15 23:43:12 +02:00
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;
2010-04-21 13:48:40 +02:00
namespace NetMonitorClient
2010-04-15 23:43:12 +02:00
{
public partial class Netzmonitor : Form
{
2010-04-16 11:51:46 +02:00
private ServiceControl sc;
2010-04-15 23:43:12 +02:00
public Netzmonitor()
{
InitializeComponent();
InitNetworks();
2010-04-26 12:46:03 +02:00
this.sc = new ServiceControl("NetMonitorServer");
2010-04-16 11:51:46 +02:00
}
private void trayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
private void TrayMenuNet_Click(object sender, EventArgs e)
2010-04-16 11:51:46 +02:00
{
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");
2010-05-19 11:44:31 +02:00
if (ip == "auto" && dns == "auto" && wins == "auto")
{
this.showPopup(this.sc.setNetworkAuto(adapter),name,"Netzwerk auf Auto");
2010-05-19 11:44:31 +02:00
}
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);
2010-04-15 23:43:12 +02:00
}
}
}