using System; using System.Collections.Generic; using System.Linq; using System.Text; using BlubbFish.Utils; using NetMonitorUtils; using System.Windows.Forms; using System.Drawing; using System.Threading; namespace NetMonitorConsole { class Program { private static NotifyIcon trayi = new NotifyIcon(); static void Main(string[] args) { setNotifyIcon(); Console.WriteLine("NetMonitorConsole: Programm zum setzen der Netzwerkeinstellungen"); if (Factory.getArguments(args).HasArgumentType("-n")) { 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); } } 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); } private static void showBallonTooltip(string title, string text, ToolTipIcon toolTipIcon) { trayi.BalloonTipIcon = toolTipIcon; trayi.BalloonTipText = text; trayi.BalloonTipTitle = title; trayi.ShowBalloonTip(100); } } }