public static void Init(string engine)
{
System.Threading.Thread.CurrentThread.Name = "Main";
Trace.Call(engine);
Assembly asm = Assembly.GetAssembly(typeof(Frontend));
AssemblyName asm_name = asm.GetName(false);
AssemblyProductAttribute pr = (AssemblyProductAttribute)asm.
GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];
_Version = asm_name.Version;
_VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;
// this always calls abort() :(((
//StflApi.stfl_error_action("print");
#if LOG4NET
_Logger.Info(_VersionString + " starting");
#endif
_MainWindow = new MainWindow();
_FrontendConfig = new FrontendConfig(UIName);
// loading and setting defaults
_FrontendConfig.Load();
if (_FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] == null) {
_FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] = "#000000";
}
_FrontendConfig.Save();
if (_FrontendConfig.IsCleanConfig) {
// first start assistant
} else {
if (String.IsNullOrEmpty(engine) || engine == "local") {
InitLocalEngine();
} else {
InitRemoteEngine(engine);
}
}
while (true) {
// wait maximum for 500ms, to force a refresh even when
// not hitting a key
_MainWindow.Run(500);
}
}
public static void Main(string[] args) { #if LOG4NET // initialize log level log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository(); repo.Threshold = log4net.Core.Level.Error; #endif bool debug = false; bool listEngines = false; string engine = "local"; InitLocale(); OptionSet parser = new OptionSet(); parser.Add( "d|debug", _("Enable debug output"), delegate(string value) { debug = true; } ); parser.Add( "e|engine=", _("Engine to connect to"), delegate(string value) { engine = value; } ); parser.Add( "l|list-engines", _("List available engines"), delegate(string value) { listEngines = true; } ); parser.Add( "h|help", _("Show this help"), delegate(string value) { Console.WriteLine(_("Usage: smuxi-frontend-stfl [options]")); Console.WriteLine(); Console.WriteLine(_("Options:")); parser.WriteOptionDescriptions(Console.Out); Environment.Exit(0); } ); parser.Add( "<>", delegate(string value) { throw new OptionException( String.Format( _("Unknown option: '{0}'"), value ), value ); } ); try { parser.Parse(args); #if LOG4NET if (debug) { repo.Threshold = log4net.Core.Level.Debug; } #endif } catch (OptionException ex) { Console.Error.WriteLine(_("Command line error: {0}"), ex.Message); Environment.Exit(1); } if (listEngines) { Console.WriteLine(_("Available Engines:")); var config = new FrontendConfig(Frontend.UIName); config.Load(); foreach (var entry in (string[])config["Engines/Engines"]) { Console.WriteLine("\t{0}", entry); } return; } try { Frontend.Init(engine); } catch (Exception e) { #if LOG4NET _Logger.Fatal(e); #endif if (SysDiag.Debugger.IsAttached) { throw; } } }