netmonitor/NetMonitorClient/Form1.cs

64 lines
2.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;
namespace NetMonitorClient
{
public partial class Netzmonitor : Form
{
private ServiceControl sc;
public Netzmonitor()
{
InitializeComponent();
InitNetworks();
this.sc = new ServiceControl("NetMonitorServer");
}
private void trayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
private void TrayMenuNet_Click(object sender, EventArgs e)
{
ToolStripMenuItem Item = (ToolStripMenuItem)sender;
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");
String ret = "";
if (ip == "auto" && dns == "auto" && wins == "auto")
{
if (this.sc.setNetworkAuto(adapter))
ret = Item.Name+";Netzwerk auf Auto gesetzt";
}
else
{
if (ip == "auto")
this.sc.setNetworkIpAuto(adapter);
else
this.sc.setNetworkIp(ip, subnet, gateway, adapter);
if(dns == "auto")
this.sc.setNetworkDnsAuto(adapter);
else
this.sc.setNetworkDNS(dns, adapter);
if(wins == "auto")
this.sc.setNetworkWinsAuto(adapter);
else
this.sc.setNetworkWINS(wins, adapter);
}
this.trayIcon.BalloonTipIcon = ToolTipIcon.Info;
this.trayIcon.BalloonTipTitle = ret.Split(';')[0];
this.trayIcon.BalloonTipText = ret.Split(';')[1];
}
}
}