Skip to content

Commit 55e12ed

Browse files
authored
Merge pull request #44 from ShibalovRoman/master
Fixed window and mouse behavior when exception throwed
2 parents 8f4e58c + 2d9cec7 commit 55e12ed

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

SmartMove/MainWindow.xaml.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public partial class MainWindow : Window
5757
#region Private Members
5858

5959
private readonly SupportedVendors _supportedVendors = new SupportedVendors();
60+
61+
private static bool canCloseWindow = true;
6062

6163
#endregion
6264

@@ -263,7 +265,8 @@ public string ConfigurationFileLinesCount
263265

264266
private void CloseButton_OnClick(object sender, RoutedEventArgs e)
265267
{
266-
Close();
268+
if (canCloseWindow)
269+
Close();
267270
}
268271

269272
private void MinimizeButton_OnClick(object sender, RoutedEventArgs e)
@@ -428,6 +431,7 @@ private void BrowseTargetFolder_OnClick(object sender, RoutedEventArgs e)
428431

429432
private async void Go_OnClick(object sender, RoutedEventArgs e)
430433
{
434+
canCloseWindow = false;
431435
string fileName = Path.GetFileNameWithoutExtension(ConfigFilePath.Text);
432436

433437
if (string.IsNullOrEmpty(ConfigFilePath.Text) || string.IsNullOrEmpty(fileName))
@@ -547,11 +551,13 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
547551
case Vendor.CiscoASA:
548552
if (string.IsNullOrEmpty(vendorParser.Version))
549553
{
554+
EnableWindow();
550555
ShowMessage("Unspecified ASA version.\nCannot find ASA version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
551556
return;
552557
}
553558
else if (vendorParser.MajorVersion < 8 || (vendorParser.MajorVersion == 8 && vendorParser.MinorVersion < 3))
554559
{
560+
EnableWindow();
555561
ShowMessage("Unsupported ASA version (" + vendorParser.Version + ").\nThis tool supports ASA 8.3 and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
556562
return;
557563
}
@@ -560,11 +566,13 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
560566
case Vendor.FirePower:
561567
if (string.IsNullOrEmpty(vendorParser.Version))
562568
{
569+
EnableWindow();
563570
ShowMessage("Unspecified NGFW version.\nCannot find version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
564571
return;
565572
}
566573
else if (vendorParser.MajorVersion < 6 || (vendorParser.MajorVersion == 6 && vendorParser.MinorVersion < 4))
567574
{
575+
EnableWindow();
568576
ShowMessage("Unsupported version (" + vendorParser.Version + ").\nThis tool supports NGFW 6.4 and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
569577
return;
570578
}
@@ -573,11 +581,13 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
573581
case Vendor.JuniperJunosOS:
574582
if (string.IsNullOrEmpty(vendorParser.Version))
575583
{
584+
EnableWindow();
576585
ShowMessage("Unspecified SRX version.\nCannot find SRX version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
577586
return;
578587
}
579588
else if (vendorParser.MajorVersion < 12 || (vendorParser.MajorVersion == 12 && vendorParser.MinorVersion < 1))
580589
{
590+
EnableWindow();
581591
ShowMessage("Unsupported SRX version (" + vendorParser.Version + ").\nThis tool supports SRX 12.1 and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
582592
return;
583593
}
@@ -589,35 +599,41 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
589599
case Vendor.FortiGate:
590600
if (string.IsNullOrEmpty(vendorParser.Version))
591601
{
602+
EnableWindow();
592603
ShowMessage("Unspecified FortiGate version.\nCannot find FortiGate version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
593604
return;
594605
}
595606
else if(vendorParser.MajorVersion < 5)
596607
{
608+
EnableWindow();
597609
ShowMessage("Unsupported FortiGate version (" + vendorParser.Version + ").\nThis tool supports FortiGate 5.x and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
598610
return;
599611
}
600612
break;
601613
case Vendor.PaloAlto:
602614
if (string.IsNullOrEmpty(vendorParser.Version))
603615
{
616+
EnableWindow();
604617
ShowMessage("Unspecified PaloAlto version.\nCannot find PaloAlto PAN-OS version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
605618
return;
606619
}
607620
else if (vendorParser.MajorVersion < 7)
608621
{
622+
EnableWindow();
609623
ShowMessage("Unsupported PaloAlto version (" + vendorParser.Version + ").\nThis tool supports PaloAlto PAN-OS 7.x and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
610624
return;
611625
}
612626
break;
613627
case Vendor.PaloAltoPanorama:
614628
if (string.IsNullOrEmpty(vendorParser.Version))
615629
{
630+
EnableWindow();
616631
ShowMessage("Unspecified PaloAlto version.\nCannot find PaloAlto Panorama version for the selected configuration.\nThe configuration may not parse correctly.", MessageTypes.Warning);
617632
return;
618633
}
619634
else if (vendorParser.MajorVersion < 7)
620635
{
636+
EnableWindow();
621637
ShowMessage("Unsupported PaloAlto version (" + vendorParser.Version + ").\nThis tool supports PaloAlto Panorama 7.x and above configuration files.\nThe configuration may not parse correctly.", MessageTypes.Warning);
622638
return;
623639
}
@@ -738,6 +754,14 @@ private async void Go_OnClick(object sender, RoutedEventArgs e)
738754
ResultsPanel.Visibility = Visibility.Visible;
739755

740756
ShowResults(vendorConverter, vendorParser.ParsedLines);
757+
canCloseWindow = true;
758+
}
759+
760+
private void EnableWindow()
761+
{
762+
Mouse.OverrideCursor = null;
763+
EnableDisableControls(true);
764+
OutputPanel.Visibility = Visibility.Collapsed;
741765
}
742766

743767
private void ConvertUserConf_Checked(object sender, RoutedEventArgs e)
@@ -975,7 +999,9 @@ public static void ShowMessage(string message, MessageTypes messageType, string
975999
MessageLinkValue = messageLinkValue
9761000
};
9771001

1002+
Mouse.OverrideCursor = null;
9781003
messageWindow.ShowDialog();
1004+
canCloseWindow = true;
9791005
}
9801006

9811007
#endregion

0 commit comments

Comments
 (0)