private static bool SyncDeviceToHostPreviewErrorHandler(string errorMessage, System.Exception exception) { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.SyncPreviewCommand_Failed_Message_Format, errorMessage); OSMessageBox.Show(message, Resources.Strings.SyncPreviewCommand_Failed_Title, SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, Resources.Strings.SyncPreviewCommand_Failed_Resolution, (r) => { }); return(true); }
private static void DownloadAndPlay(object parameter) { // stupid Mac NSToolbarItem doesn't stay disabled correctly (TODO: CHECK IF THIS WAS BUG IN DEVICE STATE) if (CanDownloadAndPlay(parameter)) { var ltoFlashViewModel = CompositionHelpers.Container.GetExport <LtoFlashViewModel>().Value; var programDescriptionViewModel = parameter as INTV.Shared.ViewModel.ProgramDescriptionViewModel; var programViewModel = parameter as ProgramViewModel; // If we don't have a valid ROM to send via the parameter, try the current ROM selection. // This is to support the main menu / toolbar invocation of the command vs. context menu. if ((programDescriptionViewModel == null) && (programViewModel == null)) { var context = parameter as LtoFlashViewModel ?? ltoFlashViewModel; if (context != null) { // Remember... the LtoFlashViewModel's CurrentSelection is the hacky-ish tracker of // the RomListViewModel's CurrentSelection. programDescriptionViewModel = context.CurrentSelection.FirstOrDefault(); } } if ((programDescriptionViewModel != null) || (programViewModel != null)) { var program = programDescriptionViewModel == null ? programViewModel.ProgramDescription : programDescriptionViewModel.Model; if ((program != null) && (program.Rom != null) && !program.Rom.Validate()) { OSMessageBox.Show(string.Format(Resources.Strings.DownloadAndPlayCommand_Missing_Message_Format, program.Name, program.Rom.RomPath), string.Format(Resources.Strings.DownloadAndPlayCommand_Failed_Title_Format, program.Name)); } else { DownloadAndPlay(ltoFlashViewModel.ActiveLtoFlashDevice.Device, program); } } } }
private static void DownloadAndPlayPrompt(object parameter) { // stupid Mac NSToolbarItem doesn't stay disabled correctly if (CanDownloadAndPlayPrompt(parameter)) { var ltoFlashViewModel = parameter as LtoFlashViewModel; var selectedFile = INTV.Shared.Model.IRomHelpers.BrowseForRoms(false, Resources.Strings.DownloadAndPlayCommand_BrowseDialogPrompt).FirstOrDefault(); if (selectedFile != null) { var rom = selectedFile.GetRomFromPath(); if (rom != null) { var fileName = System.IO.Path.GetFileName(rom.RomPath); var device = ltoFlashViewModel.ActiveLtoFlashDevice.Device; var canPlayOnDevice = rom.CanExecuteOnDevice(device.UniqueId); if (!canPlayOnDevice) { var message = string.Format(Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Message_Format, fileName); canPlayOnDevice = OSMessageBox.Show(message, Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Title, OSMessageBoxButton.YesNo) == OSMessageBoxResult.Yes; } if (canPlayOnDevice) { device.DownloadAndPlay(rom, fileName, (m, e) => DownloadAndPlayErrorHandler(m, e, fileName)); } } else { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.DownloadAndPlayPromptCommand_Failed_MessageFormat, selectedFile); OSMessageBox.Show(message, string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.DownloadAndPlayPromptCommand_Failed_Title)); } } } }
private static bool SyncDeviceToHostErrorHandler(string errorMessage, System.Exception exception, LtoFlashViewModel viewModel) { viewModel.HostPCMenuLayout.ShowOverlay = false; var showInconsistentFileInfo = ((exception != null) && (exception is InconsistentFileSystemException)) || (exception.InnerException is InconsistentFileSystemException); if (showInconsistentFileInfo) { OSMessageBox.Show( Resources.Strings.DeviceMultistageCommand_UpdatingMenuLayout_InconsistentStateErrorMessage, Resources.Strings.FileSystem_Inconsistent_Title, null, OSMessageBoxButton.YesNo, OSMessageBoxIcon.Exclamation, (result) => { if (result == OSMessageBoxResult.Yes) { SingleInstanceApplication.MainThreadDispatcher.BeginInvoke(new System.Action(() => SyncDeviceToHost(viewModel, true))); } }); } else { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.SyncDeviceToHostCommand_Failed_Message_Format, errorMessage); OSMessageBox.Show(message, Resources.Strings.SyncDeviceToHostCommand_Failed_Title, SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, (r) => { }); } return(true); }
private static void RestoreRomListComplete(AsyncTaskData taskData) { var data = (RestoreRomListTaskData)taskData; if (taskData.Error == null) { RestoreRomListComplete(data.RomListViewModel); if (!string.IsNullOrEmpty(data.BackupPath) && System.IO.File.Exists(data.BackupPath)) { FileUtilities.DeleteFile(data.BackupPath, false, 10); } } else { var title = Resources.Strings.RestoreRomListCommand_MissingFileErrorTitle; var message = Resources.Strings.RestoreRomListCommand_FailedMessage; var buttons = OSMessageBoxButton.OK; if (!string.IsNullOrEmpty(data.BackupPath) && System.IO.File.Exists(data.BackupPath)) { message += Resources.Strings.RestoreRomListCommand_PromptToRestoreMessage; buttons = OSMessageBoxButton.YesNo; } var result = OSMessageBox.Show(message, title, taskData.Error, buttons, OSMessageBoxIcon.Error); if ((result == OSMessageBoxResult.Yes) && !string.IsNullOrEmpty(data.BackupPath) && System.IO.File.Exists(data.BackupPath)) { var romsConfiguration = INTV.Shared.Model.RomListConfiguration.Instance; System.IO.File.Replace(data.BackupPath, romsConfiguration.RomFilesPath, null); data.RomListViewModel.InitializeRomList(romsConfiguration.RomFilesPath); } } }
private void GatherRomsComplete(AsyncTaskData taskData) { var args = (RomDiscoveryData)taskData; var discoveredRoms = args.NewRoms; var addedRoms = Model.AddNewItemsFromList(discoveredRoms, args.InsertLocation); if (addedRoms.Any()) { var collectionChanged = CollectionChanged; if (collectionChanged != null) { collectionChanged(this, new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Add, addedRoms as System.Collections.IList)); } if (args.SelectNewRoms) { CurrentSelection.Clear(); var addedItemIndexes = addedRoms.Select(r => Programs.ModelCollection.IndexOf(r)); foreach (var addedRomIndex in addedItemIndexes) { var programViewModel = Programs[addedRomIndex]; CurrentSelection.Add(programViewModel); } } SaveRomList(true); } Model.EndAddRomsFromFiles(args.DuplicateRomPaths); if (taskData.Error != null) { OSMessageBox.Show(Resources.Strings.AddRomsErrorMessage, Resources.Strings.AddRomsErrorTitle, taskData.Error, null); } }
private static void BrowseAndDownload(object parameter) { if (CanBrowseAndDownload(parameter)) { var selectedFile = INTV.Shared.Model.IRomHelpers.BrowseForRoms(false, Resources.Strings.BrowseAndLaunchInJzIntvCommand_BrowseDialogPrompt).FirstOrDefault(); if (selectedFile != null) { var rom = selectedFile.GetRomFromPath(); IProgramDescription programDescription = null; if (rom != null) { var programInfo = rom.GetProgramInformation(); programDescription = new ProgramDescription(rom.Crc, rom, programInfo); } if (programDescription != null) { OnLaunch(programDescription); } else { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.BrowseAndLaunchInJzIntvCommand_Failed_MessageFormat, selectedFile); OSMessageBox.Show(message, string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.BrowseAndLaunchInJzIntvCommand_Failed_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 bool DownloadAndPlayErrorHandler(string errorMessage, System.Exception exception, string programName) { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.DownloadAndPlayCommand_Failed_Message_Format, programName, errorMessage); OSMessageBox.Show( message, string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.DownloadAndPlayCommand_Failed_Title_Format, programName), SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, (r) => { }); return(true); }
private static void OnEmptyRomList(object parameter) { var message = Resources.Strings.EmptyRomListCommand_WarningMessage; var title = Resources.Strings.EmptyRomListCommand_WarningTitle; if (OSMessageBox.Show(message, title, OSMessageBoxButton.YesNo, OSMessageBoxIcon.Exclamation) == OSMessageBoxResult.Yes) { var viewModel = parameter as RomListViewModel; viewModel.ClearRomList(); viewModel.SaveRomList(true); } }
/// <summary> /// Download and play a program on a Locutus board. /// </summary> /// <param name="device">The Locutus device to send the program to.</param> /// <param name="program">The program to send.</param> internal static void DownloadAndPlay(Device device, INTV.Core.Model.Program.ProgramDescription program) { var rom = program.GetRom(); var canPlayOnDevice = rom.CanExecuteOnDevice(device.UniqueId); if (!canPlayOnDevice) { var message = string.Format(Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Message_Format, program.Name); canPlayOnDevice = OSMessageBox.Show(message, Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Title, OSMessageBoxButton.YesNo) == OSMessageBoxResult.Yes; } if (canPlayOnDevice) { device.DownloadAndPlay(rom, program.Name, (m, e) => DownloadAndPlayErrorHandler(m, e, program.Name)); } }
/// <summary> /// Sets the configuration path. /// </summary> /// <param name="sender">The button that was clicked.</param> partial void SetConfigurationPath(NSObject sender) { var control = sender as NSControl; if (control != null) { ICommand command = null; var whichFile = (EmulatorFile)(int)control.Tag; switch (whichFile) { case EmulatorFile.JzIntv: command = ConfigurationCommandGroup.LocateJzIntvCommand; break; case EmulatorFile.Exec: command = ConfigurationCommandGroup.LocateExecCommand; break; case EmulatorFile.Grom: command = ConfigurationCommandGroup.LocateGromCommand; break; case EmulatorFile.Ecs: command = ConfigurationCommandGroup.LocateEcsCommand; break; case EmulatorFile.KeyboardConfig: command = ConfigurationCommandGroup.SelectKeyboardConfigFileCommand; break; case EmulatorFile.Cgc0Config: command = ConfigurationCommandGroup.SelectClassicGameController0ConfigFileCommand; break; case EmulatorFile.Cgc1Config: command = ConfigurationCommandGroup.SelectClassicGameController1ConfigFileCommand; break; default: OSMessageBox.Show("Unrecognized file: " + whichFile + "(" + control.Tag + ")", "Set File: Missing Implementation"); break; } if (command != null) { command.Execute(ViewModel); } } }
private static void OnShowFTDIWarningCommand(object parameter) { SingleInstanceApplication.Instance.BeginInvokeOnMainThread(() => { var recommendedVersion = SingleInstanceApplication.AppInfo.RecommendedOSVersion; if ((OSVersion.Current < recommendedVersion) && Properties.Settings.Default.ShowFTDIWarning) { var buttonLabels = new Dictionary <OSMessageBoxButton, string> { { OSMessageBoxButton.OK, Resources.Strings.OKButton_Text }, { OSMessageBoxButton.YesNo, Resources.Strings.OKDoNotShowAgainButton_Text } }; var result = OSMessageBox.Show(Resources.Strings.FTDIWarning_Message, Resources.Strings.FTDIWarning_Title, OSMessageBoxButton.YesNo, buttonLabels, OSMessageBoxIcon.Exclamation); Properties.Settings.Default.ShowFTDIWarning = result == OSMessageBoxResult.Yes; } }); }
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. } } }
private static void FirmwareRestoreCompleteHandler(bool cancelled, bool didShowProgress, object result) { var title = string.Empty; var message = string.Empty; if (cancelled) { title = Resources.Strings.Firmware_RestoreFirmwareCommand_Cancelled_Title; message = Resources.Strings.Firmware_RestoreFirmwareCommand_CancelledMesssage; } else { var firmwareVersion = (FirmwareRevisions)result; title = Resources.Strings.Firmware_RestoreFirmwareCommand_Complete_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.Firmware_RestoreFirmwareCommand_CompleteMessageFormat, FirmwareRevisions.FirmwareVersionToString(firmwareVersion.Current, false)); } OSMessageBox.Show(message, title); }
internal static void SetManual(object parameter) { var program = (ProgramViewModel)parameter; var newManual = BrowseForSupportFile(program, ProgramFileKind.ManualText); if (!string.IsNullOrEmpty(newManual)) { if (AcceptManual(newManual)) { program.Manual = newManual; } else { OSMessageBox.Show(RomListViewModel.InvalidManualMessage, RomListViewModel.InvalidManualTitle, OSMessageBoxButton.OK, OSMessageBoxIcon.Error); } } CommandManager.InvalidateRequerySuggested(); }
public static void ReportError <T>(ReportMechanism reportMechanism, string message, string title) where T : Exception { switch (reportMechanism) { case ReportMechanism.Console: System.Console.WriteLine(title + ": " + message); break; case ReportMechanism.Debug: System.Diagnostics.Debug.WriteLine(title + ": " + message); break; case ReportMechanism.Dialog: OSMessageBox.Show(message, title, OSMessageBoxButton.OK, OSMessageBoxIcon.Error); break; case ReportMechanism.Exception: throw (Exception)Activator.CreateInstance(typeof(T), message); } }
private static void OnRestoreFirmware(object viewModel) { var warningDialogResult = OSMessageBox.Show( Resources.Strings.FirmwareRestore_Message, Resources.Strings.FirmwareRestore_Title, OSMessageBoxButton.YesNo, OSMessageBoxIcon.Exclamation, OSMessageBoxResult.No); if (warningDialogResult == OSMessageBoxResult.Yes) { // Actually reset the device to factory default! var ltoFlashViewModel = viewModel as LtoFlashViewModel; if (ltoFlashViewModel.ActiveLtoFlashDevice.IsValid) { var device = ltoFlashViewModel.ActiveLtoFlashDevice.Device; device.RemoveSecondaryFirmware(FirmwareRestoreCompleteHandler, (m, e) => ErrorHandler(Model.Commands.ProtocolCommandId.FirmwareEraseSecondary, m, e)); } } }
private static void OnRestoreRomList(object parameter) { var configuration = INTV.Shared.Model.RomListConfiguration.Instance; var message = Resources.Strings.RestoreRomListCommand_Message; var title = Resources.Strings.RestoreRomListCommand_MessageTitle; var doRestore = OSMessageBox.Show(message, title, OSMessageBoxButton.YesNo, OSMessageBoxIcon.Exclamation); if (doRestore == OSMessageBoxResult.Yes) { var backupDirectory = configuration.BackupDataDirectory; var backupFileName = INTV.Shared.Model.RomListConfiguration.Instance.DefaultRomsFileName; var selectBackupDialog = SelectBackupDialog.Create(backupDirectory, backupFileName, null, false); selectBackupDialog.Title = Resources.Strings.RestoreRomListCommand_SelectBackupTitle; var doRestoreResult = selectBackupDialog.ShowDialog(); if (doRestoreResult == true) { var romsConfiguration = INTV.Shared.Model.RomListConfiguration.Instance; var backupRomListFile = System.IO.Path.Combine(selectBackupDialog.SelectedBackupDirectory, romsConfiguration.DefaultRomsFileName); var romsFileExists = System.IO.File.Exists(backupRomListFile); if (romsFileExists) { var restoreRomListTask = new AsyncTaskWithProgress("RestoreRomList", false, true, 0); restoreRomListTask.UpdateTaskTitle(Resources.Strings.RestoreRomListCommand_MessageTitle); var restoreMenuLayoutTaskData = new RestoreRomListTaskData(restoreRomListTask, backupRomListFile, parameter as RomListViewModel); restoreRomListTask.RunTask(restoreMenuLayoutTaskData, RestoreRomList, RestoreRomListComplete); } else { var errorMessage = new System.Text.StringBuilder(Resources.Strings.RestoreRomListCommand_MissingFileErrorMessage).AppendLine().AppendLine(); errorMessage.AppendLine(selectBackupDialog.SelectedBackupDirectory).AppendLine(); if (!romsFileExists) { errorMessage.AppendLine(romsConfiguration.DefaultRomsFileName); } message = errorMessage.ToString(); title = Resources.Strings.RestoreRomListCommand_MissingFileErrorTitle; OSMessageBox.Show(message, title, OSMessageBoxButton.OK, OSMessageBoxIcon.Error); } } } }
private void HandleSaveFailed(object sender, INTV.Shared.Model.Program.ProgramCollectionSaveFailedEventArgs e) { // FIXME: If this is ever invoked from a non-UI thread -- I'm looking at you, Mac, it may be trouble. var title = Resources.Strings.RomList_SaveFailed_Title; var message = Resources.Strings.RomList_SaveFailed_Message; var buttons = OSMessageBoxButton.OK; if (!string.IsNullOrEmpty(e.RomListBackupPath) && System.IO.File.Exists(e.RomListBackupPath)) { message += Resources.Strings.RomList_SaveFailed_PromptToRestoreMessage; buttons = OSMessageBoxButton.YesNo; } var result = OSMessageBox.Show(message, title, e.Error, buttons, OSMessageBoxIcon.Error); if ((result == OSMessageBoxResult.Yes) && !string.IsNullOrEmpty(e.RomListBackupPath) && System.IO.File.Exists(e.RomListBackupPath)) { var romsConfiguration = INTV.Shared.Model.RomListConfiguration.Instance; System.IO.File.Replace(e.RomListPath, romsConfiguration.RomFilesPath, null); InitializeRomList(romsConfiguration.RomFilesPath); } }
private static void OnClearEmulatorFile(object parameter, EmulatorFile whichFile) { CommandLineArgumentHelpers.CheckCommandLineArgumentStrings(); var viewModel = parameter as JzIntvSettingsPageViewModel; switch (whichFile) { case EmulatorFile.JzIntv: viewModel.EmulatorPath = null; break; case EmulatorFile.Exec: viewModel.ExecRomPath = null; break; case EmulatorFile.Grom: viewModel.GromRomPath = null; break; case EmulatorFile.Ecs: viewModel.EcsRomPath = null; break; case EmulatorFile.KeyboardConfig: viewModel.DefaultKeyboardConfigPath = null; break; case EmulatorFile.Cgc0Config: viewModel.JzIntvCgc1ConfigPath = null; break; case EmulatorFile.Cgc1Config: viewModel.JzIntvCgc1ConfigPath = null; break; default: OSMessageBox.Show(string.Format(Resources.Strings.ConfigurationFile_UnknownEmulatorFile_Error_Message_Format, whichFile), Resources.Strings.ConfigurationFile_UnknownEmulatorFile_Error_Title); break; } }
/// <summary> /// Report firmware command errors to the user. /// </summary> /// <param name="command">The firmware-related command that failed.</param> /// <param name="errorMessage">The message generated from the command execution code.</param> /// <param name="exception">The exception that caused the error, if applicable.</param> /// <returns><c>true</c> if the error was reported to the user.</returns> internal static bool ErrorHandler(INTV.LtoFlash.Model.Commands.ProtocolCommandId command, string errorMessage, System.Exception exception) { var handled = false; var title = string.Empty; var messageFormat = string.Empty; switch (command) { case Model.Commands.ProtocolCommandId.FirmwareEraseSecondary: handled = true; title = Resources.Strings.RestoreFirmwareCommand_Failed_Title; messageFormat = Resources.Strings.RestoreFirmwareCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareProgramSecondary: handled = true; title = Resources.Strings.Firmware_UpdateFirmwareCommand_Failed_Title; messageFormat = Resources.Strings.Firmware_UpdateFirmwareCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareGetRevisions: handled = true; title = Resources.Strings.GetFirmwareRevisionsCommand_Failed_Title; messageFormat = Resources.Strings.GetFirmwareRevisionsCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareValidateImageInRam: handled = true; title = Resources.Strings.ProtocolCommandId_FirmwareValidateImageInRam_Title; messageFormat = Resources.Strings.ProtocolCommandId_FirmwareValidateImageInRam_Failed; break; } if (handled) { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, messageFormat, errorMessage); OSMessageBox.Show(message, title); } return(handled); }
private static void DownloadRom(IntellicartViewModel intellicart, IProgramDescription program) { if (program != null) { var isCompatible = intellicart.Model.IsRomCompatible(program); if (!isCompatible) { var message = string.Format(Resources.Strings.DownloadCommand_IncompatibleRom_Message_Format, program.Name); isCompatible = OSMessageBox.Show(message, Resources.Strings.DownloadCommand_IncompatibleRom_Title, OSMessageBoxButton.YesNo) == OSMessageBoxResult.Yes; } if (isCompatible) { if ((program != null) && (program.Rom != null) && !program.Rom.Validate()) { OSMessageBox.Show(string.Format(Resources.Strings.DownloadCommand_Missing_Message_Format, program.Name, program.Rom.RomPath), string.Format(Resources.Strings.DownloadCommand_Failed_Title_Format, program.Name)); } else { intellicart.Model.DownloadRom(program.Name, program.Rom, OnDownloadError); } } } }
private static void InstallSDLComplete(AsyncTaskData taskData) { var data = (InstallSDLTaskData)taskData; var diskImageInfo = data.DiskImageInfo; if (!string.IsNullOrEmpty(data.ErrorMessage) || (data.Error != null)) { var message = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_GeneralFailureMessage, diskImageInfo.Version); var title = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Failure_Title, diskImageInfo.Version); var dialog = INTV.Shared.View.ReportDialog.Create(title, message); dialog.TextWrapping = OSTextWrapping.Wrap; dialog.ShowSendEmailButton = false; dialog.ReportText = data.ErrorMessage; dialog.Exception = data.Error; dialog.ShowDialog(Resources.Strings.ReportErrorDialogButtonText); } else { var message = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Success_Message, diskImageInfo.Version); var title = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Success_Title, diskImageInfo.Version); OSMessageBox.Show(message, title); } }
private static void HandleLoadError(string romListFile, Exception exception) { var backupCopyPath = romListFile.GetUniqueBackupFilePath(); var errorDialog = INTV.Shared.View.ReportDialog.Create(Resources.Strings.RomList_LoadFailed_Title, Resources.Strings.RomList_LoadFailed_Message); errorDialog.ReportText = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.RomList_LoadFailed_Error_Format, backupCopyPath, exception); errorDialog.BeginInvokeDialog( Resources.Strings.RomList_LoadFailed_BackupButton_Text, new System.Action <bool?>((result) => { if (result.HasValue && result.Value) { try { File.Copy(romListFile, backupCopyPath); } catch (System.Exception x) { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.RomList_LoadFailed_BackupFailed_Message_Format, x.Message); OSMessageBox.Show(message, Resources.Strings.RomList_LoadFailed_Title, x, OSMessageBoxButton.OK, OSMessageBoxIcon.Error); } } })); }
/// <summary> /// Mac-specific error handler. /// </summary> /// <param name="emulator">The emulator instance that was running.</param> /// <param name="message">The error message.</param> /// <param name="exitCode">The exit code of the emulator.</param> /// <param name="exception">The exception that occurred.</param> static partial void OSErrorHandler(Emulator emulator, string message, int exitCode, Exception exception) { if (IsSDLMissingError(exitCode)) { var sdlVersionInfo = IncludedSDLVersion; var errorMessage = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLNotFound_ErrorMessage, sdlVersionInfo.Version); // Check to see if we can determine the missing SDL version from the error message. // If the missing version is not the same as the included version, we must get the "other" version. // Also, check to see if we already have the included SDL installed. If we do, but the failure still indicates // that it's missing, then it's possible the version of jzIntv being run requires the "other" version of SDL. // Switch over to the 'other' version for reporting the error if such is the case. var missingVersion = GetMissingSDLVersionFromErrorMessage(message); if ((missingVersion != SDLVersion.Unknown) && (missingVersion != IncludedSDLVersion.Version) || sdlVersionInfo.IsAlreadyInstalled) { sdlVersionInfo = sdlVersionInfo.GetOtherSDLVersionInfo(); errorMessage = string.Format( CultureInfo.CurrentCulture, Resources.Strings.SDLNotFound_DownloadMissingVersion_Format, sdlVersionInfo.Version, sdlVersionInfo.VersionNumber, sdlVersionInfo.DownloadUrl); } var errorTitle = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLNotFound_ErrorTitle, sdlVersionInfo.Version); if (OSMessageBox.Show(errorMessage, errorTitle, OSMessageBoxButton.YesNo) == OSMessageBoxResult.Yes) { var installSDLTask = new AsyncTaskWithProgress("InstallSDL", allowsCancel: false, isIndeterminate: true, progressDisplayDelay: 0); var installTitle = string.Format(CultureInfo.CurrentCulture, Resources.Strings.SDLInstall_Title, sdlVersionInfo.Version); installSDLTask.UpdateTaskTitle(installTitle); var installSDLTaskData = new InstallSDLTaskData(installSDLTask, sdlVersionInfo); installSDLTask.RunTask(installSDLTaskData, InstallSDL, InstallSDLComplete); } } }
private static void SyncDeviceToHostCompleteDialog(bool cancelled, bool didShowProgress, LtoFlashViewModel ltoFlashViewModel, FileSystemSyncErrors syncErrors) { ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = ltoFlashViewModel.HostPCMenuLayout.Items.Count == 0; bool showDialog = true; var title = string.Empty; var message = string.Empty; var icon = OSMessageBoxIcon.None; if (syncErrors.Any) { icon = OSMessageBoxIcon.Information; title = Resources.Strings.SyncDeviceToHostCommandComplete_WarningTitle; var briefReport = new System.Text.StringBuilder().AppendLine(Resources.Strings.SyncDeviceToHostCommandComplete_WarningsMessage); if (syncErrors.FailedToCreateEntries.Any()) { briefReport.AppendFormat(" " + Resources.Strings.SyncErrors_MissingEntriesFormat, syncErrors.FailedToCreateEntries.Count).AppendLine(); } if (syncErrors.UnableToRetrieveForks.Any()) { briefReport.Append(" ").AppendFormat(Resources.Strings.SyncErrors_UnableToRetrieveForksFormat, syncErrors.UnableToRetrieveForks.Count).AppendLine(); } if (syncErrors.OrphanedForks.Any()) { briefReport.Append(" ").AppendFormat(Resources.Strings.SyncErrors_OrphanedForksFormat, syncErrors.OrphanedForks.Count).AppendLine(); } if (syncErrors.UnsupportedForks.Any()) { briefReport.Append(" ").AppendFormat(Resources.Strings.SyncErrors_UnsupportedForksFormat, syncErrors.UnsupportedForks.Count).AppendLine(); briefReport.AppendLine().AppendLine(Resources.Strings.SyncErrors_UnsupportedForksInfo); } briefReport.AppendLine().AppendLine(Resources.Strings.SyncDeviceToHostCommandComplete_DireWarning); message = briefReport.ToString(); syncErrors.RecordErrors(Configuration.Instance.ErrorLogDirectory, "SYNC_LTOFLASH_TO_COMPUTER", "SyncDeviceToHost" + PathUtils.GetTimeString() + ".txt"); } else { if (cancelled && (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None)) { showDialog = false; } else if (!cancelled && !didShowProgress) { showDialog = false; } if (showDialog) { title = cancelled ? Resources.Strings.SyncDeviceToHostCommandCancelled_Title : Resources.Strings.SyncDeviceToHostCommandComplete_Title; if (cancelled) { message = Resources.Strings.SyncDeviceToHostCommandCancelled_Message; } else { message = Resources.Strings.SyncDeviceToHostCommandComplete_Message; } } } if (showDialog) { OSMessageBox.Show(message, title, OSMessageBoxButton.OK, icon); } ltoFlashViewModel.ActiveLtoFlashDevice.Device.GetFileSystemStatistics(GetFileSystemStatisticsErrorHandler); }
/// <summary> /// Prompts to confirm a firmware update operation and then executes the update if so instructed. /// </summary> /// <param name="device">The target device of the firmware upgrade.</param> /// <param name="firmwareFile">Absolute path to the file containing the firmware update bits.</param> /// <param name="additionalMessagePrefix">Additional optional message prefix.</param> /// <param name="additionalMessageSuffix">Additional optional message suffix.</param> internal static void UpdateFirmware(Device device, string firmwareFile, string additionalMessagePrefix, string additionalMessageSuffix) { string message = string.Empty; if (string.IsNullOrWhiteSpace(firmwareFile) || !System.IO.File.Exists(firmwareFile)) { message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.UpdateFirmwareCommand_FileNotFoundErrorMessageFormat, firmwareFile); OSMessageBox.Show(message, Resources.Strings.UpdateFirmwareCommand_FileNotFoundErrorTitle); return; } var fileInfo = new System.IO.FileInfo(firmwareFile); if ((fileInfo.Length > Device.TotalRAMSize) || (fileInfo.Length < MinimumFirmwareUpdateFileSize)) { var badFileSizetitle = Resources.Strings.UpdateFirmwareCommand_FileTooLargeErrorTitle; var messageFormat = Resources.Strings.UpdateFirmwareCommand_FileTooLargeErrorMessageFormat; if (fileInfo.Length < MinimumFirmwareUpdateFileSize) { badFileSizetitle = Resources.Strings.UpdateFirmwareCommand_FileTooSmallErrorTitle; messageFormat = Resources.Strings.UpdateFirmwareCommand_FileTooSmallErrorMessageFormat; } message = string.Format(System.Globalization.CultureInfo.CurrentCulture, messageFormat, firmwareFile, fileInfo.Length); OSMessageBox.Show(message, badFileSizetitle); return; } var firmwareRevisions = device.FirmwareRevisions; int currentVersion = firmwareRevisions.Current & ~FirmwareRevisions.SecondaryMask; int primaryVersion = firmwareRevisions.Primary; bool isValidFirmwareFile; int updateVersion = ExtractFirmwareUpdateVersion(firmwareFile, out isValidFirmwareFile); string title = string.Empty; var dialogButtons = OSMessageBoxButton.YesNo; var icon = OSMessageBoxIcon.Question; var updateMode = FirmwareUpdateMode.None; var flags = (updateVersion == currentVersion) ? 0 : FirmwareRevisions.SecondaryMask; if (firmwareRevisions.Secondary != FirmwareRevisions.UnavailableFirmwareVersion) { var secondaryVersion = firmwareRevisions.Secondary & ~FirmwareRevisions.SecondaryMask; if (updateVersion == secondaryVersion) { updateMode = FirmwareUpdateMode.ReapplySecondary; } else if (updateVersion == primaryVersion) { updateMode = FirmwareUpdateMode.RevertToPrimary; } else if (updateVersion > secondaryVersion) { updateMode = FirmwareUpdateMode.UpgradeSecondary; } else if (updateVersion < secondaryVersion) { updateMode = FirmwareUpdateMode.DowngradeSecondary; } } else { // No secondary firmware -- still running primary. if (updateVersion > primaryVersion) { updateMode = FirmwareUpdateMode.UpgradeSecondary; } else if (updateVersion < primaryVersion) { updateMode = FirmwareUpdateMode.DowngradeSecondary; } ////else // proposed update is same as primary, so do nothing } var currentVersionString = FirmwareRevisions.FirmwareVersionToString(firmwareRevisions.Current, false); var updateVersionString = FirmwareRevisions.FirmwareVersionToString(updateVersion | flags, false); switch (updateMode) { case FirmwareUpdateMode.None: title = Resources.Strings.FirmwareUpdate_SameAsFactory_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.FirmwareUpdate_SameAsFactory_Message, currentVersionString); icon = OSMessageBoxIcon.Information; dialogButtons = OSMessageBoxButton.OK; break; case FirmwareUpdateMode.UpgradeSecondary: flags |= FirmwareRevisions.SecondaryMask; title = Resources.Strings.FirmwareUpdate_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.FirmwareUpdate_MessageFormat, currentVersionString, updateVersionString); icon = OSMessageBoxIcon.Question; break; case FirmwareUpdateMode.DowngradeSecondary: flags |= FirmwareRevisions.SecondaryMask; title = Resources.Strings.FirmwareUpdate_Downgrade_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.FirmwareUpdate_Downgrade_MessageFormat, currentVersionString, updateVersionString); icon = OSMessageBoxIcon.Exclamation; break; case FirmwareUpdateMode.ReapplySecondary: flags |= FirmwareRevisions.SecondaryMask; title = Resources.Strings.FirmwareUpdate_Reapply_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.FirmwareUpdate_Reapply_Message, currentVersionString); break; case FirmwareUpdateMode.RevertToPrimary: title = Resources.Strings.FirmwareRestore_Title; message = string.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.Strings.FirmwareUpdate_SameAsFactoryRestore_Message, FirmwareRevisions.FirmwareVersionToString(firmwareRevisions.Primary, false)); break; } if (!string.IsNullOrEmpty(additionalMessagePrefix)) { message = additionalMessagePrefix + System.Environment.NewLine + System.Environment.NewLine + message; } if (!string.IsNullOrEmpty(additionalMessageSuffix)) { message += System.Environment.NewLine + System.Environment.NewLine + additionalMessageSuffix; } var warningDialogResult = OSMessageBoxResult.No; try { SingleInstanceApplication.Instance.IsBusy = true; warningDialogResult = OSMessageBox.Show(message, title, dialogButtons, icon, OSMessageBoxResult.No); } finally { SingleInstanceApplication.Instance.IsBusy = false; } if (warningDialogResult == OSMessageBoxResult.Yes) { // Actually apply the firmware update! if (updateMode == FirmwareUpdateMode.RevertToPrimary) { device.RemoveSecondaryFirmware(FirmwareRestoreCompleteHandler, (m, e) => ErrorHandler(Model.Commands.ProtocolCommandId.FirmwareEraseSecondary, m, e)); } else { device.UpdateFirmware(firmwareFile, updateVersion | flags, (c, p, r) => FirmwareUpdateCompleteHandler(c, p, r, firmwareFile), (m, e) => ErrorHandler(Model.Commands.ProtocolCommandId.FirmwareProgramSecondary, m, e)); } } }
private static void SyncHostToDeviceCompleteDialog(bool cancelled, bool didShowProgress, LtoFlashViewModel ltoFlashViewModel, IDictionary <string, FailedOperationException> warnings) { ltoFlashViewModel.HostPCMenuLayout.ShowOverlay = false; bool showDialog = true; if (cancelled && (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None)) { showDialog = false; } if (showDialog) { var title = cancelled ? Resources.Strings.SyncHostToDeviceCommandCancelled_Title : Resources.Strings.SyncHostToDeviceCommandComplete_Title; var message = string.Empty; if (cancelled) { if (ltoFlashViewModel.ActiveLtoFlashDevice.Device.FileSystem.Status == LfsDirtyFlags.None) { message = Resources.Strings.SyncHostToDeviceCommandCancelledNoChanges_Message; } else { message = Resources.Strings.SyncHostToDeviceCommandCancelled_Message; } } else { message = Resources.Strings.SyncHostToDeviceCommandComplete_Message; } var result = OSMessageBoxResult.Yes; if ((warnings != null) && warnings.Any()) { var reportDialog = ReportDialog.Create(title, message); reportDialog.ShowSendEmailButton = false; var warningsBuilder = new System.Text.StringBuilder(Resources.Strings.SyncHostToDeviceCommand_WarningMessage).AppendLine().AppendLine(); foreach (var warning in warnings) { warningsBuilder.AppendFormat(Resources.Strings.SyncHostToDeviceCommand_WarningFormat, warning.Key, warning.Value.Message).AppendLine().AppendLine(); } if (SingleInstanceApplication.SharedSettings.ShowDetailedErrors) { warningsBuilder.AppendLine(Resources.Strings.SyncHostToDeviceCommand_WarningDetailHeader).AppendLine("------------------------------------------------"); foreach (var exception in warnings.Values) { warningsBuilder.AppendLine(exception.ToString()).AppendLine(); } } reportDialog.ReportText = warningsBuilder.ToString(); reportDialog.TextWrapping = OSTextWrapping.Wrap; reportDialog.ShowDialog(Resources.Strings.OK); } else { var buttons = cancelled ? OSMessageBoxButton.YesNo : OSMessageBoxButton.OK; result = OSMessageBox.Show(message, title, buttons); } if (cancelled && (result == OSMessageBoxResult.Yes) && CanSyncHostToDevicePreview(ltoFlashViewModel)) { SyncHostToDevicePreview(ltoFlashViewModel); } } ltoFlashViewModel.ActiveLtoFlashDevice.Device.GetFileSystemStatistics(GetFileSystemStatisticsErrorHandler); }
private bool ErrorHandler(DeviceStatusFlags deviceStatusFlags, ProtocolCommandId commandId, string errorMessage, System.Exception exception) { bool handled = false; var title = string.Empty; var messageFormat = string.Empty; var showMessageBox = false; switch (commandId) { case ProtocolCommandId.SetConfiguration: handled = true; showMessageBox = handled; switch (deviceStatusFlags.Lo) { case DeviceStatusFlagsLo.IntellivisionIIStatusMask: title = Resources.Strings.SetConfigurationCommand_IntellivisionII_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_IntellivisionII_Failed_Message_Format; break; case DeviceStatusFlagsLo.EcsStatusMask: title = Resources.Strings.SetConfigurationCommand_Ecs_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_Ecs_Failed_Message_Format; break; case DeviceStatusFlagsLo.ShowTitleScreenMask: title = Resources.Strings.SetConfigurationCommand_ShowTitleScreen_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_ShowTitleScreen_Failed_Message_Format; break; case DeviceStatusFlagsLo.SaveMenuPositionMask: title = Resources.Strings.SetConfigurationCommand_SaveMenuPosition_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_SaveMenuPosition_Failed_Message_Format; break; case DeviceStatusFlagsLo.BackgroundGC: title = Resources.Strings.SetConfigurationCommand_BackgroundGC_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_BackgroundGC_Failed_Message_Format; break; case DeviceStatusFlagsLo.Keyclicks: title = Resources.Strings.SetConfigurationCommand_Keyclicks_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_Keyclicks_Failed_Message_Format; break; case DeviceStatusFlagsLo.ZeroRamBeforeLoad: title = Resources.Strings.SetConfigurationCommand_RandomizeLtoFlashRam_Failed_Title; messageFormat = Resources.Strings.SetConfigurationCommand_RandomizeLtoFlashRam_Failed_Message_Format; break; } break; case ProtocolCommandId.DownloadCrashLog: handled = true; showMessageBox = handled; title = Resources.Strings.GetErrorAndCrashLogs_Failed_Title; messageFormat = Resources.Strings.GetErrorAndCrashLogs_Failed_Message_Format; break; case ProtocolCommandId.UnknownCommand: handled = true; var application = SingleInstanceApplication.Instance; if ((application != null) && (application.MainWindow != null)) { var portName = "<null>"; if ((Device != null) && (Device.Port != null)) { portName = Device.Port.Name; } var message = string.Format(CultureInfo.CurrentCulture, Resources.Strings.DeviceValidation_Failed_Message_Format, portName); var dialog = INTV.Shared.View.ReportDialog.Create(Resources.Strings.DeviceValidation_Failed_Title, message); dialog.ReportText = errorMessage; dialog.ShowSendEmailButton = false; dialog.ShowCopyToClipboardButton = false; dialog.BeginInvokeDialog(Resources.Strings.OK, null); } break; default: break; } if (showMessageBox && handled) { var message = string.Format(CultureInfo.CurrentCulture, messageFormat, errorMessage); OSMessageBox.Show(message, title, SingleInstanceApplication.SharedSettings.ShowDetailedErrors ? exception : null, (r) => { }); } return(handled); }