-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomePage.xaml.cpp
More file actions
90 lines (77 loc) · 2.63 KB
/
HomePage.xaml.cpp
File metadata and controls
90 lines (77 loc) · 2.63 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "stdafx.h"
#include "HomePage.xaml.h"
#if __has_include("HomePage.g.cpp")
#include "HomePage.g.cpp"
#endif
#include "App.xaml.h"
#include "Prerequisite.h"
using namespace winrt;
using namespace Microsoft::UI::Xaml;
using namespace Microsoft::UI::Xaml::Media::Imaging;
using namespace Microsoft::UI::Xaml::Media::Animation;
namespace winrt::SuiteInstaller::implementation
{
HomePage::HomePage()
: mContext(App::AppService().RuntimeContext())
{
this->DataContext(mContext);
SetupCarouselTimer();
}
void HomePage::SetupCarouselTimer()
{
if (!timer)
{
timer = DispatcherTimer();
timer.Interval(Windows::Foundation::TimeSpan{ std::chrono::seconds(5) });
timer.Tick({ this, &HomePage::OnTimerTick });
timer.Start();
}
}
void HomePage::OnTimerTick(IInspectable const &, IInspectable const &)
{
if (HomeFlipView().Items() && HomeFlipView().Items().Size() > 0)
{
HomeFlipView().SelectedIndex((HomeFlipView().SelectedIndex() + 1) %
HomeFlipView().Items().Size());
}
}
void HomePage::OnNavigatedFrom(Navigation::NavigationEventArgs const & e)
{
if (timer)
{
timer.Stop();
timer = nullptr;
}
HomePageT<HomePage>::OnNavigatedFrom(e);
}
void HomePage::FlipViewItem_Tapped(IInspectable const & sender,
Input::TappedRoutedEventArgs const & /*e*/)
{
auto grid = sender.try_as<Controls::Grid>();
if (grid)
{
auto prereq = grid.DataContext().try_as<SuiteInstaller::Prerequisite>();
if (prereq)
{
auto image = grid.FindName(L"ConnectedImage").try_as<Controls::Image>();
auto title = grid.FindName(L"ConnectedTitle").try_as<Controls::TextBlock>();
if (image)
{
auto animationService = ConnectedAnimationService::GetForCurrentView();
animationService.PrepareToAnimate(L"ForwardConnectedAnimation", image);
animationService.PrepareToAnimate(L"ForwardConnectedTitleAnimation", title);
}
Frame().Navigate(xaml_typename<SuiteInstaller::PrerequisitePage>(), prereq);
}
}
}
void HomePage::GridViewItem_Clicked(IInspectable const & /*sender*/,
Controls::ItemClickEventArgs const & e)
{
ConnectedGridView().PrepareConnectedAnimation(L"ForwardConnectedAnimation", e.ClickedItem(),
L"ConnectedIcon");
ConnectedGridView().PrepareConnectedAnimation(L"ForwardConnectedTitleAnimation", e.ClickedItem(),
L"ConnectedTitle");
Frame().Navigate(xaml_typename<SuiteInstaller::PrerequisitePage>(), e.ClickedItem());
}
} // namespace winrt::SuiteInstaller::implementation