Game Development Reference
In-Depth Information
Alert Object Windows—Wrapper
The second method for a WinForms -based entry point is the wrapper approach,
where the WinForms application layers on top of the console entry point and redi-
rects all standard input and output through itself.
This approach is beneficial in the sense that there is less to code, since the major-
ity of the entry point code exists within the console entry point. Another benefit
is that this project does not require any references to the underlying framework or
specific tool logic.
Using this method also reduces the chances for bugs since one code base is main-
tained, and fixing a bug affects both entry points.
Here is the code for the WinForms entry point using the wrapper approach:
private void FirstTestWrapperButtonClick(object sender, System.EventArgs e)
{
LaunchConsoleWrapper(“1”);
}
private void SecondTestWrapperButtonClick(object sender, System.EventArgs e)
{
LaunchConsoleWrapper(“2”);
}
private void ThirdTestWrapperButtonClick(object sender, System.EventArgs e)
{
LaunchConsoleWrapper(“3”);
}
private void LaunchConsoleWrapper(string parameter)
{
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Arguments = parameter;
process.StartInfo.FileName = Application.StartupPath +
@”\AlertObjectConsole.exe”;
if (process.Start())
{
MessageBox.Show(process.StandardOutput.ReadToEnd());
process.WaitForExit();
Search Nedrilad ::




Custom Search