@@ -161,8 +161,7 @@ private void UpdateHeader(SignalConversation thread)
161
161
public void Load ( SignalConversation conversation )
162
162
{
163
163
SignalConversation = conversation ;
164
- var contact = SignalConversation as SignalContact ;
165
- if ( contact != null )
164
+ if ( SignalConversation is SignalContact contact )
166
165
{
167
166
Blocked = contact . Blocked ;
168
167
SendMessageVisible = ! Blocked ;
@@ -206,9 +205,7 @@ public T FindElementByName<T>(FrameworkElement element, string sChildName) where
206
205
var nChildCount = VisualTreeHelper . GetChildrenCount ( element ) ;
207
206
for ( int i = 0 ; i < nChildCount ; i ++ )
208
207
{
209
- FrameworkElement child = VisualTreeHelper . GetChild ( element , i ) as FrameworkElement ;
210
-
211
- if ( child == null )
208
+ if ( ! ( VisualTreeHelper . GetChild ( element , i ) is FrameworkElement child ) )
212
209
continue ;
213
210
214
211
if ( child is T && child . Name . Equals ( sChildName ) )
@@ -351,8 +348,7 @@ private void ScrollToUnread()
351
348
352
349
private int GetBottommostIndex ( )
353
350
{
354
- var sourcePanel = ConversationItemsControl . ItemsPanelRoot as ItemsStackPanel ;
355
- if ( sourcePanel != null )
351
+ if ( ConversationItemsControl . ItemsPanelRoot is ItemsStackPanel sourcePanel )
356
352
{
357
353
return sourcePanel . LastVisibleIndex ;
358
354
}
@@ -392,9 +388,8 @@ private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEven
392
388
393
389
private async void UnblockButton_Click ( object sender , RoutedEventArgs e )
394
390
{
395
- if ( SignalConversation is SignalContact )
391
+ if ( SignalConversation is SignalContact contact )
396
392
{
397
- var contact = ( SignalContact ) SignalConversation ;
398
393
contact . Blocked = false ;
399
394
Blocked = false ;
400
395
SendMessageVisible = ! Blocked ;
@@ -416,9 +411,8 @@ public class MessageTemplateSelector : DataTemplateSelector
416
411
protected override DataTemplate SelectTemplateCore ( object item , DependencyObject container )
417
412
{
418
413
FrameworkElement element = container as FrameworkElement ;
419
- if ( item is SignalMessageContainer )
414
+ if ( item is SignalMessageContainer smc )
420
415
{
421
- SignalMessageContainer smc = ( SignalMessageContainer ) item ;
422
416
SignalMessage sm = smc . Message ;
423
417
if ( sm . Type == SignalMessageType . IdentityKeyChange )
424
418
{
0 commit comments