protected override void OnShown(EventArgs e) { base.OnShown(e); screenshot.Start((a) => Invoke(a), (b) => LogLine(b), () => { if (lasthe != null) // lasthe should have name and whereami, and an indication of commander { return(new Tuple <string, string, string>(lasthe.System.Name, lasthe.WhereAmI, lasthe.Commander?.Name ?? "Unknown")); } else { return(new Tuple <string, string, string>("Unknown", "Unknown", "Unknown")); } } ); screenshot.OnScreenshot += DisplayScreenshot; EDDDLLAssemblyFinder.AssemblyFindPath = EDDOptions.Instance.DLLAppDirectory(); // any needed assemblies from here AppDomain.CurrentDomain.AssemblyResolve += EDDDLLAssemblyFinder.AssemblyResolve; DLLManager = new EDDDLLManager(); DLLCallBacks = new EDDDLLInterfaces.EDDDLLIF.EDDCallBacks(); DLLCallBacks.ver = 2; DLLCallBacks.RequestHistory = DLLRequestHistory; DLLCallBacks.RunAction = (s1, s2) => { return(false); }; DLLCallBacks.GetShipLoadout = (s) => { return(null); }; string verstring = EDDOptions.Instance.Version; string[] options = new string[] { EDDDLLInterfaces.EDDDLLIF.FLAG_HOSTNAME + "EDLITE", EDDDLLInterfaces.EDDDLLIF.FLAG_JOURNALVERSION + "2", EDDDLLInterfaces.EDDDLLIF.FLAG_CALLBACKVERSION + "2", }; string alloweddlls = EDDConfig.Instance.DLLPermissions; Tuple <string, string, string> res = DLLManager.Load(EDDOptions.Instance.DLLAppDirectory(), verstring, options, DLLCallBacks, alloweddlls); if (res.Item3.HasChars()) // new DLLs { string[] list = res.Item3.Split(','); bool changed = false; foreach (var dll in list) { if (ExtendedControls.MessageBoxTheme.Show(this, string.Format(("The following application extension DLL have been found" + Environment.NewLine + "Do you wish to allow these to be used?" + Environment.NewLine + "{0} " + Environment.NewLine ).T(EDTx.EDDiscoveryForm_DLLW), dll), "Warning".T(EDTx.Warning), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { alloweddlls = alloweddlls.AppendPrePad("+" + dll, ","); changed = true; } else { alloweddlls = alloweddlls.AppendPrePad("-" + dll, ","); } } EDDConfig.Instance.DLLPermissions = alloweddlls; if (changed) { DLLManager.UnLoad(); res = DLLManager.Load(EDDOptions.Instance.DLLAppDirectory(), verstring, options, DLLCallBacks, alloweddlls); } } if (res.Item1.HasChars()) { LogLine(string.Format("DLLs loaded: {0}".T(EDTx.EDDiscoveryForm_DLLL), res.Item1)); } if (res.Item2.HasChars()) { LogLine(string.Format("DLLs failed to load: {0}".T(EDTx.EDDiscoveryForm_DLLF), res.Item2)); } //EDDOptions.Instance.CheckRelease = true; // use this to force check for debugging Installer.CheckForNewInstallerAsync((rel) => // in thread { BeginInvoke((MethodInvoker) delegate { LogLine(string.Format("New EDDLite installer available: {0}".T(EDTx.EDDiscoveryForm_NI), rel.ReleaseName)); labelInfoBoxTop.Text = "New Release Available!".T(EDTx.EDDiscoveryForm_NRA); if (ExtendedControls.MessageBoxTheme.Show("New EDDLite Available, please upgrade!", "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { System.Diagnostics.Process.Start(Properties.Resources.URLProjectReleases); } }); }); controller.Start(a => BeginInvoke(a)); }
public EDDLiteForm() { InitializeComponent(); var appdata = EDDOptions.Instance.AppDataDirectory; // FORCE ED options to Instance - do not remove. System.Diagnostics.Debug.WriteLine("App data " + appdata); UserDatabase.Instance.Start("UserDB"); UserDatabase.Instance.Initialize(); BaseUtils.Icons.IconSet.CreateSingleton(); BaseUtils.Icons.IconSet.Instance.Add("Default", Properties.Resources.Logo); // to satisfy the journal, add the backup Default in EDDConfig.Instance.Update(); EDDLiteTheme.Init(); EDDLiteTheme.Instance.SetThemeByName(UserDatabase.Instance.GetSettingString("Theme", "EDSM")); ApplyTheme(); RestoreFormPositionRegKey = "MainForm"; extStatusStrip.Font = this.Font; label_version.Text = EDDOptions.Instance.VersionDisplayString; labelGameDateTime.Text = ""; labelInfoBoxTop.Text = ""; extButtonEDSM.Enabled = extButtonEDSY.Enabled = extButtonCoriolis.Enabled = false; dataGridViewCommanders.RowsDefaultCellStyle.SelectionBackColor = EDDLiteTheme.Instance.GridCellBack; // hide selection dataGridViewCommanders.RowsDefaultCellStyle.SelectionForeColor = EDDLiteTheme.Instance.GridCellText; screenshot = new ScreenShotConverter(); screenshotenableToolStripMenuItem.Checked = screenshot.AutoConvert; screenshotenableToolStripMenuItem.CheckedChanged += new System.EventHandler(this.enableToolStripMenuItem_CheckedChanged); controller = new EDDLiteController(); controller.ProgressEvent += (s) => { toolStripStatus.Text = s; }; controller.Refresh += ReadJournals; controller.NewEntry += HistoryEvent; controller.LogLine += LogLine; if (!EDDOptions.Instance.DisableTimeDisplay) { datetimetimer = new Timer(); datetimetimer.Interval = 1000; datetimetimer.Tick += (sv, ev) => { DateTime gameutc = DateTime.UtcNow.AddYears(1286); labelGameDateTime.Text = gameutc.ToShortDateString() + " " + gameutc.ToShortTimeString(); }; datetimetimer.Start(); timeToolStripMenuItem.Checked = labelGameDateTime.Visible = UserDatabase.Instance.GetSettingBool("TimeDisplay", true); this.timeToolStripMenuItem.CheckStateChanged += new System.EventHandler(this.timeToolStripMenuItem_CheckStateChanged); } splitContainerCmdrDataLogs.SplitterDistance(UserDatabase.Instance.GetSettingDouble("CmdrDataLogSplitter", 0.1)); splitContainerDataLogs.SplitterDistance(UserDatabase.Instance.GetSettingDouble("DataLogSplitter", 0.8)); EliteDangerousCore.IGAU.IGAUClass.SoftwareName = EliteDangerousCore.EDDN.EDDNClass.SoftwareName = EliteDangerousCore.Inara.InaraClass.SoftwareName = EDSMClass.SoftwareName = "EDDLite"; DLLManager = new EDDDLLManager(); DLLCallBacks = new EDDDLLIF.EDDCallBacks(1, DLLRequestHistory, (s1, s2) => { return(false); }, null); }