static void OnArtemisExtenderPathChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { UserConfiguration me = sender as UserConfiguration; if (me != null) { if (!string.IsNullOrEmpty(me.ArtemisExtenderPath) && File.Exists(me.ArtemisExtenderPath)) { me.MakeArtemisExtenderCopy(); me.UseArtemisExtender = true; } else { me.UseArtemisExtender = false; } } }
static void OnMissionCommandLineChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) { UserConfiguration me = sender as UserConfiguration; if (me != null) { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(me.MissionEditorPath)) { sb.Append(me.MissionEditorPath); if (!string.IsNullOrEmpty(me.MissionEditorParameters)) { sb.Append(" "); sb.Append(me.MissionEditorParameters); } me.MissionEditorCommandLine = sb.ToString(); } me.UseMissionEditor = (!string.IsNullOrEmpty(me.MissionEditorPath) && !string.IsNullOrEmpty(me.MissionEditorParameters) && File.Exists(me.MissionEditorPath)); } }
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(); }