Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: harmonize create backup window handling #186

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/BSH.Main/Dialogs/frmMainTabs/ucOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,24 +355,7 @@ private async void cmdBackupNow_MouseClick(object sender, MouseEventArgs e)
{
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
// show options
using (var dlgCreateBackup = new frmCreateBackup())
{
if (dlgCreateBackup.ShowDialog() != DialogResult.OK)
{
return;
}

// retrieve sources
string sources = string.Join("|", dlgCreateBackup.clstSources.CheckedItems.Cast<string>());
if (string.IsNullOrEmpty(sources))
{
return;
}

// start backup
await BackupLogic.BackupController.CreateBackupAsync(dlgCreateBackup.txtTitle.Text, dlgCreateBackup.txtDescription.Text, true, dlgCreateBackup.cbFullBackup.Checked, dlgCreateBackup.chkShutdownPC.Checked, sourceFolders: sources);
}
await PresentationController.Current.ShowCreateBackupWindow();
}
else
{
Expand Down
18 changes: 1 addition & 17 deletions src/BSH.Main/Modules/NotificationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,7 @@ private async void eventMainContextStartBackup(object sender, EventArgs e)

private async void eventMainContextStartBackupOptions(object sender, EventArgs e)
{
// show dialog with more backup options
using var dlgCreateBackup = new frmCreateBackup();
if (dlgCreateBackup.ShowDialog() != DialogResult.OK)
{
return;
}

// concatenate source folders
var sourceFolders = string.Join("|", dlgCreateBackup.clstSources.CheckedItems);

if (string.IsNullOrEmpty(sourceFolders))
{
return;
}

// start backup job
await BackupLogic.BackupController.CreateBackupAsync(dlgCreateBackup.txtTitle.Text, dlgCreateBackup.txtDescription.Text, true, dlgCreateBackup.cbFullBackup.Checked, dlgCreateBackup.chkShutdownPC.Checked, sourceFolders: sourceFolders);
await PresentationController.Current.ShowCreateBackupWindow();
}

private void eventMainContextClick(object sender, EventArgs e)
Expand Down
23 changes: 23 additions & 0 deletions src/BSH.Main/Modules/PresentationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

using BSH.Main.Dialogs.SubDialogs;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Brightbits.BSH.Main
Expand Down Expand Up @@ -170,5 +172,26 @@ public void ShowErrorInsufficientDiskSpace()
using var errorWindow = new frmErrorInsufficientDiskSpace();
errorWindow.ShowDialog();
}

public async Task ShowCreateBackupWindow()
{
using (var dlgCreateBackup = new frmCreateBackup())
{
if (dlgCreateBackup.ShowDialog() != DialogResult.OK)
{
return;
}

// retrieve sources
string sources = string.Join("|", dlgCreateBackup.clstSources.CheckedItems.Cast<string>());
if (string.IsNullOrEmpty(sources))
{
return;
}

// start backup
await BackupLogic.BackupController.CreateBackupAsync(dlgCreateBackup.txtTitle.Text, dlgCreateBackup.txtDescription.Text, true, dlgCreateBackup.cbFullBackup.Checked, dlgCreateBackup.chkShutdownPC.Checked, sourceFolders: sources);
}
}
}
}