@@ -21,13 +21,12 @@ public OverviewMatches()
2121 /// </summary>
2222 private void Profile_Click ( object sender , RoutedEventArgs e )
2323 {
24- Profile profile = ( ( Button ) sender ) . DataContext as Profile ;
25- if ( ! FocusOpenedWindow < ProfileWindow > ( profile ) )
24+ if ( ( ( Button ) sender ) . DataContext is Profile profile && ! FocusOpenedWindow < ProfileWindow > ( profile ) )
2625 {
2726 ProfileWindow profileWindow = new ProfileWindow ( ) ;
2827 profileWindow . ProfileWindowFrame . Content = new ProfilePage ( new ProfilePageViewModel ( profile ) ) ;
2928
30- profileWindow . Show ( ) ; // Show the authentication window
29+ profileWindow . Show ( ) ;
3130 }
3231 }
3332
@@ -39,13 +38,12 @@ private void MatchingProfile_Click(object sender, RoutedEventArgs e)
3938 ProfileWindow profileWindow = new ProfileWindow ( ) ;
4039 profileWindow . ProfileWindowFrame . Content = new MatchingProfilePage ( new MatchingProfilePageViewModel ( ( ( Button ) sender ) . DataContext as Profile ) ) ;
4140
42- profileWindow . Show ( ) ; // Show the authentication window
41+ profileWindow . Show ( ) ;
4342 }
4443
4544 private void Chat_Click ( object sender , RoutedEventArgs e )
4645 {
47- Profile profile = ( ( Button ) sender ) . DataContext as Profile ;
48- if ( ! FocusOpenedWindow < ChatWindow > ( profile ) )
46+ if ( ( ( Button ) sender ) . DataContext is Profile profile && ! FocusOpenedWindow < ChatWindow > ( profile ) )
4947 {
5048 ChatWindow chatWindow = new ChatWindow
5149 {
@@ -72,10 +70,10 @@ public static void Chat_Base(ChatWindow chatWindow)
7270 public static bool FocusOpenedWindow < T > ( int userID ) where T : Window
7371 {
7472 bool success = false ;
75- System . Windows . Application . Current . Dispatcher . Invoke ( delegate // Dispatcher delegate for threads
73+ Application . Current . Dispatcher . Invoke ( delegate // Dispatcher delegate for threads
7674 {
7775 // Check if a window is already open for the user, and if so, focus it instead of opening a new window
78- foreach ( T t in System . Windows . Application . Current . Windows . OfType < T > ( ) )
76+ foreach ( T t in Application . Current . Windows . OfType < T > ( ) )
7977 {
8078 if ( typeof ( T ) == typeof ( ChatWindow ) )
8179 {
0 commit comments