forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReleaseNotesDialog.xaml.cs
70 lines (57 loc) · 1.87 KB
/
ReleaseNotesDialog.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
67
68
69
70
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.System;
namespace Files.App.Dialogs
{
public sealed partial class ReleaseNotesDialog : ContentDialog, IDialog<ReleaseNotesDialogViewModel>
{
private FrameworkElement RootAppElement
=> (FrameworkElement)MainWindow.Instance.Content;
public ReleaseNotesDialogViewModel ViewModel
{
get => (ReleaseNotesDialogViewModel)DataContext;
set => DataContext = value;
}
public ReleaseNotesDialog()
{
InitializeComponent();
MainWindow.Instance.SizeChanged += Current_SizeChanged;
AppLanguageHelper.UpdateContextLayout(this);
UpdateDialogLayout();
}
private void UpdateDialogLayout()
{
ContainerGrid.MaxHeight = MainWindow.Instance.Bounds.Height - 70;
}
private void Current_SizeChanged(object sender, WindowSizeChangedEventArgs e)
{
UpdateDialogLayout();
}
private void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
MainWindow.Instance.SizeChanged -= Current_SizeChanged;
}
public new async Task<DialogResult> ShowAsync()
{
return (DialogResult)await SetContentDialogRoot(this).TryShowAsync();
}
private void CloseDialogButton_Click(object sender, RoutedEventArgs e)
{
Hide();
}
// WINUI3
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
{
if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
contentDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
return contentDialog;
}
private async void ReleaseNotesMarkdownTextBlock_LinkClicked(object sender, CommunityToolkit.WinUI.UI.Controls.LinkClickedEventArgs e)
{
if (Uri.TryCreate(e.Link, UriKind.Absolute, out Uri? link))
await Launcher.LaunchUriAsync(link);
}
}
}