Run() public method

public Run ( string exeName, string commandLine, string directory ) : int
exeName string
commandLine string
directory string
return int
示例#1
0
        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();
                }
            }
        }
示例#2
0
        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();
                }
            }
        }
示例#3
0
        public void RunTool()
        {
            string exeName = RunProgram.FindSDKTool("winres.exe");

            RunProgram runner = new RunProgram();
            int exitCode = runner.Run(exeName, "", @"C:\");
            Console.WriteLine("Exit code: {0}", exitCode);
            Console.WriteLine("Output: ");
            Console.WriteLine(runner.Output);
        }
示例#4
0
        // 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);
            }
        }