diff --git a/WinAudioAssistant/App.xaml b/WinAudioAssistant/App.xaml index 5c2ff18..67820bf 100644 --- a/WinAudioAssistant/App.xaml +++ b/WinAudioAssistant/App.xaml @@ -1,8 +1,7 @@  + xmlns:local="clr-namespace:WinAudioAssistant"> diff --git a/WinAudioAssistant/App.xaml.cs b/WinAudioAssistant/App.xaml.cs index 33f957d..b48c476 100644 --- a/WinAudioAssistant/App.xaml.cs +++ b/WinAudioAssistant/App.xaml.cs @@ -3,6 +3,7 @@ using System.Windows; using WinAudioAssistant.Models; using AudioSwitcher.AudioApi.CoreAudio; +using WinAudioAssistant.Views; namespace WinAudioAssistant { @@ -29,9 +30,9 @@ protected override void OnStartup(StartupEventArgs e) base.OnStartup(e); UserSettings = UserSettings.LoadAtStartup(); - SystemEventsHandler.RegisterAllEvents(); AudioEndpointManager.UpdateCachedEndpoints(); + new TrayIconView(); } } diff --git a/WinAudioAssistant/Resources/Icons/Icon1.ico b/WinAudioAssistant/Resources/Icons/Icon1.ico new file mode 100644 index 0000000..7a5e760 Binary files /dev/null and b/WinAudioAssistant/Resources/Icons/Icon1.ico differ diff --git a/WinAudioAssistant/ViewModels/TrayIconViewModel.cs b/WinAudioAssistant/ViewModels/TrayIconViewModel.cs new file mode 100644 index 0000000..0d3ecfc --- /dev/null +++ b/WinAudioAssistant/ViewModels/TrayIconViewModel.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using WinAudioAssistant.Views; + +namespace WinAudioAssistant.ViewModels +{ + class TrayIconViewModel + { + + public ICommand DoubleClickCommand { get; } + public ICommand SettingsCommand { get; } + public ICommand ExitCommand { get; } + + public TrayIconViewModel() + { + DoubleClickCommand = new RelayCommand(Settings); + SettingsCommand = new RelayCommand(Settings); + ExitCommand = new RelayCommand(Exit); + } + + private void Settings(object? parameter) + { + foreach (var window in App.Current.Windows) + { + if (window is DevicePriorityView devicePriorityView) + { + devicePriorityView.Focus(); + return; + } + } + new DevicePriorityView().Show(); + } + + private void Exit(object? parameter) + { + App.Current.Shutdown(); + } + + } +} diff --git a/WinAudioAssistant/Views/TrayIconView.xaml b/WinAudioAssistant/Views/TrayIconView.xaml new file mode 100644 index 0000000..f6dafee --- /dev/null +++ b/WinAudioAssistant/Views/TrayIconView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/WinAudioAssistant/Views/TrayIconView.xaml.cs b/WinAudioAssistant/Views/TrayIconView.xaml.cs new file mode 100644 index 0000000..7ecb39f --- /dev/null +++ b/WinAudioAssistant/Views/TrayIconView.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace WinAudioAssistant.Views +{ + /// + /// Interaction logic for TrayIconView.xaml + /// + public partial class TrayIconView : Window + { + public TrayIconView() + { + InitializeComponent(); + } + } +} diff --git a/WinAudioAssistant/WinAudioAssistant.csproj b/WinAudioAssistant/WinAudioAssistant.csproj index e27232b..68b538c 100644 --- a/WinAudioAssistant/WinAudioAssistant.csproj +++ b/WinAudioAssistant/WinAudioAssistant.csproj @@ -9,11 +9,13 @@ + + @@ -43,6 +45,7 @@ +