private static void OnLaunch(object parameter) { var programDescription = GetProgramDescription(parameter); if (CanLaunch(programDescription)) { if (!Properties.Settings.Default.AllowMultipleInstances && Emulator.Instances().Any()) { INTV.Shared.View.OSMessageBox.Show(Resources.Strings.JzIntvAlreadyRunning, Resources.Strings.LaunchInJzIntvCommand_Failed_Title); return; } var programName = Resources.Strings.UnknownROM; try { programName = programDescription.Name; var options = GetCommandLineOptionsForRom(programDescription); var romPath = programDescription.Rom.RomPath; var jzIntvPath = ConfigurationCommandGroup.ResolvePathSetting(JzIntvLauncherConfiguration.Instance.EmulatorPath); var jzIntv = new Emulator(jzIntvPath, LaunchInJzIntvErrorHandler); var process = RunExternalProgram.CreateProcess(jzIntv.Path); jzIntv.Launch(process, options, programDescription); } catch (Exception e) { var message = string.Format(Resources.Strings.UnableToLaunchJzIntv_Error_Message_Format, programName, e.Message); INTV.Shared.View.OSMessageBox.Show(message, Resources.Strings.UnableToLaunchJzIntv_Error_Title); } } }
private static void CheckForUpdatesComplete(AsyncTaskData taskData) { var data = (CheckForUpdatesTaskData)taskData; var appInfo = SingleInstanceApplication.AppInfo; if (taskData.Error != null) { var reportError = INTV.Shared.Properties.Settings.Default.ShowDetailedErrors; var message = string.Empty; if (data.CheckingAtStartup) { message = Resources.Strings.CheckForUpdatesCommand_FailedStopAsking; } else { if (reportError) { message = Resources.Strings.CheckForUpdatesCommand_Failed; } else { message = string.Format(Resources.Strings.CheckForUpdatesCommand_FailedFormat, data.Error.Message); } } if (reportError || !data.CheckingAtStartup) { OSMessageBox.Show(message, Resources.Strings.CheckForUpdatesCommand_DialogTitle, reportError ? data.Error : null, OSMessageBoxButton.OK); } } else { var message = string.Empty; if (data.UpdateAvailable) { message = string.Format(Resources.Strings.CheckForUpdatesCommand_UpdateAvailableFormat, data.VersionString, appInfo.ProductUrl, data.UpdateVersionString); } else if (!data.CheckingAtStartup) { message = Resources.Strings.CheckForUpdatesCommand_NoUpdates; } if (!string.IsNullOrEmpty(message)) { var result = OSMessageBox.Show(message, Resources.Strings.CheckForUpdatesCommand_DialogTitle, data.UpdateAvailable ? OSMessageBoxButton.YesNo : OSMessageBoxButton.OK); if (data.UpdateAvailable && (result == OSMessageBoxResult.Yes)) { try { RunExternalProgram.OpenInDefaultProgram(appInfo.ProductUrl); } catch (System.Exception e) { message = string.Format(Resources.Strings.CheckForUpdatesCommand_OpenBrowserFailedFormat, e.Message); OSMessageBox.Show(message, Resources.Strings.CheckForUpdatesCommand_DialogTitle); } } } } }
private static void ShowInstalledDocuments(object parameter) { try { RunExternalProgram.OpenInDefaultProgram(DocumentationPath); } catch (Exception) { // Ignore errors. } }
private static void ShowGettingStarted(object parameter) { try { RunExternalProgram.OpenInDefaultProgram(GettingStartedPath); } catch (System.IO.FileNotFoundException) { // ignore failure } }
private static void FirmwareUpdateCompleteHandler(bool cancelled, bool didShowProgress, object result, string firmwareFile) { var title = string.Empty; var message = string.Empty; var dialogButtons = OSMessageBoxButton.OK; if (cancelled) { title = Resources.Strings.Firmware_UpdateFirmwareCommand_Cancelled_Title; message = Resources.Strings.Firmware_UpdateFirmwareCommand_CancelledMessage; } else { var firmwareVersion = (FirmwareRevisions)result; title = Resources.Strings.Firmware_UpdateFirmwareCommand_Complete_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.Firmware_UpdateFirmwareCommand_CompleteMessageFormat, FirmwareRevisions.FirmwareVersionToString(firmwareVersion.Current, false)); } var updateNotesFile = System.IO.Path.ChangeExtension(firmwareFile, ".txt"); var showReadme = System.IO.File.Exists(updateNotesFile); if (System.IO.File.Exists(updateNotesFile)) { message += System.Environment.NewLine + System.Environment.NewLine + Resources.Strings.FirmwareUpdate_ShowReadmePrompt; dialogButtons = OSMessageBoxButton.YesNo; } // FIXME On Mac, OK and Yes are the same value, which is different than in Windows. // As a result, we can't rely on the dialog buttons mode to give a distinct answer, // so we double-check the return value *AND* whether readme exists. Ideally, the message // box result would be distinct. This means changing implementation of OSMessageBox and // all the other cases where the code calls RunModal() and simply casts the return value. var yesOrOK = OSMessageBox.Show(message, title, dialogButtons) == OSMessageBoxResult.Yes; if (showReadme && System.IO.File.Exists(updateNotesFile) && yesOrOK) { try { RunExternalProgram.OpenInDefaultProgram(updateNotesFile); } catch (System.InvalidOperationException) { // Silently fail. } } }
/// <inheritdoc /> internal override void LoadComplete(FileSystem fileSystem, bool updateRomList) { base.LoadComplete(fileSystem, updateRomList); if (Description == null) { if (Rom != null) { if (Crc32 == 0) { var filePath = Rom.FilePath; INTV.Core.Model.LuigiFileHeader luigiHeader = LuigiFileHeader.GetHeader(filePath); if (luigiHeader != null) { string cfgFile = null; string romFile = filePath; uint crc = 0u; if (luigiHeader.Version > 0) { crc = luigiHeader.OriginalRomCrc32; } else { var jzIntvConfiguration = INTV.Shared.Utility.SingleInstanceApplication.Instance.GetConfiguration <INTV.JzIntv.Model.Configuration>(); var luigiToBinPath = jzIntvConfiguration.GetProgramPath(JzIntv.Model.ProgramFile.Luigi2Bin); var luigiToBinResult = RunExternalProgram.Call(luigiToBinPath, "\"" + filePath + "\"", System.IO.Path.GetDirectoryName(filePath)); if (luigiToBinResult == 0) { romFile = System.IO.Path.ChangeExtension(filePath, RomFormat.Bin.FileExtension()); cfgFile = System.IO.Path.ChangeExtension(filePath, ProgramFileKind.CfgFile.FileExtension()); if (!System.IO.File.Exists(cfgFile)) { cfgFile = null; } } } var rom = INTV.Core.Model.Rom.Create(romFile, cfgFile); var programInfo = rom.GetProgramInformation(); var programDescription = new ProgramDescription(rom.Crc, rom, programInfo); Description = programDescription; } } } } }
private static void OnSendErrorReportEmail(object parameter) { var viewModel = parameter as ReportDialogViewModel; viewModel.SendEmailEnabled = false; viewModel.SendEmailButtonLabelText = Resources.Strings.ReportDialog_SendingErrorReport; var fullMessageReport = string.Empty; #if SMTP_SUPPORT // While sending email, disable the close button until we return. Hope this never hangs! viewModel.CloseDialogButtonEnabled = false; #endif // SMTP_SUPPORT try { // If the address isn't valid, just use Anonymous. var sender = viewModel.EmailSender; try { if (!string.IsNullOrWhiteSpace(sender)) { var address = new System.Net.Mail.MailAddress(sender); sender = address.Address; } else { sender = null; } } catch (FormatException) { sender = null; } sender = sender ?? "*****@*****.**"; var subject = "LTO Flash UI Crash Report"; var message = new System.Text.StringBuilder(subject); message.AppendLine().AppendLine("-----------------------------------------------"); message.AppendFormat("{0} (Version: {1})", System.Reflection.Assembly.GetEntryAssembly().FullName, SingleInstanceApplication.Version).AppendLine(); message.AppendFormat("Operating system: {0} {1} ({2}) (64-bit app: {3})", OSVersion.Name, OSVersion.Current, Environment.OSVersion, Environment.Is64BitOperatingSystem).AppendLine(); AppendSystemInformation(message); message.AppendFormat("CLR Version: {0}", Environment.Version).AppendLine(); var attachments = new List <string>(viewModel.Attachments.Distinct(PathComparer.Instance).Where(a => System.IO.File.Exists(a))); var errorLogPath = viewModel.GetErrorLog(false); if (System.IO.File.Exists(errorLogPath) && !attachments.Contains(errorLogPath, PathComparer.Instance)) { attachments.Add(errorLogPath); } if (attachments.Any()) { message.AppendLine().AppendLine("PLEASE INCLUDE THE FOLLOWING FILES ATTACHED TO YOUR MESSAGE!"); message.AppendLine("These may assist in diagnosing the problem.").AppendLine(); var fileNumber = 0; foreach (var attachment in attachments) { message.AppendFormat("{0}: {1}", ++fileNumber, attachment).AppendLine(); } } message.AppendLine().AppendLine("Please include any further information, such as what you were doing when you encountered the problem."); message.AppendLine("--------------------------------------------------------------------").AppendLine(); message.AppendLine("PLACE YOUR COMMENTS HERE"); message.AppendLine().AppendLine("--------------------------------------------------------------------"); message.AppendLine("Please do NOT remove or edit information below this point."); message.AppendLine("--------------------------------------------------------------------").AppendLine(); message.AppendLine(viewModel.Message).AppendLine(); message.AppendLine(viewModel.ReportText); fullMessageReport = message.ToString(); var reportRecipient = "*****@*****.**"; #if SMTP_SUPPORT RunExternalProgram.SendEmailUsingSMTP(sender, reportRecipient, viewModel.EmailCCRecipients, subject, fullMessageReport, attachments, viewModel, SendErrorReportComplete); #else RunExternalProgram.SendEmail(sender, reportRecipient, viewModel.EmailCCRecipients, subject, fullMessageReport, attachments); #endif // SMTP_SUPPORT } catch (Exception e) { ReportSendErrorReportFailure(viewModel, fullMessageReport, e); viewModel.CloseDialogButtonEnabled = true; } }
private static void InstallSDL(AsyncTaskData taskData) { var data = (InstallSDLTaskData)taskData; var diskImageInfo = data.DiskImageInfo; var progressMessage = string.Empty; if ((diskImageInfo.DownloadUrl != null) && !File.Exists(diskImageInfo.Path)) { progressMessage = string.Format( CultureInfo.CurrentCulture, Resources.Strings.SDLNotFound_Downloading_Format, diskImageInfo.Version, diskImageInfo.DownloadUrl, diskImageInfo.Path); data.UpdateTaskProgress(0, progressMessage); using (var httpClient = new System.Net.Http.HttpClient()) { var response = httpClient.GetAsync(diskImageInfo.DownloadUrl).Result; if (response.IsSuccessStatusCode) { using (var stream = response.Content.ReadAsStreamAsync().Result) using (var sdkDiskImageFile = new FileStream(diskImageInfo.Path, FileMode.Create, FileAccess.Write, FileShare.None)) { stream.CopyTo(sdkDiskImageFile); } } } } progressMessage = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Update_Mounting, diskImageInfo.FileName); data.UpdateTaskProgress(0, progressMessage); var sdlDmgPath = diskImageInfo.Path; string sdlDev = string.Empty; try { var result = RunExternalProgram.CallAndReturnStdOut("/usr/bin/hdiutil", "attach -noautoopen -nobrowse -readonly -plist \"" + sdlDmgPath + "\"", null); var plist = new XmlDocument(); plist.LoadXml(result); var mountInfo = GetSDLMountVolume(plist); var mountVolume = mountInfo == null ? null : mountInfo.Item2; sdlDev = mountInfo == null ? null : mountInfo.Item1; if (!string.IsNullOrEmpty(mountVolume) && Directory.Exists(mountVolume)) { progressMessage = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Update_Copying, diskImageInfo.FrameworkName); data.UpdateTaskProgress(0, progressMessage); var sdlSource = NSUrl.FromFilename(mountVolume).Append(diskImageInfo.FrameworkName, isDirectory: true); string errorMessage; var userLibraryDir = diskImageInfo.GetUserLibraryDirectory(out errorMessage); if ((userLibraryDir != null) && string.IsNullOrEmpty(errorMessage)) { // If the user doesn't already have a Frameworks directory, create it. NSError error; var userLibraryFrameworksDir = userLibraryDir.Append("Frameworks", true); if (Directory.Exists(userLibraryFrameworksDir.Path) || NSFileManager.DefaultManager.CreateDirectory(userLibraryFrameworksDir, true, null, out error)) { var sdlDestination = userLibraryFrameworksDir.Append(diskImageInfo.FrameworkName, isDirectory: true); if (!NSFileManager.DefaultManager.Copy(sdlSource, sdlDestination, out error)) { data.ErrorMessage = string.Format(Resources.Strings.SDLInstall_Failed_Format, diskImageInfo.Version, error.LocalizedDescription); } } else { data.ErrorMessage = string.Format(Resources.Strings.SDLInstall_Failed_Format, diskImageInfo.Version, error.LocalizedDescription); } } else { data.ErrorMessage = errorMessage; } } else { data.ErrorMessage = string.Format(Resources.Strings.SDLInstall_FailedToMount_Format, diskImageInfo.Version, sdlDmgPath, result); } } finally { if (!string.IsNullOrEmpty(sdlDev)) { progressMessage = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Update_Unmounting, diskImageInfo.FileName); data.UpdateTaskProgress(0, progressMessage); var result = RunExternalProgram.CallAndReturnStdOut("/usr/bin/hdiutil", "detach -force " + sdlDev, null); System.Diagnostics.Debug.WriteLine(result); } } }