|
1 | 1 | using log4net; |
2 | 2 | using MahApps.Metro.Controls; |
3 | | -using MahApps.Metro.Controls.Dialogs; |
4 | 3 | using MahApps.Metro.SimpleChildWindow; |
5 | 4 | using NETworkManager.Controls; |
6 | 5 | using NETworkManager.Localization; |
@@ -39,8 +38,6 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal |
39 | 38 | #region Variables |
40 | 39 | private static readonly ILog Log = LogManager.GetLogger(typeof(IPScannerViewModel)); |
41 | 40 |
|
42 | | - private readonly IDialogCoordinator _dialogCoordinator; |
43 | | - |
44 | 41 | private CancellationTokenSource _cancellationTokenSource; |
45 | 42 |
|
46 | 43 | private readonly Guid _tabId; |
@@ -285,13 +282,10 @@ private set |
285 | 282 | /// <summary> |
286 | 283 | /// Initializes a new instance of the <see cref="IPScannerViewModel"/> class. |
287 | 284 | /// </summary> |
288 | | - /// <param name="instance">The dialog coordinator instance.</param> |
289 | 285 | /// <param name="tabId">The unique identifier for the tab.</param> |
290 | 286 | /// <param name="hostOrIPRange">The initial host or IP range to scan.</param> |
291 | | - public IPScannerViewModel(IDialogCoordinator instance, Guid tabId, string hostOrIPRange) |
| 287 | + public IPScannerViewModel(Guid tabId, string hostOrIPRange) |
292 | 288 | { |
293 | | - _dialogCoordinator = instance; |
294 | | - |
295 | 289 | ConfigurationManager.Current.IPScannerTabCount++; |
296 | 290 |
|
297 | 291 | _tabId = tabId; |
@@ -564,15 +558,17 @@ private async Task DetectIPRange() |
564 | 558 | } |
565 | 559 |
|
566 | 560 | if (!subnetmaskDetected) |
567 | | - await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, |
568 | | - Strings.CouldNotDetectSubnetmask, MessageDialogStyle.Affirmative, |
569 | | - AppearanceManager.MetroDialog); |
| 561 | + { |
| 562 | + var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive); |
| 563 | + |
| 564 | + await DialogHelper.ShowMessageAsync(window, Strings.Error, Strings.CouldNotDetectSubnetmask, ChildWindowIcon.Error); |
| 565 | + } |
570 | 566 | } |
571 | 567 | else |
572 | 568 | { |
573 | | - await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, |
574 | | - Strings.CouldNotDetectLocalIPAddressMessage, MessageDialogStyle.Affirmative, |
575 | | - AppearanceManager.MetroDialog); |
| 569 | + var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive); |
| 570 | + |
| 571 | + await DialogHelper.ShowMessageAsync(window, Strings.Error, Strings.CouldNotDetectLocalIPAddressMessage, ChildWindowIcon.Error); |
576 | 572 | } |
577 | 573 |
|
578 | 574 | IsSubnetDetectionRunning = false; |
@@ -614,10 +610,9 @@ private async Task CustomCommand(object guid) |
614 | 610 | { |
615 | 611 | Log.Error("Error trying to run custom command", ex); |
616 | 612 |
|
617 | | - await _dialogCoordinator.ShowMessageAsync(this, |
618 | | - Strings.ResourceManager.GetString("Error", |
619 | | - LocalizationManager.GetInstance().Culture), ex.Message, MessageDialogStyle.Affirmative, |
620 | | - AppearanceManager.MetroDialog); |
| 613 | + var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive); |
| 614 | + |
| 615 | + await DialogHelper.ShowMessageAsync(window, Strings.Error, ex.Message, ChildWindowIcon.Error); |
621 | 616 | } |
622 | 617 | } |
623 | 618 | } |
@@ -667,12 +662,9 @@ private Task Export() |
667 | 662 | { |
668 | 663 | Log.Error("Error while exporting data as " + instance.FileType, ex); |
669 | 664 |
|
670 | | - var settings = AppearanceManager.MetroDialog; |
671 | | - settings.AffirmativeButtonText = Strings.OK; |
672 | | - |
673 | | - await _dialogCoordinator.ShowMessageAsync(window, Strings.Error, |
| 665 | + await DialogHelper.ShowMessageAsync(window, Strings.Error, |
674 | 666 | Strings.AnErrorOccurredWhileExportingTheData + Environment.NewLine + |
675 | | - Environment.NewLine + ex.Message, MessageDialogStyle.Affirmative, settings); |
| 667 | + Environment.NewLine + ex.Message, ChildWindowIcon.Error); |
676 | 668 | } |
677 | 669 |
|
678 | 670 | SettingsManager.Current.IPScanner_ExportFileType = instance.FileType; |
|
0 commit comments