/// <summary> /// JSONReaderSingleton method that creates only one object of JSONReaderSingleton /// </summary> /// <param name="JournalsDirPath">Journals directory path</param> /// <param name="JournalsDirPathOutput">Output of constructor which has Journals dir path inside method completition</param> /// <param name="ScreenShotBool">Bool that tells JSONReader if he can produce screenshots</param> /// <returns></returns> public static JSONReaderSingleton GetInstance(string JournalsDirPath, out string JournalsDirPathOutput, bool ScreenShotBool) { string temp = null; if (JSONReaderInstance == null) { JSONReaderInstance = new JSONReaderSingleton(JournalsDirPath, out temp, ScreenShotBool); } else { MessageBox.Show("Warning: Cant create more then one object of JSONReaderSingleton"); log.Warn("Warning: Tried to create more then one object of JSONReaderSingleton"); } JournalsDirPathOutput = temp; return(JSONReaderInstance); }
private void Form1_Load(object sender, EventArgs e) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); //getting a logfiles directory path string directoryPath; if (ConfigurationManager.AppSettings["FirstRun"].Equals("true")) { //finds path to Users folder ("C:\Users\<user>)" which is then used to find default path of ED journals directoryPath = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName; if (Environment.OSVersion.Version.Major >= 6) { directoryPath = Directory.GetParent(directoryPath).ToString() + @"\Saved Games\Frontier Developments\Elite Dangerous"; } ChangeConfig("JournalsDirPath", directoryPath); ChangeConfig("FirstRun", "false"); } else { directoryPath = ConfigurationManager.AppSettings["JournalsDirPath"]; } bool.TryParse(ConfigurationManager.AppSettings["ScreenShotsPermission"], out bool ScreenShotsPermission); try { reader = JSONReaderSingleton.GetInstance(directoryPath, out string directoryPathOutput, ScreenShotsPermission); //saves Journals directory path to config if its different if (!directoryPathOutput.Equals(ConfigurationManager.AppSettings["JournalsDirPath"])) { ChangeConfig("JournalsDirPath", directoryPath); } } catch (ArgumentException ex) { log.Info(ex.Message, ex); throw; } KillCounter.Text = "Scanning logs please wait"; StartAsyncMethods(); }