/// <summary>
        /// Shows the application window.
        /// </summary>
        private void ShowApplicationWindow()
        {
            var win = new MainWindow(_logger, _appHost.PlaybackManager, _appHost.ApiClient, _appHost.ImageManager, _appHost, _appHost.PresentationManager, _appHost.UserInputManager, _appHost.TheaterConfigurationManager, _appHost.NavigationService);

            var config = _appHost.TheaterConfigurationManager.Configuration;

            // Restore window position/size
            if (config.WindowState.HasValue)
            {
                // Set window state
                win.WindowState = config.WindowState.Value;

                // Set position if not maximized
                if (config.WindowState.Value != WindowState.Maximized)
                {
                    double left = 0;
                    double top = 0;

                    // Set left
                    if (config.WindowLeft.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        win.Left = left = Math.Max(config.WindowLeft.Value, 0);
                    }

                    // Set top
                    if (config.WindowTop.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        win.Top = top = Math.Max(config.WindowTop.Value, 0);
                    }

                    // Set width
                    if (config.WindowWidth.HasValue)
                    {
                        win.Width = Math.Min(config.WindowWidth.Value, SystemParameters.VirtualScreenWidth - left);
                    }

                    // Set height
                    if (config.WindowHeight.HasValue)
                    {
                        win.Height = Math.Min(config.WindowHeight.Value, SystemParameters.VirtualScreenHeight - top);
                    }
                }
            }

            win.LocationChanged += ApplicationWindow_LocationChanged;
            win.StateChanged += ApplicationWindow_LocationChanged;
            win.SizeChanged += ApplicationWindow_LocationChanged;
            win.Closing += win_Closing;

            HiddenWindow.Activated += HiddenWindow_Activated;
            HiddenWindow.IsVisibleChanged += HiddenWindow_IsVisibleChanged;

            ApplicationWindow = win;

            ApplicationWindow.Show();

            ApplicationWindow.Owner = HiddenWindow;

            SyncHiddenWindowLocation();

            ApplicationWindow.Activate();
        }
        /// <summary>
        /// Shows the application window.
        /// </summary>
        private void ShowApplicationWindow()
        {
            var win = new MainWindow(Logger);

            var config = CompositionRoot.UIConfigurationManager.Configuration;

            // Restore window position/size
            if (config.WindowState.HasValue)
            {
                // Set window state
                win.WindowState = config.WindowState.Value;

                // Set position if not maximized
                if (config.WindowState.Value != WindowState.Maximized)
                {
                    double left = 0;
                    double top = 0;

                    // Set left
                    if (config.WindowLeft.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        win.Left = left = Math.Max(config.WindowLeft.Value, 0);
                    }

                    // Set top
                    if (config.WindowTop.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        win.Top = top = Math.Max(config.WindowTop.Value, 0);
                    }

                    // Set width
                    if (config.WindowWidth.HasValue)
                    {
                        win.Width = Math.Min(config.WindowWidth.Value, SystemParameters.VirtualScreenWidth - left);
                    }

                    // Set height
                    if (config.WindowHeight.HasValue)
                    {
                        win.Height = Math.Min(config.WindowHeight.Value, SystemParameters.VirtualScreenHeight - top);
                    }
                }
            }

            win.LocationChanged += ApplicationWindow_LocationChanged;
            win.StateChanged += ApplicationWindow_LocationChanged;
            win.SizeChanged += ApplicationWindow_LocationChanged;

            ApplicationWindow = win;

            ApplicationWindow.Show();

            ApplicationWindow.Owner = HiddenWindow;

            SyncHiddenWindowLocation();
        }
        /// <summary>
        /// Shows the application window.
        /// </summary>
        private void ShowApplicationWindow()
        {
            var win = new MainWindow(_logger, _appHost.PlaybackManager, _appHost.ImageManager,
                _appHost, _appHost.PresentationManager, _appHost.UserInputManager, _appHost.TheaterConfigurationManager,
                _appHost.NavigationService, _appHost.ScreensaverManager, _appHost.ConnectionManager);

            var config = _appHost.TheaterConfigurationManager.Configuration;

            // Restore window position/size
            if (config.WindowState.HasValue)
            {
                double left = 0;
                double top = 0;

                // Set left
                if (config.WindowLeft.HasValue)
                {
                    win.WindowStartupLocation = WindowStartupLocation.Manual;
                    win.Left = left = Math.Max(config.WindowLeft.Value, SystemParameters.VirtualScreenLeft);
                }

                // Set top
                if (config.WindowTop.HasValue)
                {
                    win.WindowStartupLocation = WindowStartupLocation.Manual;
                    win.Top = top = Math.Max(config.WindowTop.Value, SystemParameters.VirtualScreenLeft);
                }

                // Set width
                if (config.WindowWidth.HasValue && config.WindowWidth.Value > 0)
                {
                    win.Width = Math.Min(config.WindowWidth.Value, SystemParameters.VirtualScreenWidth - left + SystemParameters.VirtualScreenLeft);
                }

                // Set height
                if (config.WindowHeight.HasValue && config.WindowHeight.Value > 0)
                {
                    win.Height = Math.Min(config.WindowHeight.Value, SystemParameters.VirtualScreenHeight - top + SystemParameters.VirtualScreenTop);
                }

                // Set window state
                win.WindowState = config.WindowState.Value;
            }
            else
            {
                //Set these so we don't generate exceptions later on. This also fixes the issue where the first run hidden window size problem.
                if (double.IsNaN(win.Width))
                    win.Width = System.Windows.SystemParameters.FullPrimaryScreenWidth * .75;
                if (double.IsNaN(win.Height))
                    win.Height = System.Windows.SystemParameters.FullPrimaryScreenHeight * .75;

                if (double.IsNaN(win.Top))
                    win.Top = 0;
                if (double.IsNaN(win.Left))
                    win.Left = 0;

                win.WindowState = WindowState.Normal;
            }

            ApplicationWindow = win;

            win.Loaded += win_Loaded;
            win.LocationChanged += win_LocationChanged;
            win.StateChanged += win_StateChanged;
            win.SizeChanged += win_SizeChanged;
            win.Closing += win_Closing;

            int? formWidth = null;
            int? formHeight = null;
            int? formLeft = null;
            int? formTop = null;

            try
            {
                formWidth = Convert.ToInt32(ApplicationWindow.Width);
                formHeight = Convert.ToInt32(ApplicationWindow.Height);
            }
            catch (OverflowException)
            {
                formWidth = null;
                formHeight = null;
            }
            try
            {
                formTop = Convert.ToInt32(ApplicationWindow.Top);
                formLeft = Convert.ToInt32(ApplicationWindow.Left);
            }
            catch (OverflowException)
            {
                formLeft = null;
                formTop = null;
            }

            var state = GetWindowsFormState(ApplicationWindow.WindowState);

            _hiddenWindowThread = new Thread(() => ShowHiddenWindow(formWidth, formHeight, formTop, formLeft, state));
            _hiddenWindowThread.SetApartmentState(ApartmentState.MTA);
            _hiddenWindowThread.IsBackground = true;
            _hiddenWindowThread.Priority = ThreadPriority.AboveNormal;
            _hiddenWindowThread.Start();
        }
        /// <summary>
        /// Shows the application window.
        /// </summary>
        private void ShowApplicationWindow()
        {
            var win = new MainWindow(_logger, _appHost.PlaybackManager, _appHost.ApiClient, _appHost.ImageManager,
                _appHost, _appHost.PresentationManager, _appHost.UserInputManager, _appHost.TheaterConfigurationManager,
                _appHost.NavigationService, _appHost.ScreensaverManager);

            var config = _appHost.TheaterConfigurationManager.Configuration;

            System.Windows.Forms.FormStartPosition? startPosition = null;

            // Restore window position/size
            if (config.WindowState.HasValue)
            {
                // Set window state
                win.WindowState = config.WindowState.Value;

                // Set position if not maximized
                if (config.WindowState.Value != WindowState.Maximized)
                {
                    double left = 0;
                    double top = 0;

                    // Set left
                    if (config.WindowLeft.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        startPosition = System.Windows.Forms.FormStartPosition.Manual;
                        win.Left = left = Math.Max(config.WindowLeft.Value, 0);
                    }

                    // Set top
                    if (config.WindowTop.HasValue)
                    {
                        win.WindowStartupLocation = WindowStartupLocation.Manual;
                        startPosition = System.Windows.Forms.FormStartPosition.Manual;
                        win.Top = top = Math.Max(config.WindowTop.Value, 0);
                    }

                    // Set width
                    if (config.WindowWidth.HasValue)
                    {
                        win.Width = Math.Min(config.WindowWidth.Value, SystemParameters.VirtualScreenWidth - left);
                    }

                    // Set height
                    if (config.WindowHeight.HasValue)
                    {
                        win.Height = Math.Min(config.WindowHeight.Value, SystemParameters.VirtualScreenHeight - top);
                    }
                }
            }

            ApplicationWindow = win;

            win.Loaded += win_Loaded;
            win.LocationChanged += win_LocationChanged;
            win.StateChanged += win_StateChanged;
            win.SizeChanged += win_SizeChanged;
            win.Closing += win_Closing;

            int? formWidth = null;
            int? formHeight = null;
            int? formLeft = null;
            int? formTop = null;

            try
            {
                formWidth = Convert.ToInt32(ApplicationWindow.Width);
                formHeight = Convert.ToInt32(ApplicationWindow.Height);
            }
            catch (OverflowException)
            {
                formWidth = null;
                formHeight = null;
            }
            try
            {
                formTop = Convert.ToInt32(ApplicationWindow.Top);
                formLeft = Convert.ToInt32(ApplicationWindow.Left);
            }
            catch (OverflowException)
            {
                formLeft = null;
                formTop = null;
            }

            var state = GetWindowsFormState(ApplicationWindow.WindowState);

            _hiddenWindowThread = new Thread(() => ShowHiddenWindow(formWidth, formHeight, formTop, formLeft, startPosition, state));
            _hiddenWindowThread.SetApartmentState(ApartmentState.STA);
            _hiddenWindowThread.IsBackground = true;
            _hiddenWindowThread.Start();
        }