forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamicDialog.xaml.cs
66 lines (54 loc) · 1.64 KB
/
DynamicDialog.xaml.cs
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
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
using Files.App.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Files.App.Dialogs
{
public sealed partial class DynamicDialog : ContentDialog, IDisposable
{
private FrameworkElement RootAppElement
=> (FrameworkElement)MainWindow.Instance.Content;
public DynamicDialogViewModel ViewModel
{
get => (DynamicDialogViewModel)DataContext;
private set => DataContext = value;
}
public DynamicDialogResult DynamicResult
{
get => ViewModel.DynamicResult;
}
public new Task<ContentDialogResult> ShowAsync()
{
return this.TryShowAsync();
}
public DynamicDialog(DynamicDialogViewModel dynamicDialogViewModel)
{
InitializeComponent();
dynamicDialogViewModel.HideDialog = Hide;
ViewModel = dynamicDialogViewModel;
AppLanguageHelper.UpdateContextLayout(this);
}
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
ViewModel.PrimaryButtonCommand.Execute(args);
}
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
ViewModel.SecondaryButtonCommand.Execute(args);
}
private void ContentDialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
ViewModel.CloseButtonCommand.Execute(args);
}
private void ContentDialog_KeyDown(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e)
{
ViewModel.KeyDownCommand.Execute(e);
}
public void Dispose()
{
ViewModel?.Dispose();
ViewModel = null;
}
}
}