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); }
private void DoAppStartup() { ((Manager)Resources["ThemeManager"]).Load(); _mixerWindow = new WindowHolder(CreateMixerExperience); _settingsWindow = new WindowHolder(CreateSettingsExperience); PlaybackDevicesViewModel = new DeviceCollectionViewModel(WindowsAudioFactory.Create(AudioDeviceKind.Playback)); PlaybackDevicesViewModel.Ready += OnMainViewModelReady; FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel); FlyoutWindow = new FlyoutWindow(FlyoutViewModel); TrayViewModel = new TrayViewModel(PlaybackDevicesViewModel); TrayViewModel.LeftClick = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer)); TrayViewModel.OpenMixer = new RelayCommand(_mixerWindow.OpenOrBringToFront); TrayViewModel.OpenSettings = new RelayCommand(_settingsWindow.OpenOrBringToFront); FlyoutWindow.DpiChanged += (_, __) => TrayViewModel.Refresh(); _trayIcon = new TrayIcon(TrayViewModel); SettingsService.RegisterHotkeys(); HotkeyManager.Current.KeyPressed += OnHotKeyPressed; MaybeShowFirstRunExperience(); }
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 OnItemSelected(FlyoutMenuViewModel sender, FlyoutViewModel x) { if (x != null) { Detail = new NavigationPage(new MenuHorizontal(x.LabelTitle)); MessagingCenter.Unsubscribe <MainPage>(this, "ChangeDetail"); IsPresented = false; } }
private void OnHotKeyPressed(HotkeyData hotkey) { if (hotkey.Equals(SettingsService.FlyoutHotkey)) { FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Keyboard); } else if (hotkey.Equals(SettingsService.SettingsHotkey)) { _settingsWindow.OpenOrBringToFront(); } else if (hotkey.Equals(SettingsService.MixerHotkey)) { _mixerWindow.OpenOrClose(); } }
public AudioListViewModel(VkApi vkApi, FlyoutViewModel flyout) { _vkApi = vkApi; _flyout = flyout; Title = "Мои аудиозаписи"; LoadAudio(); PauseAudioButtonClick = new RelayCommand(PauseAudio); StopAudioButtonClick = new RelayCommand(StopAudio); SaveAudioButtonClick = new RelayCommand(SaveAudio); CheckAllAudioButtonClick = new RelayCommand(CheckAll); UnCheckAllAudioButtonClick = new RelayCommand(UnCheckAll); SaveCheckedAudioButtonClick = new RelayCommand(SaveCheckedAudio); _audioPlayer.OnEndAudio += NextAudioPlay; _audioPlayer.OnAudioPositionChanged += (sender, args) => RaisePropertyChanged("AudioPosition"); }
private void ContinueStartup() { ((UI.Themes.Manager)Resources["ThemeManager"]).Load(); _settings = new AppSettings(); _settings.FlyoutHotkeyTyped += () => FlyoutViewModel.OpenFlyout(InputType.Keyboard); _settings.MixerHotkeyTyped += () => _mixerWindow.OpenOrClose(); _settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront(); _mixerWindow = new WindowHolder(CreateMixerExperience); _settingsWindow = new WindowHolder(CreateSettingsExperience); PlaybackDevicesViewModel = new DeviceCollectionViewModel(DataModel.WindowsAudio.WindowsAudioFactory.Create(DataModel.WindowsAudio.AudioDeviceKind.Playback), _settings); PlaybackDevicesViewModel.Ready += (_, __) => CompleteStartup(); PlaybackDevicesViewModel.TrayPropertyChanged += () => UpdateTrayTooltipAndIcon(); FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel, () => _trayIcon.SetFocus()); FlyoutWindow = new FlyoutWindow(FlyoutViewModel); CreateTrayExperience(); }
private void ContinueStartup() { ((UI.Themes.Manager)Resources["ThemeManager"]).Load(); var deviceManager = WindowsAudioFactory.Create(AudioDeviceKind.Playback); deviceManager.Loaded += (_, __) => CompleteStartup(); CollectionViewModel = new DeviceCollectionViewModel(deviceManager, _settings); _trayIcon = new ShellNotifyIcon(new TaskbarIconSource(CollectionViewModel, _settings)); Exit += (_, __) => _trayIcon.IsVisible = false; CollectionViewModel.TrayPropertyChanged += () => _trayIcon.SetTooltip(CollectionViewModel.GetTrayToolTip()); _flyoutViewModel = new FlyoutViewModel(CollectionViewModel, () => _trayIcon.SetFocus()); FlyoutWindow = new FlyoutWindow(_flyoutViewModel); // Initialize the FlyoutWindow last because its Show/Hide cycle will pump messages, causing UI frames // to be executed, breaking the assumption that startup is complete. FlyoutWindow.Initialize(); }
private void Application_Startup(object sender, StartupEventArgs e) { ErrorReportingService.Initialize(); Trace.WriteLine("App Application_Startup"); if (!SingleInstanceAppMutex.TakeExclusivity()) { Trace.WriteLine("App Application_Startup TakeExclusivity failed"); Current.Shutdown(); return; } ((ThemeManager)Resources["ThemeManager"]).SetTheme(ThemeData.GetBrushData()); PlaybackDevicesViewModel = new DeviceCollectionViewModel(DataModelFactory.CreateAudioDeviceManager(AudioDeviceKind.Playback)); PlaybackDevicesViewModel.Ready += MainViewModel_Ready; FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel); FlyoutWindow = new FlyoutWindow(FlyoutViewModel); TrayViewModel = new TrayViewModel(PlaybackDevicesViewModel); TrayViewModel.LeftClick = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer)); TrayViewModel.OpenMixer = new RelayCommand(OpenMixer); TrayViewModel.OpenSettings = new RelayCommand(OpenSettings); _trayIcon = new TrayIcon(TrayViewModel); FlyoutWindow.DpiChanged += (_, __) => TrayViewModel.DpiChanged(); HotkeyManager.Current.Register(SettingsService.Hotkey); HotkeyManager.Current.KeyPressed += (hotkey) => { if (hotkey.Equals(SettingsService.Hotkey)) { FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Keyboard); } }; StartupUWPDialogDisplayService.ShowIfAppropriate(); Trace.WriteLine($"App Application_Startup Exit"); }
private void CreateTrayExperience() { if (!SndVolSSO.SystemIconsAreAvailable()) { _settings.UseLegacyIcon = true; } TaskbarIconSource iconSource = null; iconSource = new TaskbarIconSource(icon => { if (_settings.UseLegacyIcon) { icon?.Dispose(); icon = IconHelper.LoadIconForTaskbar(SystemSettings.IsSystemLightTheme ? $"{AssetBaseUri}Application.ico" : $"{AssetBaseUri}Tray.ico"); } double iconFillPercent = ((SndVolSSO.IconId)iconSource.Tag) == SndVolSSO.IconId.NoDevice && !_settings.UseLegacyIcon ? 0.4 : 1; if (SystemParameters.HighContrast) { icon = IconHelper.ColorIcon(icon, iconFillPercent, _trayIcon.IsMouseOver ? SystemColors.HighlightTextColor : SystemColors.WindowTextColor); } else if (SystemSettings.IsSystemLightTheme && !_settings.UseLegacyIcon) { icon = IconHelper.ColorIcon(icon, iconFillPercent, System.Windows.Media.Colors.Black); } return(icon); }, () => $"hc={SystemParameters.HighContrast} {(SystemParameters.HighContrast ? $"mouse={_trayIcon.IsMouseOver}" : "")} dpi={WindowsTaskbar.Dpi} theme={SystemSettings.IsSystemLightTheme} legacy={_settings.UseLegacyIcon}"); _settings.UseLegacyIconChanged += (_, __) => iconSource.CheckForUpdate(); _trayIcon = new ShellNotifyIcon(iconSource, () => _settings.TrayIconIdentity, _settings.ResetTrayIconIdentity); _trayIcon.PrimaryInvoke += (_, type) => FlyoutViewModel.OpenFlyout(type); _trayIcon.SecondaryInvoke += (_, __) => _trayIcon.ShowContextMenu(GetTrayContextMenuItems()); _trayIcon.TertiaryInvoke += (_, __) => PlaybackDevicesViewModel.Default?.ToggleMute.Execute(null); _trayIcon.Scrolled += (_, wheelDelta) => PlaybackDevicesViewModel.Default?.IncrementVolume(Math.Sign(wheelDelta) * 2); Exit += (_, __) => _trayIcon.IsVisible = false; UpdateTrayTooltipAndIcon(); }
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); }
public void OnAddonEvent(AddonEventKind evt) { if (evt == AddonEventKind.InitializeAddon) { Current = this; DeviceCollection = ((App)App.Current).CollectionViewModel; m_hardwareManager = new HardwareManager(DeviceCollection, WindowsAudioFactory.Create(AudioDeviceKind.Playback)); // Monitor the EarTrumpet flyout so we don't show when the flyout is showing. _flyoutViewModel = (FlyoutViewModel)((App)Application.Current).FlyoutWindow.DataContext; _flyoutViewModel.StateChanged += OnFlyoutViewModelStateChanged; // Create a window to use as OSD. _osdWindowViewModel = new OSDWindowViewModel(); _osdWindow = new OSDWindow(_osdWindowViewModel); _osdWindow.Initialize(); // Listen to events and then present the active ViewModel to the OSD window. PlaybackDataModelHost.Current.AppPropertyChanged += OnAppPropertyChanged; PlaybackDataModelHost.Current.DevicePropertyChanged += OnDevicePropertyChanged; } }
protected void ShowFlyout(FlyoutViewModel model) { Flyout = model; }
public AudioItemViewModel(VkApi vkApi, FlyoutViewModel flyout) { _vkApi = vkApi; _flyout = flyout; SaveAudioButtonClick = new RelayCommand(SaveAudio); }
public flyoutControl() { InitializeComponent(); Model = new FlyoutViewModel(); DataContext = Model; }