public static void Main() { // Инициализация Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Проверка запуска единственной копии bool result; Mutex instance = new Mutex(true, ProgramDescription.AssemblyTitle, out result); if (!result) { MessageBox.Show(string.Format(Localization.GetText("AlreadyStarted", Localization.CurrentLanguage), ProgramDescription.AssemblyTitle), ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Отображение справки и запроса на принятие Политики if (!ProgramDescription.AcceptEULA()) { return; } ProgramDescription.ShowAbout(true); // Запуск Application.Run(new DatesDifferenceForm()); }
/// <summary> /// Launch the emulator to run the given ROM, using the supplied options. /// </summary> /// <param name="process">The emulator process to start.</param> /// <param name="options">The command line options for the emulator.</param> /// <param name="program">The program to run in the emulator.</param> /// <returns><c>true</c> if the process launched successfully; <c>false</c> otherwise.</returns> public bool Launch(Process process, IDictionary <CommandLineArgument, object> options, ProgramDescription program) { Rom = program; var commandLineArguments = options.BuildCommandLineArguments(program.Rom.RomPath, false); process.StartInfo.Arguments = commandLineArguments; process.StartInfo.FileName = Path; process.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(Path); process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.EnableRaisingEvents = true; process.OutputDataReceived += HandleOutputDataReceived; process.ErrorDataReceived += HandleErrorDataReceived; process.Exited += HandleProcessExited; var started = process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); Process = process; _launchedInstances.TryAdd(this, program); System.Diagnostics.Debug.WriteLine("jzIntv Launched with arguments: " + commandLineArguments); return(started); }
/// <summary> /// Refreshes the status of the program description by checking the file system. /// </summary> /// <param name="peripherals">Peripherals available for compatibility checks.</param> /// <returns><c>true</c>, if file status changed, <c>false</c> otherwise.</returns> public bool RefreshFileStatus(IEnumerable <IPeripheral> peripherals) { #if REPORT_PERFORMANCE var stopwatch = System.Diagnostics.Stopwatch.StartNew(); try { #endif // REPORT_PERFORMANCE var currentStatus = RomFileStatus; var currentIcon = RomFileStatusIcon; ProgramDescription.Validate(Model, peripherals, SingleInstanceApplication.Instance.GetConnectedDevicesHistory(), true); var state = Model.Files.GetSupportFileState(ProgramFileKind.Rom); RomFileStatus = GetRomFileStatus(state); RomFileStatusIcon = StatusIcons[state]; var statusChanged = (currentIcon != RomFileStatusIcon) || (currentStatus != RomFileStatus); if (statusChanged) { this.RaisePropertyChanged(PropertyChanged, "RomFileStatus"); this.RaisePropertyChanged(PropertyChanged, "RomFileStatusIcon"); } return(statusChanged); #if REPORT_PERFORMANCE } finally { stopwatch.Stop(); var romPath = Rom == null ? "<invalid ROM>" : Rom.RomPath; romPath = romPath ?? "<invalid ROM path>"; Logger.Log("ProgramDescriptionViewModel.RefreshFileStatus() for: " + romPath + " took: + " + stopwatch.Elapsed.ToString()); } #endif // REPORT_PERFORMANCE }
/// <summary> /// Initializes a new instance of the Program class. /// </summary> /// <param name="description">The program which is represented as a file.</param> /// <param name="fileSystem">The file system to which the program entry belongs.</param> public Program(ProgramDescription description, FileSystem fileSystem) : base(fileSystem) { var newDescription = description.Copy(); fileSystem.Files.Add(this); var updatedCrc = OnProgramDescriptionChanged(_description, newDescription, false); _description = newDescription; if (!updatedCrc) { UpdateCrc(); } _description.Files.DefaultLtoFlashDataPath = _description.Rom.GetLtoFlashFilePath(); // The following block causes at least two extra calls to IRomHelpers.PrepareForDeployment. // It's not clear exactly what the benefit of this is based on simple code inspection. #if false // Force updates for support files. var forceSupportFilesUpdates = new[] { ProgramSupportFiles.DefaultLtoFlashDataPathPropertyName, ProgramSupportFiles.RomConfigurationFilePathPropertyName, ProgramSupportFiles.DefaultManualTextPathPropertyName, ProgramSupportFiles.DefaultSaveDataPathPropertyName }; foreach (var supportFile in forceSupportFilesUpdates) { HandleProgramSupportFilesPropertyChanged(_description.Files, new System.ComponentModel.PropertyChangedEventArgs(supportFile)); } #endif // false }
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)); } } } }
/// <summary> /// Initializes a new instance of the ProgramDescriptionViewModel class. /// </summary> /// <param name="programDescription">The ProgramDescription model to model a view for.</param> public ProgramDescriptionViewModel(ProgramDescription programDescription) { _description = programDescription; _description.PropertyChanged += OnPropertyChanged; if (Properties.Settings.Default.RomListValidateAtStartup) { #if REPORT_PERFORMANCE var stopwatch = System.Diagnostics.Stopwatch.StartNew(); try { #endif // REPORT_PERFORMANCE ProgramDescription.Validate(programDescription, SingleInstanceApplication.Instance.GetAttachedDevices(), SingleInstanceApplication.Instance.GetConnectedDevicesHistory(), reportMessagesChanged: false); #if REPORT_PERFORMANCE } finally { stopwatch.Stop(); var romPath = Rom == null ? "<invalid ROM>" : Rom.RomPath; romPath = romPath ?? "<invalid ROM path>"; Logger.Log("ProgramDescriptionViewModel().Validate() for: " + romPath + " took: + " + stopwatch.Elapsed.ToString()); } #endif // REPORT_PERFORMANCE } var state = programDescription.Files.GetSupportFileState(ProgramFileKind.Rom); RomFileStatus = GetRomFileStatus(state); RomFileStatusIcon = StatusIcons[state]; Features = new ComparableObservableCollection <ProgramFeatureImageViewModel>(_description.Features.ToFeatureViewModels()); Initialize(); }
public void ProgramDescription_Copy_ProducesEquivalentCopy() { var information = new TestProgramInformation(); var crc = 5u; var name = "AgletMaster 5905"; information.AddCrc(crc, name); var description0 = new ProgramDescription(crc, null, information); description0.ShortName = "A\aa"; description0.Vendor = "V\vv"; var description1 = description0.Copy(); Assert.Equal(description0.Name, description1.Name); Assert.Equal(description0.ShortName, description1.ShortName); Assert.Equal(description0.Vendor, description1.Vendor); Assert.Equal(description0.Year, description1.Year); Assert.Equal(description0.Features, description1.Features); Assert.False(object.ReferenceEquals(description0.XmlName, description1.XmlName)); Assert.Equal(description0.XmlName.XmlText, description1.XmlName.XmlText); Assert.Equal(description0.XmlName.Escaped, description1.XmlName.Escaped); Assert.False(object.ReferenceEquals(description0.XmlShortName, description1.XmlShortName)); Assert.Equal(description0.XmlShortName.XmlText, description1.XmlShortName.XmlText); Assert.Equal(description0.XmlShortName.Escaped, description1.XmlShortName.Escaped); Assert.Equal(description0.Vendor, description1.Vendor); Assert.False(object.ReferenceEquals(description0.XmlVendor, description1.XmlVendor)); Assert.Equal(description0.XmlVendor.XmlText, description1.XmlVendor.XmlText); Assert.Equal(description0.XmlVendor.Escaped, description1.XmlVendor.Escaped); Assert.True(object.ReferenceEquals(description0.Rom, description1.Rom)); VerifyProgramInformation(description0.ProgramInformation, description1.ProgramInformation); VerifyProgramSupportFiles(description0.Files, description1.Files); Assert.Equal(description0, description1); }
public static void Main() { // Инициализация Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Проверка запуска единственной копии bool result; Mutex instance = new Mutex(true, ProgramDescription.AssemblyTitle, out result); if (!result) { MessageBox.Show(ProgramDescription.AssemblyTitle + " is already running", ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Отображение справки и запроса на принятие Политики if (!ProgramDescription.AcceptEULA()) { return; } ProgramDescription.ShowAbout(true); // Запуск Application.Run(new SudokuSolverForm()); }
// Запрос справки о программе private void TablesMergerForm_HelpButtonClicked(object sender, CancelEventArgs e) { // Отмена обработки события вызова справки e.Cancel = true; // Отображение ProgramDescription.ShowAbout(false); }
public void Ecs_IRomCompatibleWithEcsRom_IsTrue() { var ecs = new Ecs(); var programInformationTable = ProgramInformationTable.Initialize(Enumerable.Empty <ProgramInformationTableDescriptor>().ToArray()); var mindStrikeProgramId = new ProgramIdentifier(0x9D57498F); var mindStrikeInfo = programInformationTable.FindProgram(mindStrikeProgramId); Assert.NotNull(mindStrikeInfo); var mindStrikeDescription = new ProgramDescription(mindStrikeProgramId.DataCrc, null, mindStrikeInfo); Assert.True(ecs.IsRomCompatible(mindStrikeDescription)); }
public void ProgramDescription_ValidateWithNullRom_ThrowsNullReferenceException() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5400"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, null, information); Assert.Throws <NullReferenceException>(() => ProgramDescription.Validate(description, null, null, reportMessagesChanged: false)); // Throws because ROM is null. }
public void ProgramDescription_GetHashCode_ProducesExpectedHashCode() { var crc = 0x82736455u; var information = new TestProgramInformation(); information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); var expectedHashCode = crc.GetHashCode(); Assert.Equal(expectedHashCode, description.GetHashCode()); }
public void ProgramDescription_EqualsNull_ReturnsFalse() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5800a"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, null, information); Assert.False(description.Equals(null)); }
public void ProgramDescription_EqualsSelf_ReturnsTrue() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5700a"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, null, information); var self = description; Assert.True(description.Equals(self)); }
public void ProgramDescription_OperatorNullEquals_ReturnsFalse() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5900"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, null, information); IProgramDescription other = null; Assert.False(other == description); }
public void ProgramDescription_NullEquals_ThrowsNullReferenceException() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5900a"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, null, information); ProgramDescription nullProgramDescription = null; Assert.Throws <NullReferenceException>(() => nullProgramDescription.Equals(description)); }
public void ProgramDescription_SetFeatures_UpdatesFeatures() { var information = new TestProgramInformation(); var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); var newFeatures = new ProgramFeaturesBuilder().WithTutorvisionCompatibility(FeatureCompatibility.Requires).Build() as ProgramFeatures; description.Features = newFeatures; Assert.True(object.ReferenceEquals(newFeatures, description.Features)); }
public void ProgramDescription_SetCrcWhenNotInDatabase_UpdatesCrc() { var information = new TestProgramInformation(); var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); var newCrc = 0x12346587u; description.Crc = newCrc; Assert.Equal(newCrc, description.Crc); }
public void ProgramDescription_SetYear_YearIsExpectedValue(string newYear, string expectedYear) { var information = new TestProgramInformation() { Year = "1984" }; var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); description.Year = newYear; Assert.Equal(expectedYear, description.Year); }
public void ProgramDescription_SetShortName_ShortNameIsExpectedValue(string newShortName, string expectedShortName) { var information = new TestProgramInformation() { Title = "Taterkins", ShortName = "Tater" }; var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); description.ShortName = newShortName; Assert.Equal(expectedShortName, description.ShortName); }
public void ProgramDescription_SetVendor_VendorIsExpectedValue(string newVendor, string expectedVendor) { var information = new TestProgramInformation() { Vendor = "Vendorman" }; var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); description.Vendor = newVendor; Assert.Equal(expectedVendor, description.Vendor); }
public void ProgramDescription_RomIsNullSetProgramSupportFilesWithNullRom_UpdatesFilesAndLeavesRomUnchanged() { var information = new TestProgramInformation(); var crc = 1u; information.AddCrc(crc); var description = new ProgramDescription(crc, null, information); var newFiles = new ProgramSupportFiles(null); description.Files = newFiles; Assert.Null(description.Rom); Assert.True(object.ReferenceEquals(newFiles, description.Files)); }
public static void Main(string[] args) { // Инициализация Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Отображение справки и запроса на принятие Политики if (!ProgramDescription.AcceptEULA()) { return; } ProgramDescription.ShowAbout(true); // Запуск Application.Run(new TablesMergerForm()); }
public void ProgramDescription_ValidateWithValidRom_ReturnsTrue() { var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestRomPath).First(); var rom = Rom.Create(romPath, null); Assert.NotNull(rom); var information = new TestProgramInformation(); var crc = rom.Crc; var name = "AgletMaster 5500"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, rom, information); Assert.True(ProgramDescription.Validate(description, null, null, reportMessagesChanged: false)); }
private static void SyncFileData(FileNode localFile, ILfsFileInfo deviceFile, bool updateOnly, Dictionary <ushort, ushort> forkNumberMap, Dictionary <ushort, string> forkSourceFileMap, FileSystemSyncErrors syncErrors) { localFile.Color = deviceFile.Color; localFile.LongName = deviceFile.LongName; localFile.ShortName = deviceFile.ShortName; System.Diagnostics.Debug.Assert(localFile.GlobalFileNumber == deviceFile.GlobalFileNumber, "Need to figure out how to set GFN"); System.Diagnostics.Debug.Assert(localFile.GlobalDirectoryNumber == deviceFile.GlobalDirectoryNumber, "Need to figure out how to set GDN"); switch (deviceFile.FileType) { case FileType.File: var program = (Program)localFile; var forks = new ushort[(int)ForkKind.NumberOfForkKinds]; for (int i = 0; i < forks.Length; ++i) { ushort forkNumber; if (!forkNumberMap.TryGetValue(deviceFile.ForkNumbers[i], out forkNumber)) { forkNumber = GlobalForkTable.InvalidForkNumber; } forks[i] = forkNumber; } program.SetForks(deviceFile.ForkNumbers); ProgramDescription description = null; SyncForkData(localFile.Rom, ForkKind.Program, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); if (description != null) { program.Description = description; } SyncForkData(localFile.Manual, ForkKind.Manual, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); SyncForkData(localFile.JlpFlash, ForkKind.JlpFlash, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); SyncForkData(localFile.Vignette, ForkKind.Vignette, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); SyncForkData(localFile.ReservedFork4, ForkKind.Reserved4, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); SyncForkData(localFile.ReservedFork5, ForkKind.Reserved5, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); SyncForkData(localFile.ReservedFork6, ForkKind.Reserved6, forkSourceFileMap, (f, k) => ReportForkSyncError(f, k, localFile, syncErrors), ref description); break; case FileType.Folder: for (var i = 0; i < deviceFile.ForkNumbers.Length; ++i) { ((Folder)localFile).ForkNumbers[i] = deviceFile.ForkNumbers[i]; } break; default: throw new System.InvalidOperationException(Resources.Strings.FileSystem_InvalidFileType); } }
// Обработка клавиатуры private void MainForm_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { // Справка case Keys.F1: ProgramDescription.ShowAbout(false); break; // Сохранение case Keys.Return: SaveImage(); break; // Выход case Keys.Escape: case Keys.X: case Keys.Q: this.Close(); break; // Сброс выделения case Keys.Space: if (MainSelection.Visible) { MainSelection.Visible = false; } else { if (GetPointedWindowBounds(MousePosition.X, MousePosition.Y)) { MainSelection.Text = "(" + MainSelection.Left.ToString() + "; " + MainSelection.Top.ToString() + ") (" + MainSelection.Width.ToString() + " x " + MainSelection.Height.ToString() + ")"; MainSelection.Visible = true; } } break; // Смена языка интерфейса case Keys.L: LanguageForm lf = new LanguageForm(al); al = Localization.CurrentLanguage; Localize(); break; } }
public void ProgramDescription_ValidateWithValidRomWhoseCfgFileIsMissing_ReturnsFalse() { var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestLuigiScrambledForDevice0Path).First(); var rom = Rom.Create(romPath, null); Assert.NotNull(rom); var information = new TestProgramInformation(); var crc = 0x8C29E37Du; var name = "AgletMaster 5600"; information.AddCrc(crc, name); var description = new ProgramDescription(crc, rom, information); var v = ProgramDescription.Validate(description, null, null, reportMessagesChanged: false); Assert.False(ProgramDescription.Validate(description, null, null, reportMessagesChanged: false)); }
public void ProgramDescription_CreateWithMatchingCrcWithNullRomInformationWithFeaturesAndMatchingCrcMultipleIncompatibilities_FeaturesIncludesAllIncompatibilities() { var information = new TestProgramInformation(); var crc = 1u; var name = "AgletMaster 5300"; information.AddCrc(crc, name, IncompatibilityFlags.None); information.AddCrc(crc + 1, name, IncompatibilityFlags.Jlp); information.AddCrc(crc + 2, name, IncompatibilityFlags.LtoFlash); information.Features = new ProgramFeaturesBuilder().WithPalCompatibility(FeatureCompatibility.Enhances).Build() as ProgramFeatures; var description = new ProgramDescription(crc, null, information); Assert.Equal(FeatureCompatibility.Enhances, description.Features.Pal); Assert.Equal(JlpFeatures.Incompatible, description.Features.Jlp); Assert.Equal(LtoFlashFeatures.Incompatible, description.Features.LtoFlash); }
public static void Main(string[] args) { // Инициализация Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Проверка запуска единственной копии bool result; Mutex instance = new Mutex(true, ProgramDescription.AssemblyTitle, out result); if (!result) { if (args.Length > 0) { // Сохранение пути к вызываемому файлу и инициирование его обработки в запущенном приложении ConfigAccessor.NextDumpPath = args[0]; IntPtr ptr = FindWindow(null, ProgramDescription.AssemblyVisibleName); SendMessage(ptr, ConfigAccessor.NextDumpPathMsg, IntPtr.Zero, IntPtr.Zero); } else { MessageBox.Show("Программа " + ProgramDescription.AssemblyTitle + " уже запущена", ProgramDescription.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } // Отображение справки и запроса на принятие Политики if (!ProgramDescription.AcceptEULA()) { return; } ProgramDescription.ShowAbout(true); // Запуск if (args.Length > 0) { Application.Run(new TextToKKTForm(args[0])); } else { Application.Run(new TextToKKTForm("")); } }
/// <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; } } } } }