private void LoadViewModel() { if (_state == GoToWindowState.ShowingThenHide) { Log.Debug("Executing pending Hide (before loading windows)."); Hide(true); return; } Log.Debug("View Model loading..."); _mainWindow.BeginInit(); _mainViewModel.Load(PluginsContainer.Plugins); _mainWindow.DataReady(); _mainWindow.EndInit(); Log.Debug("View Model loaded."); if (_state == GoToWindowState.ShowingThenHide) { Log.Debug("Executing pending Hide (after loading windows)."); Hide(true); return; } _state = GoToWindowState.Shown; Application.Current.Dispatcher.InvokeAsync(EnsureWindowIsForeground, DispatcherPriority.Background); }
private void HideWindow() { _mainWindow.Hide(); Log.Debug("Main window hidden."); lock (_lock) { _state = GoToWindowState.Hidden; } }
public void Show() { lock (_lock) { if (_state == GoToWindowState.Shown) { Log.Debug("Sending Tab Again to Main Window."); _mainWindow.ShortcutAgain(); return; } if (_state != GoToWindowState.Hidden) { return; } Log.Debug("Showing Main Window."); _state = GoToWindowState.Showing; } if (Showing != null) { Showing(this, new EventArgs()); } SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight); _mainWindow.Left = SystemParameters.PrimaryScreenWidth / 2f - _mainViewModel.AvailableWindowWidth / 2f; _mainWindow.Top = SystemParameters.PrimaryScreenHeight / 2f - (_mainViewModel.AvailableWindowHeight + 56) / 2f; _mainWindow.Show(); if (_mainWindowEntry == null) { var interopHelper = new WindowInteropHelper(_mainWindow); _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle); Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd); } _mainWindow.SetFocus(); _mainWindowEntry.Focus(); Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background); }
public void Hide(bool hideIfPending) { lock (_lock) { if (_state == GoToWindowState.Showing) { Log.Debug("Cannot Hide because Show is still in progress. Pending Hide."); _state = GoToWindowState.ShowingThenHide; return; } if (!hideIfPending && _state == GoToWindowState.ShowingThenHide) { Log.Debug("Hide already pending."); return; } if (_state != GoToWindowState.Shown && _state != GoToWindowState.ShowingThenHide) { return; } Log.Debug("Hiding Main Window."); _state = GoToWindowState.Hiding; } try { _mainWindow.BeginInit(); _mainViewModel.Empty(); _mainWindow.EndInit(); _mainViewModel.IsEmpty = true; } catch (InvalidOperationException exc) { Log.Error("Failed hiding window.", exc); } Application.Current.Dispatcher.InvokeAsync(HideWindow, DispatcherPriority.ApplicationIdle); }
public void Show() { lock (_lock) { if (_state == GoToWindowState.Shown) { Log.Debug("Sending Tab Again to Main Window."); _mainWindow.ShortcutAgain(); return; } if (_state != GoToWindowState.Hidden) return; Log.Debug("Showing Main Window."); _state = GoToWindowState.Showing; } if (Showing != null) Showing(this, new EventArgs()); SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight); _mainWindow.Left = SystemParameters.PrimaryScreenWidth/2f - _mainViewModel.AvailableWindowWidth/2f; _mainWindow.Top = SystemParameters.PrimaryScreenHeight/2f - (_mainViewModel.AvailableWindowHeight + 56)/2f; _mainWindow.Show(); if (_mainWindowEntry == null) { var interopHelper = new WindowInteropHelper(_mainWindow); _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle); Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd); } _mainWindow.SetFocus(); _mainWindowEntry.Focus(); Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background); }
public void Hide(bool hideIfPending) { lock (_lock) { if (_state == GoToWindowState.Showing) { Log.Debug("Cannot Hide because Show is still in progress. Pending Hide."); _state = GoToWindowState.ShowingThenHide; return; } if (!hideIfPending && _state == GoToWindowState.ShowingThenHide) { Log.Debug("Hide already pending."); return; } if (_state != GoToWindowState.Shown && _state != GoToWindowState.ShowingThenHide) return; Log.Debug("Hiding Main Window."); _state = GoToWindowState.Hiding; } try { _mainWindow.BeginInit(); _mainViewModel.Empty(); _mainWindow.EndInit(); _mainViewModel.IsEmpty = true; } catch (InvalidOperationException exc) { Log.Error("Failed hiding window.", exc); } Application.Current.Dispatcher.InvokeAsync(HideWindow, DispatcherPriority.ApplicationIdle); }