private void ViewModel_OnStateChanged(object sender, object e) { switch (_viewModel.State) { case FlyoutViewModel.ViewState.Opening: if (_viewModel.ShowOptions == FlyoutShowOptions.Pointer) { _rawListener.Start(); } Show(); // We need the theme to be updated on show because the window borders will be set based on taskbar position. ThemeChanged(); UpdateWindowBounds(); // Update layout otherwise we may display queued state changes UpdateLayout(); DevicesList.Focus(); WindowAnimationLibrary.BeginFlyoutEntranceAnimation(this, () => _viewModel.ChangeState(FlyoutViewModel.ViewState.Open)); break; case FlyoutViewModel.ViewState.Closing_Stage1: _rawListener.Stop(); if (_needsExpandOrCollapse) { WindowAnimationLibrary.BeginFlyoutExitanimation(this, () => { this.Cloak(); Hide(); // NB: Hidden to avoid the stage 2 hide delay, we want to show again immediately. _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }); } else { this.Cloak(); Hide(); DisableAcrylic(); _viewModel.ChangeState(FlyoutViewModel.ViewState.Closing_Stage2); } break; case FlyoutViewModel.ViewState.Hidden: if (_needsExpandOrCollapse) { _needsExpandOrCollapse = false; _viewModel.DoExpandCollapse(); _viewModel.BeginOpen(); } break; } }
public FlyoutWindow(FlyoutViewModel flyoutViewModel) { InitializeComponent(); _viewModel = flyoutViewModel; _viewModel.StateChanged += ViewModel_OnStateChanged; _viewModel.WindowSizeInvalidated += ViewModel_WindowSizeInvalidated; _viewModel.ExpandCollapse = new RelayCommand(() => { _needsExpandOrCollapse = true; _viewModel.BeginClose(); }); DataContext = _viewModel; Deactivated += FlyoutWindow_Deactivated; SourceInitialized += FlyoutWindow_SourceInitialized; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; Closing += FlyoutWindow_Closing; this.FlowDirection = SystemSettings.IsRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; // Ensure the Win32 and WPF windows are created to fix first show issues with DPI Scaling Show(); Hide(); this.ApplyExtendedWindowStyle(User32.WS_EX_TOOLWINDOW); _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }
internal FlyoutWindow(MainViewModel mainViewModel, FlyoutViewModel flyoutViewModel) { InitializeComponent(); _mainViewModel = mainViewModel; _viewModel = flyoutViewModel; _viewModel.StateChanged += ViewModel_OnStateChanged; _viewModel.WindowSizeInvalidated += ViewModel_WindowSizeInvalidated; _viewModel.AppExpanded += ViewModel_AppExpanded; _viewModel.AppCollapsed += ViewModel_AppCollapsed; DataContext = _viewModel; AppPopup.Closed += AppPopup_Closed; Deactivated += FlyoutWindow_Deactivated; SourceInitialized += FlyoutWindow_SourceInitialized; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; Closing += FlyoutWindow_Closing; this.FlowDirection = SystemSettings.IsRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; // Ensure the Win32 and WPF windows are created to fix first show issues with DPI Scaling Show(); Hide(); _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }
public FlyoutWindow(FlyoutViewModel flyoutViewModel) { InitializeComponent(); _viewModel = flyoutViewModel; _viewModel.StateChanged += ViewModel_OnStateChanged; _viewModel.WindowSizeInvalidated += ViewModel_WindowSizeInvalidated; _viewModel.ExpandCollapse = new RelayCommand(() => { _needsExpandOrCollapse = true; _viewModel.BeginClose(); }); DataContext = _viewModel; if (Features.IsEnabled(Feature.DevicePopup)) { Application.Current.Deactivated += FlyoutWindow_Deactivated; } else { Deactivated += FlyoutWindow_Deactivated; } SourceInitialized += FlyoutWindow_SourceInitialized; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; Closing += FlyoutWindow_Closing; this.FlowDirection = SystemSettings.IsRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; // Ensure the Win32 and WPF windows are created to fix first show issues with DPI Scaling Show(); Hide(); _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }
private void OnStateChanged(object sender, object e) { switch (_viewModel.State) { case FlyoutViewModel.ViewState.Opening: Show(); ThemeChanged(); UpdateWindowBounds(); // Focus the first device if available. DevicesList.FindVisualChild <DeviceView>()?.FocusAndRemoveFocusVisual(); WaitForKeyboardVisuals(() => { WindowAnimationLibrary.BeginFlyoutEntranceAnimation(this, () => _viewModel.ChangeState(FlyoutViewModel.ViewState.Open)); }); break; case FlyoutViewModel.ViewState.Closing_Stage1: DevicesList.FindVisualChild <DeviceView>()?.FocusAndRemoveFocusVisual(); if (_viewModel.IsExpandingOrCollapsing) { WindowAnimationLibrary.BeginFlyoutExitanimation(this, () => { this.Cloak(); // NB: Hidden to avoid the stage 2 hide delay, we want to show again immediately. _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }); } else { this.Cloak(); DisableAcrylic(); WaitForKeyboardVisuals(() => { Hide(); _viewModel.ChangeState(FlyoutViewModel.ViewState.Closing_Stage2); }); } break; } }
public FlyoutWindow(FlyoutViewModel flyoutViewModel) { InitializeComponent(); _viewModel = flyoutViewModel; _viewModel.StateChanged += OnStateChanged; _viewModel.WindowSizeInvalidated += OnWindowSizeInvalidated; DataContext = _viewModel; Deactivated += OnDeactivated; SourceInitialized += OnSourceInitialized; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += OnDisplaySettingsChanged; Closing += OnClosing; FlowDirection = SystemSettings.IsRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; // Ensure the Win32 and WPF windows are created to fix first show issues with DPI Scaling Show(); Hide(); this.ApplyExtendedWindowStyle(User32.WS_EX_TOOLWINDOW); _viewModel.ChangeState(FlyoutViewModel.ViewState.Hidden); }