public static FindSDKTool ( string exeName ) : string | ||
exeName | string | |
return | string |
private void dialogEditorButton_Click(object sender, EventArgs e) { if (listViewStrings.SelectedItems.Count > 0) { ListViewItem item = listViewStrings.SelectedItems[0]; LocString str = (LocString)item.Tag; Save(); string winResExe = RunProgram.FindSDKTool("winres.exe"); if (winResExe == null) { MessageBox.Show(@"Cannot find al.exe in the Windows SDK. Make sure the Windows SDK is installed in c:\Program Files\Microsoft SDKs\Windows"); } else { // The unlocalized file must be copied to the same directory as the localized for winres to work. string resXFileName = str.File.LocalizedFileName; string resXUnlocalized = str.File.NonLocalizedFileName; string resXCopiedUnlocalized = Path.Combine(Path.GetDirectoryName(resXFileName), Path.GetFileName(resXUnlocalized)); bool copy = !string.Equals(resXUnlocalized, resXCopiedUnlocalized, StringComparison.InvariantCultureIgnoreCase); if (copy) { File.Copy(resXUnlocalized, resXCopiedUnlocalized, true); } Enabled = false; try { RunProgram runProgram = new RunProgram(); runProgram.Run(winResExe, Path.GetFileName(resXFileName), Path.GetDirectoryName(resXFileName)); } finally { Enabled = true; Activate(); } if (copy) { File.Delete(resXCopiedUnlocalized); } resourceDirectory.ReadResources(); PopulateListView(); } } }
// Generate a DLL with resources in it. public bool Generate(ResourceDirectory directory) { string directoryPath = Path.Combine(OutputDirectory, directory.Culture.Name); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } List <string> resourcesFiles = new List <string>(); // Find tools. alExeName = RunProgram.FindSDKTool("al.exe"); if (alExeName == null) { ErrorText += @"Cannot find al.exe in the Windows SDK. Make sure the Windows SDK is installed in c:\Program Files\Microsoft SDKs\Windows"; } resgenExeName = RunProgram.FindSDKTool("resgen.exe"); if (resgenExeName == null) { ErrorText += @"Cannot find resgen.exe in the Windows SDK. Make sure the Windows SDK is installed in c:\Program Files\Microsoft SDKs\Windows"; } if (alExeName == null || resgenExeName == null) { return(false); } // Convert all .resx to .resources. foreach (ResXFile resxFile in directory.AllFiles) { bool success = ConvertResX(resxFile, directoryPath); if (!success) { ErrorText += programRunner.Output; return(false); } } // Create response file for AL. string responseFileName = Path.Combine(directoryPath, "alresp.txt"); using (TextWriter responseWriter = new StreamWriter(responseFileName)) { responseWriter.WriteLine("/t:lib"); foreach (ResXFile resxFile in directory.AllFiles) { string resourceFile = GetResourcesName(resxFile, directoryPath); responseWriter.WriteLine("/embed:\"{0}\",\"{1}.{2}\"", resourceFile, Namespace, Path.GetFileName(resourceFile)); } responseWriter.WriteLine("/culture:{0}", directory.Culture.Name); responseWriter.WriteLine("/out:\"{0}\"", Path.Combine(directoryPath, DllName + ".resources.dll")); } // Run AL.EXE int exitCode = programRunner.Run(alExeName, "\"@" + responseFileName + "\"", directoryPath); ErrorText += programRunner.Output; if (exitCode == 0) { foreach (ResXFile resxFile in directory.AllFiles) { string resourceFile = GetResourcesName(resxFile, directoryPath); File.Delete(resourceFile); } return(true); } else { return(false); } }