public MainForm(Config config, Updater updater) { InitializeComponent(); this.config = config; this.updater = updater; this.LoadSettings(); base.Text = base.Text + " " + Version; this.lblVersion.Text = Version; this.lblExtra.Parent = this.picLogo; this.lblVersion.Parent = this.picLogo; this.trayIcon.Icon = this.Icon; this.server = new HttpServer(config.AppBaseDir + @"\https\localhost.pfx"); this.server.BindToAllInterfaces = this.cbBindToAll.Checked; this.server.UseHttps = this.cbHttps.Checked; this.server.LogAllRequests = this.cbLogAllRequests.Checked; this.scriptRepository = new ScriptRepository(config.AppBaseDir); this.scriptRepository.Log = this.Log; this.servlets = new Servlets(this.server, this.scriptRepository, this.Log, this, config.AppBaseDir); this.UpdateServletSettings(); this.ActiveControl = this.comboEmail; }
static void Main() { AppDomain.CurrentDomain.UnhandledException += (sender, args) => HandleException(args.ExceptionObject as Exception); Application.ThreadException += (sender, args) => HandleException(args.Exception); try { bool isPostUpdate = Environment.CommandLine == PostUpdateSwitch; Config config = new Config(); config.LoadSettings(); if (!isPostUpdate && ActivateRunningInstance(config.GetBool("https"))) return; Application.EnableVisualStyles(); var updater = new Updater(config); if (!isPostUpdate) updater.Run(); var mainForm = new MainForm(config, updater); if (Environment.CommandLine.Contains(WinServiceSwitch)) WinService.Start(mainForm); else Application.Run(mainForm); } catch (Exception ex) { HandleException(ex); } }