File tree Expand file tree Collapse file tree 7 files changed +103
-3
lines changed Expand file tree Collapse file tree 7 files changed +103
-3
lines changed Original file line number Diff line number Diff line change 11<Application x : Class =" WinAudioAssistant.App"
22 xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33 xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4- xmlns : local =" clr-namespace:WinAudioAssistant"
5- StartupUri =" Views\DevicePriorityView.xaml" >
4+ xmlns : local =" clr-namespace:WinAudioAssistant" >
65 <Application .Resources>
76
87 </Application .Resources>
Original file line number Diff line number Diff line change 33using System . Windows ;
44using WinAudioAssistant . Models ;
55using AudioSwitcher . AudioApi . CoreAudio ;
6+ using WinAudioAssistant . Views ;
67
78namespace WinAudioAssistant
89{
@@ -29,9 +30,9 @@ protected override void OnStartup(StartupEventArgs e)
2930 base . OnStartup ( e ) ;
3031
3132 UserSettings = UserSettings . LoadAtStartup ( ) ;
32-
3333 SystemEventsHandler . RegisterAllEvents ( ) ;
3434 AudioEndpointManager . UpdateCachedEndpoints ( ) ;
35+ new TrayIconView ( ) ;
3536 }
3637 }
3738
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+ using System . Windows . Input ;
7+ using WinAudioAssistant . Views ;
8+
9+ namespace WinAudioAssistant . ViewModels
10+ {
11+ class TrayIconViewModel
12+ {
13+
14+ public ICommand DoubleClickCommand { get ; }
15+ public ICommand SettingsCommand { get ; }
16+ public ICommand ExitCommand { get ; }
17+
18+ public TrayIconViewModel ( )
19+ {
20+ DoubleClickCommand = new RelayCommand ( Settings ) ;
21+ SettingsCommand = new RelayCommand ( Settings ) ;
22+ ExitCommand = new RelayCommand ( Exit ) ;
23+ }
24+
25+ private void Settings ( object ? parameter )
26+ {
27+ foreach ( var window in App . Current . Windows )
28+ {
29+ if ( window is DevicePriorityView devicePriorityView )
30+ {
31+ devicePriorityView . Focus ( ) ;
32+ return ;
33+ }
34+ }
35+ new DevicePriorityView ( ) . Show ( ) ;
36+ }
37+
38+ private void Exit ( object ? parameter )
39+ {
40+ App . Current . Shutdown ( ) ;
41+ }
42+
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ <Window x : Class =" WinAudioAssistant.Views.TrayIconView"
2+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
5+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
6+ xmlns : tb =" http://www.hardcodet.net/taskbar"
7+ xmlns : local =" clr-namespace:WinAudioAssistant.Views"
8+ xmlns : viewmodels =" clr-namespace:WinAudioAssistant.ViewModels"
9+ mc : Ignorable =" d"
10+ d : DesignHeight =" 450" d : DesignWidth =" 800"
11+ Title =" TrayIcon" >
12+ <Window .DataContext>
13+ <viewmodels : TrayIconViewModel />
14+ </Window .DataContext>
15+ <Grid >
16+ <tb : TaskbarIcon IconSource =" /Resources/Icons/Icon1.ico" ToolTipText =" WinAudioAssistant"
17+ DoubleClickCommand =" {Binding DoubleClickCommand}" >
18+ <tb : TaskbarIcon .ContextMenu>
19+ <ContextMenu >
20+ <MenuItem Header =" Settings" Command =" {Binding SettingsCommand}" />
21+ <MenuItem Header =" Exit" Command =" {Binding ExitCommand}" />
22+ </ContextMenu >
23+ </tb : TaskbarIcon .ContextMenu>
24+ </tb : TaskbarIcon >
25+ </Grid >
26+ </Window >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+ using System . Windows ;
7+ using System . Windows . Controls ;
8+ using System . Windows . Data ;
9+ using System . Windows . Documents ;
10+ using System . Windows . Input ;
11+ using System . Windows . Media ;
12+ using System . Windows . Media . Imaging ;
13+ using System . Windows . Shapes ;
14+
15+ namespace WinAudioAssistant . Views
16+ {
17+ /// <summary>
18+ /// Interaction logic for TrayIconView.xaml
19+ /// </summary>
20+ public partial class TrayIconView : Window
21+ {
22+ public TrayIconView ( )
23+ {
24+ InitializeComponent ( ) ;
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 99 </PropertyGroup >
1010
1111 <ItemGroup >
12+ <None Remove =" Resources\Icons\Icon1.ico" />
1213 <None Remove =" Resources\Icons\MissingFile.ico" />
1314 </ItemGroup >
1415
1516 <ItemGroup >
1617 <PackageReference Include =" gong-wpf-dragdrop" Version =" 3.2.1" />
18+ <PackageReference Include =" Hardcodet.NotifyIcon.Wpf" Version =" 1.1.0" />
1719 <PackageReference Include =" Newtonsoft.Json" Version =" 13.0.3" />
1820 <PackageReference Include =" System.Reactive" Version =" 6.0.0" />
1921 </ItemGroup >
4345 </ItemGroup >
4446
4547 <ItemGroup >
48+ <Resource Include =" Resources\Icons\Icon1.ico" />
4649 <Resource Include =" Resources\Icons\MissingFile.ico" />
4750 </ItemGroup >
4851</Project >
You can’t perform that action at this time.
0 commit comments