forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code Quality: Create alike RichCommands inheritance (files-community#…
- Loading branch information
1 parent
bd8c78f
commit 2b4132f
Showing
23 changed files
with
417 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Files.App.Dialogs; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class CompressIntoArchiveAction : BaseCompressArchiveAction | ||
{ | ||
public override string Label | ||
=> "CreateArchive".GetLocalizedResource(); | ||
|
||
public override string Description | ||
=> "CompressIntoArchiveDescription".GetLocalizedResource(); | ||
|
||
public CompressIntoArchiveAction() | ||
{ | ||
} | ||
|
||
public override async Task ExecuteAsync() | ||
{ | ||
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage); | ||
|
||
var dialog = new CreateArchiveDialog | ||
{ | ||
FileName = fileName, | ||
}; | ||
|
||
var result = await dialog.TryShowAsync(); | ||
|
||
if (!dialog.CanCreate || result != ContentDialogResult.Primary) | ||
return; | ||
|
||
IArchiveCreator creator = new ArchiveCreator | ||
{ | ||
Sources = sources, | ||
Directory = directory, | ||
FileName = dialog.FileName, | ||
Password = dialog.Password, | ||
FileFormat = dialog.FileFormat, | ||
CompressionLevel = dialog.CompressionLevel, | ||
SplittingSize = dialog.SplittingSize, | ||
}; | ||
|
||
await ArchiveHelpers.CompressArchiveAsync(creator); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class CompressIntoSevenZipAction : BaseCompressArchiveAction | ||
{ | ||
public override string Label | ||
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.7z"); | ||
|
||
public override string Description | ||
=> "CompressIntoSevenZipDescription".GetLocalizedResource(); | ||
|
||
public CompressIntoSevenZipAction() | ||
{ | ||
} | ||
|
||
public override Task ExecuteAsync() | ||
{ | ||
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage); | ||
|
||
IArchiveCreator creator = new ArchiveCreator | ||
{ | ||
Sources = sources, | ||
Directory = directory, | ||
FileName = fileName, | ||
FileFormat = ArchiveFormats.SevenZip, | ||
}; | ||
|
||
return ArchiveHelpers.CompressArchiveAsync(creator); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class CompressIntoZipAction : BaseCompressArchiveAction | ||
{ | ||
public override string Label | ||
=> string.Format("CreateNamedArchive".GetLocalizedResource(), $"{ArchiveHelpers.DetermineArchiveNameFromSelection(context.SelectedItems)}.zip"); | ||
|
||
public override string Description | ||
=> "CompressIntoZipDescription".GetLocalizedResource(); | ||
|
||
public CompressIntoZipAction() | ||
{ | ||
} | ||
|
||
public override Task ExecuteAsync() | ||
{ | ||
var (sources, directory, fileName) = ArchiveHelpers.GetCompressDestination(context.ShellPage); | ||
|
||
IArchiveCreator creator = new ArchiveCreator | ||
{ | ||
Sources = sources, | ||
Directory = directory, | ||
FileName = fileName, | ||
FileFormat = ArchiveFormats.Zip, | ||
}; | ||
|
||
return ArchiveHelpers.CompressArchiveAsync(creator); | ||
} | ||
} | ||
} |
79 changes: 0 additions & 79 deletions
79
src/Files.App/Actions/Content/Archives/CompressIntoArchiveAction.cs
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
src/Files.App/Actions/Content/Archives/CompressIntoSevenZipAction.cs
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
src/Files.App/Actions/Content/Archives/CompressIntoZipAction.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.