@@ -266,9 +266,9 @@ private void LoadSettings()
266
266
267
267
#region ICommands & Actions
268
268
269
- public ICommand ScanCommand => new RelayCommand ( p => ScanAction ( ) , Scan_CanExecute ) ;
269
+ public ICommand ScanCommand => new RelayCommand ( _ => ScanAction ( ) , Scan_CanExecute ) ;
270
270
271
- private bool Scan_CanExecute ( object paramter )
271
+ private bool Scan_CanExecute ( object parameter )
272
272
{
273
273
return Application . Current . MainWindow != null && ! ( ( MetroWindow ) Application . Current . MainWindow ) . IsAnyDialogOpen ;
274
274
}
@@ -278,7 +278,7 @@ private void ScanAction()
278
278
Scan ( ) ;
279
279
}
280
280
281
- public ICommand DetectSubnetCommand => new RelayCommand ( p => DetectSubnetAction ( ) ) ;
281
+ public ICommand DetectSubnetCommand => new RelayCommand ( _ => DetectSubnetAction ( ) ) ;
282
282
283
283
private void DetectSubnetAction ( )
284
284
{
@@ -299,14 +299,14 @@ private void RedirectDataToApplicationAction(object name)
299
299
EventSystem . RedirectToApplication ( applicationName , host ) ;
300
300
}
301
301
302
- public ICommand PerformDNSLookupIPAddressCommand => new RelayCommand ( p => PerformDNSLookupIPAddressAction ( ) ) ;
302
+ public ICommand PerformDNSLookupIPAddressCommand => new RelayCommand ( _ => PerformDNSLookupIPAddressAction ( ) ) ;
303
303
304
304
private void PerformDNSLookupIPAddressAction ( )
305
305
{
306
306
EventSystem . RedirectToApplication ( ApplicationName . DNSLookup , SelectedResult . PingInfo . IPAddress . ToString ( ) ) ;
307
307
}
308
308
309
- public ICommand PerformDNSLookupHostnameCommand => new RelayCommand ( p => PerformDNSLookupHostnameAction ( ) ) ;
309
+ public ICommand PerformDNSLookupHostnameCommand => new RelayCommand ( _ => PerformDNSLookupHostnameAction ( ) ) ;
310
310
311
311
private void PerformDNSLookupHostnameAction ( )
312
312
{
@@ -320,7 +320,7 @@ private void CustomCommandAction(object guid)
320
320
CustomCommand ( guid ) ;
321
321
}
322
322
323
- public ICommand AddProfileSelectedHostCommand => new RelayCommand ( p => AddProfileSelectedHostAction ( ) ) ;
323
+ public ICommand AddProfileSelectedHostCommand => new RelayCommand ( _ => AddProfileSelectedHostAction ( ) ) ;
324
324
325
325
private async void AddProfileSelectedHostAction ( )
326
326
{
@@ -336,56 +336,56 @@ private async void AddProfileSelectedHostAction()
336
336
await ProfileDialogManager . ShowAddProfileDialog ( this , _dialogCoordinator , profileInfo ) ;
337
337
}
338
338
339
- public ICommand CopySelectedStatusCommand => new RelayCommand ( p => CopySelectedStatusAction ( ) ) ;
339
+ public ICommand CopySelectedStatusCommand => new RelayCommand ( _ => CopySelectedStatusAction ( ) ) ;
340
340
341
341
private void CopySelectedStatusAction ( )
342
342
{
343
343
ClipboardHelper . SetClipboard ( SelectedResult . IsReachable . ToString ( ) ) ;
344
344
}
345
345
346
- public ICommand CopySelectedIPAddressCommand => new RelayCommand ( p => CopySelectedIPAddressAction ( ) ) ;
346
+ public ICommand CopySelectedIPAddressCommand => new RelayCommand ( _ => CopySelectedIPAddressAction ( ) ) ;
347
347
348
348
private void CopySelectedIPAddressAction ( )
349
349
{
350
350
ClipboardHelper . SetClipboard ( SelectedResult . PingInfo . IPAddress . ToString ( ) ) ;
351
351
}
352
352
353
- public ICommand CopySelectedHostnameCommand => new RelayCommand ( p => CopySelectedHostnameAction ( ) ) ;
353
+ public ICommand CopySelectedHostnameCommand => new RelayCommand ( _ => CopySelectedHostnameAction ( ) ) ;
354
354
355
355
private void CopySelectedHostnameAction ( )
356
356
{
357
357
ClipboardHelper . SetClipboard ( SelectedResult . Hostname ) ;
358
358
}
359
359
360
- public ICommand CopySelectedPortStatusCommand => new RelayCommand ( p => CopySelectedPortStatusAction ( ) ) ;
360
+ public ICommand CopySelectedPortStatusCommand => new RelayCommand ( _ => CopySelectedPortStatusAction ( ) ) ;
361
361
362
362
private void CopySelectedPortStatusAction ( )
363
363
{
364
364
ClipboardHelper . SetClipboard ( ResourceTranslator . Translate ( ResourceIdentifier . PortState , SelectedResult . IsAnyPortOpen ? PortState . Open : PortState . Closed ) ) ;
365
365
}
366
366
367
- public ICommand CopySelectedPingStatusCommand => new RelayCommand ( p => CopySelectedPingStatusAction ( ) ) ;
367
+ public ICommand CopySelectedPingStatusCommand => new RelayCommand ( _ => CopySelectedPingStatusAction ( ) ) ;
368
368
369
369
private void CopySelectedPingStatusAction ( )
370
370
{
371
371
ClipboardHelper . SetClipboard ( ResourceTranslator . Translate ( ResourceIdentifier . PortState , SelectedResult . PingInfo . Status ) ) ;
372
372
}
373
373
374
- public ICommand CopySelectedMACAddressCommand => new RelayCommand ( p => CopySelectedMACAddressAction ( ) ) ;
374
+ public ICommand CopySelectedMACAddressCommand => new RelayCommand ( _ => CopySelectedMACAddressAction ( ) ) ;
375
375
376
376
private void CopySelectedMACAddressAction ( )
377
377
{
378
378
ClipboardHelper . SetClipboard ( MACAddressHelper . GetDefaultFormat ( SelectedResult . MACAddress . ToString ( ) ) ) ;
379
379
}
380
380
381
- public ICommand CopySelectedVendorCommand => new RelayCommand ( p => CopySelectedVendorAction ( ) ) ;
381
+ public ICommand CopySelectedVendorCommand => new RelayCommand ( _ => CopySelectedVendorAction ( ) ) ;
382
382
383
383
private void CopySelectedVendorAction ( )
384
384
{
385
385
ClipboardHelper . SetClipboard ( SelectedResult . Vendor ) ;
386
386
}
387
387
388
- public ICommand CopySelectedPortsCommand => new RelayCommand ( p => CopySelectedPortsAction ( ) ) ;
388
+ public ICommand CopySelectedPortsCommand => new RelayCommand ( _ => CopySelectedPortsAction ( ) ) ;
389
389
390
390
private void CopySelectedPortsAction ( )
391
391
{
@@ -399,28 +399,28 @@ private void CopySelectedPortsAction()
399
399
ClipboardHelper . SetClipboard ( stringBuilder . ToString ( ) ) ;
400
400
}
401
401
402
- public ICommand CopySelectedBytesCommand => new RelayCommand ( p => CopySelectedBytesAction ( ) ) ;
402
+ public ICommand CopySelectedBytesCommand => new RelayCommand ( _ => CopySelectedBytesAction ( ) ) ;
403
403
404
404
private void CopySelectedBytesAction ( )
405
405
{
406
406
ClipboardHelper . SetClipboard ( SelectedResult . PingInfo . Bytes . ToString ( ) ) ;
407
407
}
408
408
409
- public ICommand CopySelectedTimeCommand => new RelayCommand ( p => CopySelectedTimeAction ( ) ) ;
409
+ public ICommand CopySelectedTimeCommand => new RelayCommand ( _ => CopySelectedTimeAction ( ) ) ;
410
410
411
411
private void CopySelectedTimeAction ( )
412
412
{
413
413
ClipboardHelper . SetClipboard ( SelectedResult . PingInfo . Time . ToString ( ) ) ;
414
414
}
415
415
416
- public ICommand CopySelectedTTLCommand => new RelayCommand ( p => CopySelectedTTLAction ( ) ) ;
416
+ public ICommand CopySelectedTTLCommand => new RelayCommand ( _ => CopySelectedTTLAction ( ) ) ;
417
417
418
418
private void CopySelectedTTLAction ( )
419
419
{
420
420
ClipboardHelper . SetClipboard ( SelectedResult . PingInfo . TTL . ToString ( ) ) ;
421
421
}
422
422
423
- public ICommand ExportCommand => new RelayCommand ( p => ExportAction ( ) ) ;
423
+ public ICommand ExportCommand => new RelayCommand ( _ => ExportAction ( ) ) ;
424
424
425
425
private void ExportAction ( )
426
426
{
@@ -539,19 +539,16 @@ private async Task DetectIPRange()
539
539
var subnetmaskDetected = false ;
540
540
541
541
// Get subnetmask, based on ip address
542
- foreach ( var networkInterface in await NetworkInterface . GetNetworkInterfacesAsync ( ) )
542
+ foreach ( var networkInterface in ( await NetworkInterface . GetNetworkInterfacesAsync ( ) ) . Where ( networkInterface => networkInterface . IPv4Address . Any ( x => x . Item1 . Equals ( localIP ) ) ) )
543
543
{
544
- if ( networkInterface . IPv4Address . Any ( x => x . Item1 . Equals ( localIP ) ) )
545
- {
546
- subnetmaskDetected = true ;
544
+ subnetmaskDetected = true ;
547
545
548
- Hosts = $ "{ localIP } /{ Subnetmask . ConvertSubnetmaskToCidr ( networkInterface . IPv4Address . First ( ) . Item2 ) } ";
546
+ Hosts = $ "{ localIP } /{ Subnetmask . ConvertSubnetmaskToCidr ( networkInterface . IPv4Address . First ( ) . Item2 ) } ";
549
547
550
- // Fix: If the user clears the textbox and then clicks again on the button, the textbox remains empty...
551
- OnPropertyChanged ( nameof ( Hosts ) ) ;
548
+ // Fix: If the user clears the textbox and then clicks again on the button, the textbox remains empty...
549
+ OnPropertyChanged ( nameof ( Hosts ) ) ;
552
550
553
- break ;
554
- }
551
+ break ;
555
552
}
556
553
557
554
if ( ! subnetmaskDetected )
@@ -569,14 +566,14 @@ private async Task CustomCommand(object guid)
569
566
{
570
567
if ( guid is Guid id )
571
568
{
572
- CustomCommandInfo info = ( CustomCommandInfo ) CustomCommands . FirstOrDefault ( x => x . ID == id ) . Clone ( ) ;
569
+ var info = ( CustomCommandInfo ) CustomCommands . FirstOrDefault ( x => x . ID == id ) ? . Clone ( ) ;
573
570
574
571
if ( info == null )
575
572
return ; // ToDo: Log and error message
576
573
577
574
// Replace vars
578
- string hostname = ! string . IsNullOrEmpty ( SelectedResult . Hostname ) ? SelectedResult . Hostname . TrimEnd ( '.' ) : "" ;
579
- string ipAddress = SelectedResult . PingInfo . IPAddress . ToString ( ) ;
575
+ var hostname = ! string . IsNullOrEmpty ( SelectedResult . Hostname ) ? SelectedResult . Hostname . TrimEnd ( '.' ) : "" ;
576
+ var ipAddress = SelectedResult . PingInfo . IPAddress . ToString ( ) ;
580
577
581
578
info . FilePath = Regex . Replace ( info . FilePath , "\\ $\\ $hostname\\ $\\ $" , hostname , RegexOptions . IgnoreCase ) ;
582
579
info . FilePath = Regex . Replace ( info . FilePath , "\\ $\\ $ipaddress\\ $\\ $" , ipAddress , RegexOptions . IgnoreCase ) ;
@@ -636,7 +633,7 @@ private async Task Export()
636
633
637
634
SettingsManager . Current . IPScanner_ExportFileType = instance . FileType ;
638
635
SettingsManager . Current . IPScanner_ExportFilePath = instance . FilePath ;
639
- } , instance => { _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ; } , new ExportFileType [ ] { ExportFileType . Csv , ExportFileType . Xml , ExportFileType . Json } , true , SettingsManager . Current . IPScanner_ExportFileType , SettingsManager . Current . IPScanner_ExportFilePath ) ;
636
+ } , instance => { _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ; } , new [ ] { ExportFileType . Csv , ExportFileType . Xml , ExportFileType . Json } , true , SettingsManager . Current . IPScanner_ExportFileType , SettingsManager . Current . IPScanner_ExportFilePath ) ;
640
637
641
638
customDialog . Content = new ExportDialog
642
639
{
0 commit comments