2010-07-15 02:41:08 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2014-07-11 16:38:10 +02:00
|
|
|
|
using BlubbFish.Utils;
|
|
|
|
|
using NetMonitorUtils;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Threading;
|
2010-07-15 02:41:08 +02:00
|
|
|
|
|
|
|
|
|
namespace NetMonitorConsole
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2014-07-11 16:38:10 +02:00
|
|
|
|
private static NotifyIcon trayi = new NotifyIcon();
|
2010-07-15 02:41:08 +02:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2014-07-11 16:38:10 +02:00
|
|
|
|
setNotifyIcon();
|
2010-07-15 02:41:08 +02:00
|
|
|
|
Console.WriteLine("NetMonitorConsole: Programm zum setzen der Netzwerkeinstellungen");
|
2014-07-11 16:38:10 +02:00
|
|
|
|
if (Factory.getArguments(args).HasArgumentType("-n"))
|
2010-07-15 02:41:08 +02:00
|
|
|
|
{
|
2014-07-11 16:38:10 +02:00
|
|
|
|
NetworkSetter netsetter = new NetworkSetter("network.ini", "config.ini");
|
|
|
|
|
netsetter.eventInfo += netsetter_eventInfo;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
netsetter.setNetwork(Factory.getArguments(args).GetArgumentData("-n"));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Fehler: " + e.Message);
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
Factory.getLogger().setLine("### NetMonitorConsole Debug logging dump:");
|
|
|
|
|
Factory.getLogger().setArray(netsetter.getLog(OwnObject.LogLevel.Debug, true, true).ToArray());
|
|
|
|
|
showBallonTooltip("NetMonitor Fehler", "Fehler in die Logdatei geschrieben", ToolTipIcon.Warning);
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
}
|
2010-07-15 02:41:08 +02:00
|
|
|
|
}
|
2014-07-11 16:38:10 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
showBallonTooltip("NetMonitor Fehler", "usage: NetMonitorConsole.exe: -n [networkid]", ToolTipIcon.Error);
|
|
|
|
|
Thread.Sleep(10000);
|
|
|
|
|
}
|
|
|
|
|
trayi.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void setNotifyIcon()
|
|
|
|
|
{
|
|
|
|
|
trayi.Visible = true;
|
|
|
|
|
trayi.Icon = new Icon(NetMonitorConsole.Properties.Resources.TrayIcon, 40, 40);
|
|
|
|
|
trayi.Text = "NetMonitorConsole";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void netsetter_eventInfo(string location, string message, OwnObject.LogLevel type, DateTime date)
|
|
|
|
|
{
|
|
|
|
|
ToolTipIcon i = ToolTipIcon.None;
|
|
|
|
|
if (type >= OwnObject.LogLevel.Error) { i = ToolTipIcon.Error; }
|
|
|
|
|
else if (type >= OwnObject.LogLevel.Warn) { i = ToolTipIcon.Warning; }
|
|
|
|
|
else { i = ToolTipIcon.Info; }
|
|
|
|
|
showBallonTooltip("NetMonitor " + type, message, i);
|
2010-07-15 02:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 16:38:10 +02:00
|
|
|
|
private static void showBallonTooltip(string title, string text, ToolTipIcon toolTipIcon)
|
2010-07-15 02:41:08 +02:00
|
|
|
|
{
|
2014-07-11 16:38:10 +02:00
|
|
|
|
trayi.BalloonTipIcon = toolTipIcon;
|
|
|
|
|
trayi.BalloonTipText = text;
|
|
|
|
|
trayi.BalloonTipTitle = title;
|
|
|
|
|
trayi.ShowBalloonTip(100);
|
2010-07-15 02:41:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|