private void OnStateChanged(object sender, object e) { switch (_viewModel.State) { case FlyoutViewState.Opening: var taskbar = WindowsTaskbar.Current; Show(); PositionWindowRelativeToTaskbar(taskbar); // Focus the first device if available. DevicesList.FindVisualChild <DeviceView>()?.FocusAndRemoveFocusVisual(); // Prevent showing stale adnorners. this.WaitForKeyboardVisuals(() => { LayoutRoot.Background = new SolidColorBrush(Themes.Manager.Current.ResolveRef(this, "AcrylicColor_Flyout")); WindowAnimationLibrary.BeginFlyoutEntranceAnimation(this, taskbar, () => { _viewModel.ChangeState(FlyoutViewState.Open); // Wait to apply acrylic, or the translate transform illusion will be spoiled. EnableAcrylicIfApplicable(taskbar); }); }); break; case FlyoutViewState.Closing_Stage1: DevicesList.FindVisualChild <DeviceView>()?.FocusAndRemoveFocusVisual(); if (_viewModel.IsExpandingOrCollapsing) { AccentPolicyLibrary.DisableAcrylic(this); WindowAnimationLibrary.BeginFlyoutExitanimation(this, () => { this.Cloak(); // Go directly to ViewState.Hidden to avoid the stage 2 hide delay (debounce for tray clicks), // we want to show again immediately. _viewModel.ChangeState(FlyoutViewState.Hidden); }); } else { // No animation for normal exit. this.Cloak(); AccentPolicyLibrary.DisableAcrylic(this); // Prevent de-queueing partially on show and showing stale adnorners. this.WaitForKeyboardVisuals(() => { Hide(); _viewModel.ChangeState(FlyoutViewState.Closing_Stage2); }); } break; } }
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; } }
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; } }