Exemplo n.º 1
0
        private void OnStateChanged(object sender, object e)
        {
            switch (_viewModel.State)
            {
            case FlyoutViewState.Opening:
                var taskbar = WindowsTaskbar.Current;

                Show();
                EnableAcrylicIfApplicable(taskbar);
                PositionWindowRelativeToTaskbar(taskbar);

                WindowAnimationLibrary.BeginWindowEntranceAnimation(this, () =>
                {
                    _viewModel.ChangeState(FlyoutViewState.Open);
                });
                break;

            case FlyoutViewState.Closing_Stage1:
                WindowAnimationLibrary.BeginWindowExitAnimation(this, () =>
                {
                    this.Cloak();
                    AccentPolicyLibrary.DisableAcrylic(this);
                    _viewModel.ChangeState(FlyoutViewState.Hidden);
                });

                break;
            }
        }
Exemplo n.º 2
0
        public void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            switch (_state)
            {
            case WindowViewState.Open:
                _state   = WindowViewState.Closing;
                e.Cancel = true;

                Dialog.IsVisible = false;
                _mainViewModel.OnFullWindowClosed();

                var window = (Window)sender;
                WindowAnimationLibrary.BeginWindowExitAnimation(window, () =>
                {
                    _state = WindowViewState.CloseReady;
                    window.Close();
                });
                break;

            case WindowViewState.Closing:
                // Ignore any requests while playing the close animation.
                e.Cancel = true;
                break;

            case WindowViewState.CloseReady:
                // Accept the close.
                break;
            }
        }
Exemplo n.º 3
0
 private void OpenSettings()
 {
     if (_openSettingsWindow != null)
     {
         _openSettingsWindow.RaiseWindow();
     }
     else
     {
         var viewModel = new SettingsViewModel();
         viewModel.OpenAddonManager = new RelayCommand(() =>
         {
             var window = new DialogWindow {
                 Owner = _openSettingsWindow
             };
             var addonManagerViewModel = new AddonManagerViewModel(AddonManager.Current);
             window.DataContext        = addonManagerViewModel;
             window.ShowDialog();
         });
         _openSettingsWindow             = new SettingsWindow();
         _openSettingsWindow.DataContext = viewModel;
         _openSettingsWindow.Closing    += (_, __) => _openSettingsWindow = null;
         _openSettingsWindow.Show();
         WindowAnimationLibrary.BeginWindowEntranceAnimation(_openSettingsWindow, () => { });
     }
 }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     Trace.WriteLine("FullWindow CloseButton_Click");
     if (!_isClosing)
     {
         // Ensure we don't double-animate if the user is able to close us multiple ways before the window stops accepting input.
         _isClosing = true;
         WindowAnimationLibrary.BeginWindowExitAnimation(this, () => this.Close());
     }
 }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        public void SafeClose()
        {
            Trace.WriteLine("SettingsWindow SafeClose");

            if (!_isClosing)
            {
                // Ensure we don't double-animate if the user is able to close us multiple ways before the window stops accepting input.
                _isClosing = true;
                WindowAnimationLibrary.BeginWindowExitAnimation(this, () => this.Close());
            }
        }
Exemplo n.º 8
0
 public static void ActivateSingleInstance()
 {
     if (Instance == null)
     {
         var window = new SettingsWindow();
         window.Show();
         WindowAnimationLibrary.BeginWindowEntranceAnimation(window, () => { });
     }
     else
     {
         Instance.RaiseWindow();
     }
 }
Exemplo n.º 9
0
        public static void ActivateSingleInstance(MainViewModel mainViewModel)
        {
            Trace.WriteLine("FullWindow ActivateSingleInstance");
            if (Instance == null)
            {
                var window = new FullWindow(mainViewModel);

                window.Show();
                WindowAnimationLibrary.BeginWindowEntranceAnimation(window, () => { });
            }
            else
            {
                Instance.RaiseWindow();
            }
        }
Exemplo n.º 10
0
        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;
            }
        }
Exemplo n.º 11
0
 private void OpenMixer()
 {
     if (_openMixerWindow != null)
     {
         _openMixerWindow.RaiseWindow();
     }
     else
     {
         var viewModel = new FullWindowViewModel(PlaybackDevicesViewModel);
         _openMixerWindow             = new FullWindow();
         _openMixerWindow.DataContext = viewModel;
         _openMixerWindow.Closing    += (_, __) =>
         {
             _openMixerWindow = null;
             viewModel.Close();
         };
         _openMixerWindow.Show();
         WindowAnimationLibrary.BeginWindowEntranceAnimation(_openMixerWindow, () => { });
     }
 }
Exemplo n.º 12
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     WindowAnimationLibrary.BeginWindowExitAnimation(this, () => this.Close());
 }