forked from microsoft/microsoft-ui-xaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPagerControl.h
89 lines (70 loc) · 3.75 KB
/
PagerControl.h
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "pch.h"
#include "common.h"
#include "PagerControl.g.h"
#include "PagerControl.properties.h"
class PagerControl :
public ReferenceTracker<PagerControl, winrt::implementation::PagerControlT>,
public PagerControlProperties
{
public:
/* Common functions */
PagerControl();
~PagerControl();
/* IFrameworkElement */
void OnApplyTemplate();
void OnPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args);
winrt::AutomationPeer OnCreateAutomationPeer();
/* Property changed handlers */
void OnDisplayModeChanged();
void UpdateDisplayModeAutoState();
void OnNumberOfPagesChanged(const int oldValue);
void OnSelectedPageIndexChange(const int oldValue);
void OnButtonVisibilityChanged(const winrt::PagerControlButtonVisibility visibility,
const wstring_view visibleStateName,
const wstring_view collapsedStateName,
const wstring_view hiddenStateName,
const int hiddenOnEdgePageCriteria);
private:
/* UI updating */
void UpdateTemplateSettingElementLists();
void FillComboBoxCollectionToSize(const int numberOfPages);
void UpdateOnEdgeButtonVisualStates();
/* Eventing */
void RaiseSelectedIndexChanged();
/* NumberPanel logic */
void UpdateNumberPanel(const int numberOfPages);
void UpdateNumberOfPanelCollectionInfiniteItems();
void UpdateNumberPanelCollectionAllItems(const int numberOfPages);
void UpdateNumberPanelCollectionStartWithEllipsis(const int numberOfPages, const int selectedIndex);
void UpdateNumberPanelCollectionEndWithEllipsis(const int numberOfPages, const int selectedIndex);
void UpdateNumberPanelCollectionCenterWithEllipsis(const int numberOfPages, const int selectedIndex);
void MoveIdentifierToElement(const int index);
void AppendButtonToNumberPanelList(const int pageNumber, const int numberOfPages);
void AppendEllipsisIconToNumberPanelList();
/* Interaction event listeners */
void OnRootGridKeyDown(const winrt::IInspectable& sender, const winrt::KeyRoutedEventArgs& args);
void NumberBoxValueChanged(const winrt::IInspectable& sender, const winrt::NumberBoxValueChangedEventArgs& args);
void ComboBoxSelectionChanged(const winrt::IInspectable& sender, const winrt::SelectionChangedEventArgs& args);
void FirstButtonClicked(const IInspectable& sender, const winrt::RoutedEventArgs& args);
void PreviousButtonClicked(const IInspectable& sender, const winrt::RoutedEventArgs& args);
void NextButtonClicked(const IInspectable& sender, const winrt::RoutedEventArgs& args);
void LastButtonClicked(const IInspectable& sender, const winrt::RoutedEventArgs& args);
int m_lastSelectedPageIndex = -1;
int m_lastNumberOfPagesCount = 0;
tracker_ref<winrt::ComboBox> m_comboBox{ this };
tracker_ref<winrt::NumberBox> m_numberBox{ this };
tracker_ref<winrt::ItemsRepeater> m_numberPanelRepeater{ this };
tracker_ref<winrt::FrameworkElement> m_selectedPageIndicator{ this };
winrt::FrameworkElement::KeyDown_revoker m_rootGridKeyDownRevoker{};
winrt::ComboBox::SelectionChanged_revoker m_comboBoxSelectionChangedRevoker{};
winrt::NumberBox::ValueChanged_revoker m_numberBoxValueChangedRevoker{};
winrt::Button::Click_revoker m_firstPageButtonClickRevoker{};
winrt::Button::Click_revoker m_previousPageButtonClickRevoker{};
winrt::Button::Click_revoker m_nextPageButtonClickRevoker{};
winrt::Button::Click_revoker m_lastPageButtonClickRevoker{};
winrt::IObservableVector<IInspectable> m_comboBoxEntries{};
winrt::IObservableVector<IInspectable> m_numberPanelElements{};
};