2
2
using Files . Helpers ;
3
3
using Files . Interacts ;
4
4
using Files . View_Models ;
5
- using GalaSoft . MvvmLight ;
6
5
using System ;
7
- using System . Collections . Generic ;
8
- using System . IO ;
9
- using System . Linq ;
10
6
using System . Threading ;
11
- using System . Threading . Tasks ;
12
7
using Windows . Foundation . Metadata ;
13
- using Windows . Security . Cryptography . Core ;
14
- using Windows . Storage ;
15
- using Windows . Storage . FileProperties ;
16
- using Windows . Storage . Search ;
17
8
using Windows . UI ;
18
- using Windows . UI . Core ;
19
9
using Windows . UI . WindowManagement ;
20
10
using Windows . UI . Xaml ;
21
11
using Windows . UI . Xaml . Controls ;
22
- using Windows . UI . Xaml . Media ;
23
- using Windows . UI . Xaml . Media . Imaging ;
24
12
using Windows . UI . Xaml . Navigation ;
25
- using static Files . Helpers . NativeFindStorageItemHelper ;
26
- using FileAttributes = System . IO . FileAttributes ;
27
13
28
14
namespace Files
29
15
{
30
16
public sealed partial class Properties : Page
31
17
{
32
18
private static AppWindowTitleBar _TitleBar ;
33
- private CancellationTokenSource _tokenSource ;
19
+
20
+ private CancellationTokenSource _tokenSource = new CancellationTokenSource ( ) ;
34
21
35
22
public AppWindow propWindow ;
23
+
36
24
public SelectedItemsPropertiesViewModel ViewModel { get ; set ; }
37
25
38
26
public Properties ( )
39
27
{
40
28
this . InitializeComponent ( ) ;
41
29
}
30
+
42
31
protected override void OnNavigatedTo ( NavigationEventArgs e )
43
32
{
44
33
ViewModel = new SelectedItemsPropertiesViewModel ( e . Parameter as ListedItem ) ;
45
- if ( ApiInformation . IsApiContractPresent ( "Windows.Foundation.UniversalApiContract" , 8 ) )
46
- {
47
- Loaded += Properties_Loaded ;
48
- }
49
- else
50
- {
51
- this . OKButton . Visibility = Visibility . Collapsed ;
52
- }
53
34
ViewModel . ItemMD5HashProgress = ItemMD5HashProgress ;
54
35
ViewModel . Dispatcher = Dispatcher ;
55
36
App . AppSettings . ThemeModeChanged += AppSettings_ThemeModeChanged ;
56
37
base . OnNavigatedTo ( e ) ;
57
38
}
39
+
58
40
private async void Properties_Loaded ( object sender , RoutedEventArgs e )
59
41
{
60
- _tokenSource ? . Dispose ( ) ;
61
- _tokenSource = new CancellationTokenSource ( ) ;
62
- Unloaded += Properties_Unloaded ;
63
42
if ( ApiInformation . IsApiContractPresent ( "Windows.Foundation.UniversalApiContract" , 8 ) )
64
43
{
65
44
// Collect AppWindow-specific info
@@ -73,6 +52,7 @@ private async void Properties_Loaded(object sender, RoutedEventArgs e)
73
52
74
53
await ViewModel . GetPropertiesAsync ( _tokenSource ) ;
75
54
}
55
+
76
56
private void Properties_Unloaded ( object sender , RoutedEventArgs e )
77
57
{
78
58
if ( _tokenSource != null && ! _tokenSource . IsCancellationRequested )
@@ -81,8 +61,8 @@ private void Properties_Unloaded(object sender, RoutedEventArgs e)
81
61
_tokenSource . Dispose ( ) ;
82
62
_tokenSource = null ;
83
63
}
84
- Unloaded -= Properties_Unloaded ;
85
64
}
65
+
86
66
private void AppSettings_ThemeModeChanged ( object sender , EventArgs e )
87
67
{
88
68
RequestedTheme = ThemeHelper . RootTheme ;
@@ -118,9 +98,6 @@ private async void Button_Click(object sender, RoutedEventArgs e)
118
98
else
119
99
{
120
100
App . PropertiesDialogDisplay . Hide ( ) ;
121
- _tokenSource . Cancel ( ) ;
122
- _tokenSource . Dispose ( ) ;
123
- _tokenSource = new CancellationTokenSource ( ) ;
124
101
}
125
102
}
126
103
}
0 commit comments