private void DisplayConsumerWindow(string workingDirectory, DemoAppLauncherSelection appSelection) { Console.WriteLine($"Command Parameters: {appSelection.ToString()} {BrokerAppType.Consumer.ToString()}"); var windowLayout = GetConsumerWindowLayout(appSelection); var windowHandle = ProcessCommand.StartProgram(workingDirectory, appSelection, BrokerAppType.Consumer, windowLayout); _windowHandles.Add(windowHandle); }
private WindowLayout GetPublisherWindowLayout(DemoAppLauncherSelection appSelection) { var width = 700; var height = 500; var windowLayout = GetWindowLayout(appSelection, width, height); _windowLayouts.Add(windowLayout); return(windowLayout); }
public void DisplayBrokerConsole(string workingDirectory, DemoAppLauncherSelection appSelection) { while (true) { Console.WriteLine(Enum.GetName(typeof(DemoAppLauncherSelection), appSelection)); Console.WriteLine("Type the number of the application to start and then press [enter]."); foreach (var value in Enum.GetValues(typeof(BrokerAppLauncherSelection))) { Console.WriteLine($"{(int)value} - {value}"); } var selection = Console.ReadLine(); Console.Clear(); Console.WriteLine($"Working Directory: {workingDirectory}"); if (string.IsNullOrEmpty(selection)) { continue; } BrokerAppLauncherSelection brokerAppSelection = (BrokerAppLauncherSelection)Enum.Parse(typeof(BrokerAppLauncherSelection), selection); if (brokerAppSelection != BrokerAppLauncherSelection.Exit) { switch (brokerAppSelection) { case BrokerAppLauncherSelection.Publisher: DisplayPublisherWindow(workingDirectory, appSelection); ProcessCommand.FocusProcess(_windowHandles.Last()); break; case BrokerAppLauncherSelection.Consumer: DisplayConsumerWindow(workingDirectory, appSelection); break; case BrokerAppLauncherSelection.All: DisplayConsumerWindow(workingDirectory, appSelection); DisplayConsumerWindow(workingDirectory, appSelection); DisplayConsumerWindow(workingDirectory, appSelection); DisplayPublisherWindow(workingDirectory, appSelection); var publisherHandle = _windowHandles.Last(); ProcessCommand.FocusProcess(publisherHandle); break; } } else { CloseWindows(); _windowLayouts = new List <WindowLayout>(); _windowHandles = new List <IntPtr>(); break; } } }
private WindowLayout GetWindowLayout(DemoAppLauncherSelection appSelection, int width, int height) { var count = _windowLayouts.Count; if (count == 0) { return(new WindowLayout() { Height = height, Width = width, StartX = xDefaultPosition + xOffset, StartY = yDefaultPosition }); } else { var last = _windowLayouts.Last(); return(new WindowLayout() { Height = height, Width = width, StartX = last.StartX + last.Width + xOffset, StartY = yDefaultPosition }); } }
public static IntPtr StartProgram(string workingDirectory, DemoAppLauncherSelection app, BrokerAppType subApp, WindowLayout wp) { var startInfo = new ProcessStartInfo("dotnet"); startInfo.Arguments = $"run --no-build {app.ToString()} {subApp.ToString()}"; startInfo.UseShellExecute = true; startInfo.WorkingDirectory = workingDirectory; var process = new Process(); process.StartInfo = startInfo; process.Start(); Thread.Sleep(500); var handle = process.MainWindowHandle; if (!MoveWindow((IntPtr)handle, wp.StartX, wp.StartY, wp.Width, wp.Height, true)) { throw new Win32Exception(); } return((IntPtr)handle); }