private static IRenderHost CreateWindowWpf(Size size, string title, Func <IRenderHostSetup, IRenderHost> constructorForRenderHost) { var window = new System.Windows.Window() { Width = size.Width, Height = size.Height, Title = title }; var hostControl = CreateHostControl(); // create forms host which is basically a wrapper for the WPF to function properly var windowsFormsHost = new System.Windows.Forms.Integration.WindowsFormsHost() { Child = hostControl, // Here, if need be, you can add necessary properties for the WPF //Width = 300, //Height = 200, //HorizontalAlignment = System.Windows.HorizontalAlignment.Left, //VerticalAlignment = System.Windows.VerticalAlignment.Top, //Margin = new System.Windows.Thickness(200, 100, 0, 0) }; window.Content = windowsFormsHost; window.Closed += (sender, args) => System.Windows.Application.Current.Shutdown(); window.Show(); var renderHostSetup = new RenderHostSetup(hostControl.Handle(), new Inputs.InputForms(hostControl)); // TODO: change default to IInput var renderHostToReturn = constructorForRenderHost(renderHostSetup); return(renderHostToReturn); }
private static IRenderHost CreateWindowForm(Size size, string title, Func <IRenderHostSetup, IRenderHost> constructorForRenderHost) { var window = new System.Windows.Forms.Form() { Size = size, Text = title }; var hostControl = CreateHostControl(); window.Controls.Add(hostControl); window.Closed += (sender, args) => System.Windows.Application.Current.Shutdown(); window.Show(); var renderHostSetup = new RenderHostSetup(hostControl.Handle(), new Inputs.InputForms(hostControl)); var renderHostToReturn = constructorForRenderHost(renderHostSetup); return(renderHostToReturn); }