private static void CreateWindowInstance(ControlTestRequest request, ManualResetEventSlim evt) {
try {
Window = new Window();
if (Screen.AllScreens.Length == 1) {
Window.Left = 0;
Window.Top = 50;
} else {
Screen secondary = Screen.AllScreens.FirstOrDefault(x => !x.Primary);
Window.Left = secondary.WorkingArea.Left;
Window.Top = secondary.WorkingArea.Top + 50;
}
Window.Width = 800;
Window.Height = 600;
Component = Activator.CreateInstance(request.ControlType);
if (Component is Control) {
Control = Component as Control;
} else {
Control = Component.GetType().GetProperty("Control").GetValue(Component) as Control;
}
Window.Title = "Control - " + request.ControlType;
Window.Content = Control;
} finally {
evt.Set();
}
Window.Topmost = true;
Window.ShowDialog();
}