-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathCompressIntoArchiveAction.cs
More file actions
55 lines (43 loc) · 1.45 KB
/
CompressIntoArchiveAction.cs
File metadata and controls
55 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Files Community
// Licensed under the MIT License.
using Files.App.Dialogs;
using Microsoft.UI.Xaml.Controls;
using Windows.Foundation.Metadata;
namespace Files.App.Actions
{
[GeneratedRichCommand]
internal sealed partial class CompressIntoArchiveAction : BaseCompressArchiveAction
{
public override string Label
=> Strings.CreateArchive.GetLocalizedResource();
public override string Description
=> Strings.CompressIntoArchiveDescription.GetLocalizedFormatResource(context.SelectedItems.Count);
public CompressIntoArchiveAction()
{
}
public override async Task ExecuteAsync(object? parameter = null)
{
if (context.ShellPage is null)
return;
GetDestination(out var sources, out var directory, out var fileName);
var dialog = new CreateArchiveDialog() { FileName = fileName };
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
var result = await dialog.TryShowAsync();
if (!dialog.CanCreate || result != ContentDialogResult.Primary)
return;
ICompressArchiveModel compressionModel = new CompressArchiveModel(
sources,
directory,
dialog.FileName,
dialog.CPUThreads,
dialog.Password,
dialog.FileFormat,
dialog.CompressionLevel,
dialog.SplittingSize,
dialog.DictionarySize,
dialog.WordSize);
await StorageArchiveService.CompressAsync(compressionModel);
}
}
}