void ModManagement_DownloadFailed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } CleanupDownload(); Locations.MessageBoxShow("Download Failed:\r\n\r\n" + e.Error.ToString() + "\r\n\r\nPlease manually download the file and select it.", MessageBoxButton.OK, MessageBoxImage.Error); ModConfiguration mod = e.UserState as ModConfiguration; if (string.IsNullOrEmpty(mod.Download.Source)) { System.Diagnostics.Process.Start(mod.Download.Source); } else { System.Diagnostics.Process.Start(mod.Download.Webpage); } BrowseForPackage(mod); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void ToAndroid_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn != null) { ModConfiguration config = btn.CommandParameter as ModConfiguration; if (config != null) { Locations.MessageBoxShow(AMLResources.Properties.Resources.AttachAndroid, MessageBoxButton.OK, MessageBoxImage.Information); System.Windows.Forms.FolderBrowserDialog diag = new System.Windows.Forms.FolderBrowserDialog(); diag.Description = AMLResources.Properties.Resources.BrowseToFolder; if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Locations.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.snt"); Locations.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.xml"); Locations.MessageBoxShow( AMLResources.Properties.Resources.CopyComplete + DataStrings.CRCR + AMLResources.Properties.Resources.ApplyToAndroid, MessageBoxButton.OK, MessageBoxImage.Information); } } } }
void FinalNotify() { Locations.MessageBoxShow(AMLResources.Properties.Resources.ResetComplete + DataStrings.CRCR + string.Format(AMLResources.Properties.Resources.RestartRequired, AMLResources.Properties.Resources.Title), MessageBoxButton.OK, MessageBoxImage.Information); System.Diagnostics.Process.Start(Assembly.GetEntryAssembly().Location); App.Current.Shutdown(); }
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()); } }
void UpdateCheckProcess() { if (ModManagement.CheckForUpdate()) { if (Locations.MessageBoxShow(string.Format("An update to Artemis has been detected. Do you wish to apply that update to the copy that {0} runs?", Locations.AssemblyTitle), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { ModManagement.ProcessUpdate(); } } }
private void AfterUninstall_Event(object sender, InstallEventArgs e) { if (Locations.MessageBoxShow(AMLResources.Properties.Resources.RemoveAllUserFilesQuestion, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { FileHelper.GeneralResult = true; FileHelper.DeleteAllFiles(Locations.DataPath); if (!FileHelper.GeneralResult) { Locations.MessageBoxShow(AMLResources.Properties.Resources.NotAllRemoved, MessageBoxButton.OK, MessageBoxImage.Information); } } }
static bool VersionOK(string source) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool AtLeastOne = true; bool retVal = true; string[] xmlFiles = GetAllXmlFiles(source); if (xmlFiles == null) { retVal = false; } else { foreach (string s in xmlFiles) { AtLeastOne = false; decimal ver = ModManagement.GetVesselDataVersion(s); if (ver >= 1.56M) { AtLeastOne = true; break; } } if (!AtLeastOne) { retVal = (Locations.MessageBoxShow( AMLResources.Properties.Resources.IncompatibleVesselDataMessage + DataStrings.CRCR + AMLResources.Properties.Resources.InstallAnyhowQuestion, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } return(retVal); }
private void Remove_click(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn != null) { big_message miss = btn.CommandParameter as big_message; if (miss != null) { if (Locations.MessageBoxShow(AMLResources.Properties.Resources.AreYouSure + DataStrings.CRCR + AMLResources.Properties.Resources.ThisIsNotRecoverable, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { FileInfo f = new FileInfo(miss.MissionPath); FileHelper.DeleteAllFiles(f.DirectoryName); MissionList.Remove(miss); } } } }
private void RunArtemis_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (this.SelectedIPAddress != Locations.GetCurrentIPAddress()) { if (!Locations.SetIPAddress(this.SelectedIPAddress)) { Locations.MessageBoxShow("Unable to set the Server IP address.\r\n\r\nReview log file for details as to why.", MessageBoxButton.OK, MessageBoxImage.Information); } } Window thiswin = Window.GetWindow(this); thiswin.ShowInTaskbar = false; SessionMonitor win = new SessionMonitor(); win.StartSession(); DoAnimation(); win.ShowDialog(); thiswin.ShowInTaskbar = true; thiswin.WindowState = System.Windows.WindowState.Normal; string newIP = Locations.GetCurrentIPAddress(); if (!IPAddresses.Contains(newIP)) { Locations.AddToIPList(newIP); IPAddresses.Add(newIP); SelectedIPAddress = newIP; } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
void ProcessUpdate(object state) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool success = true; string URL = state as string; string file = URL.Substring(URL.LastIndexOf('/') + 1); string fullPath = Path.Combine(Path.GetTempPath(), file); if (!string.IsNullOrEmpty(URL)) { try { FileHelper.DeleteFile(fullPath); using (WebClient w = new WebClient()) { Uri address = new Uri(URL); w.DownloadFile(address, fullPath); } } catch (Exception ex) { if (_log.IsWarnEnabled) { _log.Warn("Error downloading updated installer", ex); } Locations.MessageBoxShow("Failed to download update.\r\n\r\nPlease try again later.\r\n\r\nError:\r\n" + ex.Message, MessageBoxButton.OK, MessageBoxImage.Error); success = false; } } this.Dispatcher.BeginInvoke(new Action(CloseStandBy)); if (success && !System.Diagnostics.Debugger.IsAttached) { this.Dispatcher.BeginInvoke(new Action <string>(CloseDown), fullPath); } else { if (System.Diagnostics.Debugger.IsAttached) { if (success) { Locations.MessageBoxShow("Update would have been successful--Debugger is attached. Update is downlaoded.", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { Locations.MessageBoxShow("Update would have been Unsuccessful--Debugger is attached. Proceeding normally.", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } this.Dispatcher.BeginInvoke(new Action(FinishStartup)); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public bool DeactivateLastConfig() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool retVal = true; if (Configurations.Count > 1) { ModConfiguration config = Configurations[Configurations.Count - 1]; if (_log.IsInfoEnabled) { _log.InfoFormat("~~~~~~~~~~~~~ Beginning Deactivation of {0}", config.Title); } config.DeactivateMod(); Configurations.Remove(config); for (int i = Configurations.Count - 1; i >= 0; i--) { foreach (FileMap m in Configurations[i].ActiveFiles) { if (!File.Exists(m.Target)) { if (File.Exists(m.Source)) { if (_log.IsInfoEnabled) { _log.InfoFormat("Restoring \"{0}\" from config {1}", m.Source, Configurations[i].Title); } File.Copy(m.Source, m.Target); } else { if (_log.IsWarnEnabled) { _log.WarnFormat("Source file is missing: \"{0}\"", m.Source); } //A source file from Mod "{0}" is missing. StringBuilder sb = new StringBuilder(); sb.AppendFormat(AMLResources.Properties.Resources.SourceNotFoundPrefix, Configurations[i].Title); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(AMLResources.Properties.Resources.CorruptedMod); sb.AppendLine(); sb.AppendLine(AMLResources.Properties.Resources.ProcessingContinue); sb.AppendLine(); sb.AppendFormat(AMLResources.Properties.Resources.MissingFileLabel, m.Source); Locations.MessageBoxShow(sb.ToString(), MessageBoxButton.OK, MessageBoxImage.Exclamation); } } } //Processing base files might not be needed if bug with active files fixed. ////////if (Configurations[i].BaseFiles != null) ////////{ //////// foreach (FileMap m in Configurations[i].BaseFiles) //////// { //////// string target = Path.Combine(Locations.ArtemisCopyPath, m.Target); //////// if (m.Source.Contains("*") || m.Source.Contains("?")) //////// { //////// //more than one file, wildcarded. //////// string sourceFle = m.Source; //////// int i1 = sourceFle.LastIndexOf('\\'); //////// sourceFle = sourceFle.Substring(0, i1); //////// string fullSrc = Path.Combine(Configurations[i].InstalledPath, sourceFle); //////// foreach (FileInfo f in new DirectoryInfo(fullSrc).GetFiles("*.*", SearchOption.AllDirectories)) //////// { //////// string relative = f.DirectoryName.Substring(fullSrc.Length + 1); //////// if (relative.StartsWith("\\", StringComparison.OrdinalIgnoreCase)) //////// { //////// relative = relative.Substring(1); //////// } //////// if (!File.Exists(Path.Combine(Locations.ArtemisCopyPath, relative))) //////// { //////// f.CopyTo(Path.Combine(Locations.ArtemisCopyPath, relative)); //////// } //////// } //////// } //////// else //////// { //////// if (!File.Exists(target)) //////// { //////// string src = Path.Combine(Configurations[i].InstalledPath, m.Source); //////// if (File.Exists(src)) //////// { //////// File.Copy(src, target); //////// } //////// else //////// { //////// if (_log.IsWarnEnabled) //////// { //////// _log.WarnFormat("Source file is missing: \"{0}\"", src); //////// } //////// Locations.MessageBoxShow("A source file from Mod \"" //////// + Configurations[i].Title //////// + "\" is missing.\r\n\r\nThis could mean the mod is corrupted.\r\n\r\n" //////// + "Processing will continue, but you may want to deactivate this mod and re-install.\r\n\r\n" //////// + " Missing file: \"" + src + "\"", //////// MessageBoxButton.OK, MessageBoxImage.Exclamation); //////// } //////// } //////// } //////// } ////////} } //Do Save. SaveData(); } else { retVal = false; } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } return(retVal); }
private static void InstallEXE(ModConfiguration config, string file) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (string.IsNullOrEmpty(file) || !file.EndsWith(".EXE", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Must be an EXE file to call InstallEXE Method."); } if (config != null) { Locations.MessageBoxShow( AMLResources.Properties.Resources.EXEInstallWarning + DataStrings.CRCR + AMLResources.Properties.Resources.FullRestoreWarning, MessageBoxButton.OK, MessageBoxImage.Information); //First get list of files ModManagement.DoMessage(AMLResources.Properties.Resources.LoadingListOfFiles); #if EXETest string testPath = @"D:\Stuff\Downloads\Artemis backup"; FileInfo[] PreInstall = new DirectoryInfo(testPath).GetFiles("*.*", SearchOption.AllDirectories); #else FileInfo[] PreInstall = new DirectoryInfo(Locations.ArtemisInstallPath).GetFiles("*.*", SearchOption.AllDirectories); ModManagement.DoMessage(AMLResources.Properties.Resources.InstallingModMessage); RunAdminProcess(file, string.Empty); #endif ModManagement.DoMessage(AMLResources.Properties.Resources.LoadingListAddedByMod); FileInfo[] PostInstall = new DirectoryInfo(Locations.ArtemisInstallPath).GetFiles("*.*", SearchOption.AllDirectories); if (VersionOK(Locations.ArtemisInstallPath)) { //Now identify what changed, and copy changed files to work path. string wrkPath = Path.Combine(Locations.InstalledModsPath, config.ID); if (_log.IsInfoEnabled) { _log.InfoFormat("Work Path set to \"{0}\"", wrkPath); } Dictionary <string, FileInfo> PreInstallFiles = new Dictionary <string, FileInfo>(); foreach (FileInfo f in PreInstall) { string fn = f.FullName; #if EXETest fn = fn.Replace(testPath, Locations.ArtemisInstallPath); #endif PreInstallFiles.Add(fn, f); } ModManagement.DoMessage(AMLResources.Properties.Resources.CopyingToModInstallation); foreach (FileInfo f in PostInstall) { if (_log.IsInfoEnabled) { _log.InfoFormat("Post install file: {0}", f.FullName); } string relative = f.DirectoryName.Substring(Locations.ArtemisInstallPath.Length); if (relative.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) { relative = relative.Substring(0, relative.Length - 1); } if (relative.StartsWith("\\", StringComparison.OrdinalIgnoreCase)) { relative = relative.Substring(1, relative.Length - 1); } string folder = Path.Combine(wrkPath, relative); if (_log.IsInfoEnabled) { _log.InfoFormat("Relative path = \"{1}\". Target folder set to \"{0}\"", folder, relative); } if (PreInstallFiles.ContainsKey(f.FullName)) { if (_log.IsInfoEnabled) { _log.Info("File found amoung preinstall."); } if (f.Length != PreInstallFiles[f.FullName].Length || f.LastWriteTimeUtc.CompareTo(PreInstallFiles[f.FullName].LastWriteTimeUtc) != 0) { if (_log.IsInfoEnabled) { _log.Info("File size or last modified date not match."); } DoCopy(folder, f); } else { if (_log.IsInfoEnabled) { _log.Info("File matches perfectly."); } } } else { if (_log.IsInfoEnabled) { _log.Info("File was not found among pre-installed files."); } DoCopy(folder, f); } } } #if !EXETest if (!string.IsNullOrEmpty(config.Uninstall)) { ModManagement.DoMessage(AMLResources.Properties.Resources.UninstallingEXEMod); RunAdminProcess(Path.Combine(Locations.ArtemisInstallPath, config.Uninstall), string.Empty); System.Threading.Thread.Sleep(10000); } else { Locations.MessageBoxShow( AMLResources.Properties.Resources.PleaseRunUninstaller, MessageBoxButton.OK, MessageBoxImage.Exclamation); } ModManagement.DoMessage(AMLResources.Properties.Resources.RestoringOriginalArtemis); // config.InstallMod(wrkPath); ModConfiguration stock = new ModConfiguration(Locations.MODStockDefinition); string StockPath = Path.Combine(Locations.InstalledModsPath, stock.ID); string xcopy = Path.Combine(Path.GetTempPath(), DataStrings.RestoreArtemisCmd); using (StreamWriter sw = new StreamWriter(xcopy)) { sw.WriteLine(string.Format(DataStrings.XcopyCommand, StockPath, Locations.ArtemisInstallPath)); } RunAdminProcess(xcopy, string.Empty); #endif } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }