public void PromptUserForArtemisPath() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } //if (Application.Current.Dispatcher != System.Windows.Threading.Dispatcher.CurrentDispatcher) //{ // Application.Current.Dispatcher.Invoke(new Action(PromptUserForArtemisPath)); //} //else //{ ArtemisInstallPath = Locations.FindArtemisInstallPath(); if (string.IsNullOrEmpty(ArtemisInstallPath) || !Directory.Exists(ArtemisInstallPath)) { //Application.Current.Dispatcher.Invoke( // new Func<string, MessageBoxButton, MessageBoxImage, MessageBoxResult>(Locations.MessageBoxShow), // AMLResources.Properties.Resources.CannotLocateArtemisInstall // + DataStrings.CRCR // + AMLResources.Properties.Resources.PleaseSpecifyLocation, // MessageBoxButton.OK, MessageBoxImage.Hand); //MessageBox.Show(AMLResources.Properties.Resources.CannotLocateArtemisInstall // + DataStrings.CRCR // + AMLResources.Properties.Resources.PleaseSpecifyLocation, "Artemis Mod Loader", // MessageBoxButton.OK, MessageBoxImage.Hand); Locations.MessageBoxShow( AMLResources.Properties.Resources.CannotLocateArtemisInstall + DataStrings.CRCR + AMLResources.Properties.Resources.PleaseSpecifyLocation, MessageBoxButton.OK, MessageBoxImage.Hand); using (System.Windows.Forms.FolderBrowserDialog diag = new System.Windows.Forms.FolderBrowserDialog()) { diag.Description = "Cannot locate the Artemis installation. Please specify the location where Artemis is installed."; diag.ShowNewFolderButton = false; if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ArtemisInstallPath = diag.SelectedPath; Save(); } } } else { Save(); } //} if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
static UserConfiguration() { bool DataConverted = false; if (File.Exists(Locations.ConfigFile)) { using (StreamReader sr = new StreamReader(Locations.ConfigFile)) { string sLine = sr.ReadLine(); if (!sLine.Contains("=")) { Current = new UserConfiguration(); Current.ArtemisInstallPath = sLine; if (!string.IsNullOrEmpty(Current.ArtemisInstallPath)) { if (!File.Exists(Path.Combine(Current.ArtemisInstallPath, Locations.ArtemisEXE))) { Current.ArtemisInstallPath = Locations.FindArtemisInstallPath(); } } if (sLine != null) { sLine = sr.ReadLine(); if (!string.IsNullOrEmpty(sLine)) { bool b; if (bool.TryParse(sLine, out b)) { Current.UseArtemisExtender = b; } } if (sLine != null) { sLine = sr.ReadLine(); Current.ArtemisExtenderPath = sLine; if (sLine != null) { sLine = sr.ReadLine(); Current.ArtemisExtenderCopy = sLine; } } } DataConverted = true; } } } if (DataConverted) { FileHelper.DeleteFile(Locations.ConfigFile); Current.Save(); } else { Current = INIConverter.ToObject(Locations.ConfigFile, new UserConfiguration()) as UserConfiguration; } if (string.IsNullOrEmpty(Current.ArtemisExtenderCopy) || !File.Exists(Current.ArtemisExtenderCopy)) { Current.UseArtemisExtender = false; } Current.Original = new UserConfiguration(); Current.AcceptChanges(); }