Index: test/Common/DelftTools.TestUtils/WpfTestHelper.xaml.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- test/Common/DelftTools.TestUtils/WpfTestHelper.xaml.cs (.../WpfTestHelper.xaml.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ test/Common/DelftTools.TestUtils/WpfTestHelper.xaml.cs (.../WpfTestHelper.xaml.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -1,7 +1,9 @@ using System; using System.Windows; -using System.Windows.Controls; +using System.Windows.Forms; using log4net; +using Application = System.Windows.Forms.Application; +using Control = System.Windows.Controls.Control; namespace DelftTools.TestUtils { @@ -10,12 +12,16 @@ /// public partial class WpfTestHelper : Window { - private static ILog log = LogManager.GetLogger(typeof(WindowsFormsTestHelper)); + private static readonly ILog log = LogManager.GetLogger(typeof(WindowsFormsTestHelper)); + private static Window window; + private Action shownAction; - private GuiTestHelper guiTestHelper; + private readonly GuiTestHelper guiTestHelper; + private bool wasShown; + public WpfTestHelper() { InitializeComponent(); @@ -40,7 +46,7 @@ } } - public static void ShowModal(Control control, Action formVisibleChangedAction, params object[] propertyObjects) + public static void ShowModal(Control control, Action
formVisibleChangedAction, params object[] propertyObjects) { throw new InvalidOperationException("Use Action instead of Action (WPF)"); } @@ -63,7 +69,7 @@ } // clear all controls shown as non-modal after modal control closes - if(!modal) + if (!modal) { throw new NotImplementedException(); } @@ -82,8 +88,8 @@ while (window.IsVisible) { - System.Windows.Forms.Application.DoEvents(); - System.Windows.Forms.Application.DoEvents(); + Application.DoEvents(); + Application.DoEvents(); window.Close(); } @@ -111,10 +117,6 @@ } } - private bool wasShown; - - private static Window window; - private void ShowControlInTestForm(Control control, bool modal, object[] propertyObjects) { IsVisibleChanged += delegate { wasShown = true; }; @@ -132,9 +134,18 @@ } else { - window = new Window { Content = control }; + window = new Window + { + Content = control + }; } - window.IsVisibleChanged += delegate { if (window.IsVisible) wasShown = true; }; + window.IsVisibleChanged += delegate + { + if (window.IsVisible) + { + wasShown = true; + } + }; window.ContentRendered += delegate { wasShown = true; }; window.Show(); @@ -147,13 +158,13 @@ // wait until control is shown while (!wasShown && guiTestHelper.Exception == null) { - System.Windows.Forms.Application.DoEvents(); + Application.DoEvents(); } // is shown, not trigger action try { - System.Windows.Forms.Application.DoEvents(); + Application.DoEvents(); if (shownAction != null && wasShown) { @@ -170,7 +181,7 @@ { while (control.IsVisible) { - System.Windows.Forms.Application.DoEvents(); + Application.DoEvents(); } } @@ -180,4 +191,4 @@ } } } -} +} \ No newline at end of file