1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-06-02 15:34:06 +02:00

Message boxes use main window to stay in front

This commit is contained in:
chylex 2015-04-13 17:30:36 +02:00
parent ab8dfb3d07
commit 92861ea03e
2 changed files with 6 additions and 4 deletions
BackupEssentials

View File

@ -14,6 +14,8 @@ namespace BackupEssentials{
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hwnd);
public static Window Window { get { return Application.Current.MainWindow; } }
/// <summary>
/// List of arguments
/// =================
@ -63,11 +65,11 @@ namespace BackupEssentials{
return;
}
else{
if (MessageBox.Show("The application is already running, but is not responding. Do you want to force close it?","Application is already running",MessageBoxButton.YesNo,MessageBoxImage.Question) == MessageBoxResult.Yes){
if (MessageBox.Show(MainWindow,"The application is already running, but is not responding. Do you want to force close it?","Application is already running",MessageBoxButton.YesNo,MessageBoxImage.Question) == MessageBoxResult.Yes){
try{
process.Kill();
}catch(Exception e){
MessageBox.Show("Could not close the application: "+e.Message);
MessageBox.Show(MainWindow,"Could not close the application: "+e.Message);
}
}
}

View File

@ -40,7 +40,7 @@ namespace BackupEssentials.Pages{
private void ClickSave(object sender, RoutedEventArgs e){
if (EditLocation.Name.Length == 0){
VisualStateManager.GoToState(TextBoxName,"Invalid",true);
System.Windows.MessageBox.Show("Location name cannot be empty.","Caution!",MessageBoxButton.OK,MessageBoxImage.Warning);
System.Windows.MessageBox.Show(App.Window,"Location name cannot be empty.","Caution!",MessageBoxButton.OK,MessageBoxImage.Warning);
return;
}
@ -56,7 +56,7 @@ namespace BackupEssentials.Pages{
if (warning.Length != 0){
VisualStateManager.GoToState(TextBoxDirectory,"Invalid",true);
LastWarningDirectory = EditLocation.Directory;
System.Windows.MessageBox.Show(warning+" Click Save again to confirm.","Caution!",MessageBoxButton.OK,MessageBoxImage.Warning);
System.Windows.MessageBox.Show(App.Window,warning+" Click Save again to confirm.","Caution!",MessageBoxButton.OK,MessageBoxImage.Warning);
return;
}
}