public void FormShouldAllowOwningToWpf() { bool passed = false; var ev = new ManualResetEvent(false); Invoke(() => { var nativeWindow = new sw.Window(); nativeWindow.SizeToContent = sw.SizeToContent.WidthAndHeight; nativeWindow.Closed += (sender, e) => ev.Set(); var showDialog = new Button { Text = "Show Owned Dialog" }; showDialog.Click += (sender, e) => { var parentWindow = showDialog.ParentWindow; if (parentWindow == null) { passed = false; nativeWindow.Close(); return; } var form = new Form(); var closeButton = new Button { Text = "Close" }; closeButton.Click += (sender2, e2) => form.Close(); form.Content = new StackLayout { Padding = 10, Spacing = 10, Items = { "This should show as a child to the parent, and should not be able to go behind it", closeButton } }; form.Owner = parentWindow; form.Show(); }; var passButton = new Button { Text = "Pass" }; passButton.Click += (sender, e) => { passed = true; nativeWindow.Close(); ev.Set(); }; var failButton = new Button { Text = "Fail" }; failButton.Click += (sender, e) => { passed = false; nativeWindow.Close(); ev.Set(); }; var panel = new StackLayout { Items = { new Panel { Padding = 20, Content = showDialog }, TableLayout.Horizontal(failButton, passButton) } }; var wpfPanel = panel.ToNative(true); nativeWindow.HorizontalContentAlignment = sw.HorizontalAlignment.Stretch; nativeWindow.VerticalContentAlignment = sw.VerticalAlignment.Stretch; nativeWindow.Content = wpfPanel; nativeWindow.Show(); }); ev.WaitOne(); Assert.IsTrue(passed); }
public void FormShouldAllowOwningToWinForms() { bool passed = false; var ev = new ManualResetEvent(false); Invoke(() => { var nativeWindow = new swf.Form(); nativeWindow.MinimumSize = new System.Drawing.Size(300, 300); nativeWindow.FormClosed += (sender, e) => ev.Set(); var wpfhost = new swf.Integration.ElementHost(); wpfhost.Dock = swf.DockStyle.Fill; nativeWindow.Controls.Add(wpfhost); var showDialog = new Button { Text = "Show Owned Dialog" }; showDialog.Click += (sender, e) => { var form = new Form(); var closeButton = new Button { Text = "Close" }; closeButton.Click += (sender2, e2) => form.Close(); form.Content = new StackLayout { Padding = 10, Spacing = 10, Items = { "This should show as a child to the parent, and should not be able to go behind it", closeButton } }; form.Owner = showDialog.ParentWindow; form.Show(); }; var passButton = new Button { Text = "Pass" }; passButton.Click += (sender, e) => { passed = true; nativeWindow.Close(); ev.Set(); }; var failButton = new Button { Text = "Fail" }; failButton.Click += (sender, e) => { passed = false; nativeWindow.Close(); ev.Set(); }; var panel = new StackLayout { Items = { new Panel { Padding = 20, Content = showDialog }, TableLayout.Horizontal(failButton, passButton) } }; wpfhost.Child = panel.ToNative(true); var parentWindow = panel.ParentWindow; nativeWindow.Show(); }); ev.WaitOne(); Assert.IsTrue(passed); }
public void DialogShouldAllowAttachingToNativeWindow() { bool passed = false; var ev = new ManualResetEvent(false); Invoke(() => { var nswindow = new NSWindow(new CGRect(100, 100, 300, 300), NSWindowStyle.Titled, NSBackingStore.Buffered, false); nswindow.ReleasedWhenClosed = false; var showDialog = new Button { Text = "Show Attached Dialog" }; showDialog.Click += (sender, e) => { var dlg = new Dialog(); dlg.DisplayMode = DialogDisplayMode.Attached; var closeButton = new Button { Text = "Close" }; closeButton.Click += (sender2, e2) => dlg.Close(); dlg.Content = new StackLayout { Padding = 10, Spacing = 10, Items = { "This should show as attached", closeButton } }; dlg.ShowModal(showDialog); }; var passButton = new Button { Text = "Pass" }; passButton.Click += (sender, e) => { passed = true; nswindow.Close(); ev.Set(); }; var failButton = new Button { Text = "Fail" }; failButton.Click += (sender, e) => { passed = false; nswindow.Close(); ev.Set(); }; var panel = new StackLayout { Items = { new Panel { Padding = 20, Content = showDialog }, TableLayout.Horizontal(failButton, passButton) } }; nswindow.ContentView = panel.ToNative(true); var parentWindow = panel.ParentWindow; nswindow.MakeKeyAndOrderFront(nswindow); }); ev.WaitOne(); Assert.IsTrue(passed); }