-
Notifications
You must be signed in to change notification settings - Fork 1
/
S2_ListFolders.xaml.cpp
72 lines (61 loc) · 2.36 KB
/
S2_ListFolders.xaml.cpp
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
71
72
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// Scenario2.xaml.cpp
// Implementation of the Scenario2 class
//
#include "pch.h"
#include "S2_ListFolders.xaml.h"
using namespace SDKTemplate;
using namespace concurrency;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Storage;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
Scenario2::Scenario2()
{
InitializeComponent();
}
/// <summary>
/// Obtains the list of folders that make up the Pictures library and binds the FoldersListView
/// to this list.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Scenario2::ListFoldersButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
ListFoldersButton->IsEnabled = false;
create_task(StorageLibrary::GetLibraryAsync(KnownLibraryId::Pictures)).then([this](StorageLibrary^ library)
{
picturesLibrary = library;
// Bind the FoldersListView to the list of folders that make up the library
FoldersListView->ItemsSource = picturesLibrary->Folders;
// Register for the DefinitionChanged event to be notified if other apps modify the library
picturesLibrary->DefinitionChanged += ref new TypedEventHandler<StorageLibrary^, Platform::Object^>(
[this](StorageLibrary^ /*sender*/, Platform::Object^ /*e*/)
{
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
{
UpdateHeaderText();
}));
});
UpdateHeaderText();
});
}
/// <summary>
/// Updates the FoldersListHeaderTextBlock with the count of folders in the Pictures library.
/// </summary>
void Scenario2::UpdateHeaderText()
{
FoldersListHeaderTextBlock->Text = "Pictures library (" + picturesLibrary->Folders->Size + " folders)";
}