18 namespace xaml = winrt::Microsoft::UI::Xaml;
20 namespace xaml = winrt::Windows::UI::Xaml;
34 inline auto tolower(std::wstring_view sv) {
35 std::wstring copy(sv);
36 std::transform(copy.begin(), copy.end(), copy.begin(), [](
wchar_t x) { return (wchar_t)::tolower(x); });
53 template<
template<
typename...>
typename TOutContainer = std::vector,
typename TInContainer,
typename UnaryOp>
54 auto transform(TInContainer
const& iterable, UnaryOp&& unary_op) {
55 using result_t = std::invoke_result_t<UnaryOp, typename TInContainer::value_type>;
56 TOutContainer<result_t> out{};
57 auto o = std::inserter(out, out.end());
58 for (
auto i = iterable.cbegin(); i != iterable.cend(); i++) {
99 template<
template<
typename...>
typename TOutContainer = std::vector,
typename TInContainer,
typename UnaryOp>
101 using result_t = std::invoke_result_t<UnaryOp, typename TInContainer::value_type, typename TInContainer::const_iterator::difference_type>;
102 TOutContainer<result_t> out{};
103 auto o = std::inserter(out, out.end());
104 for (
auto i = iterable.cbegin(); i != iterable.cend(); i++) {
105 o = unary_op(*i, i - iterable.cbegin());
119 template<
typename T = cppxaml::xaml::DependencyObject>
121 if (
auto fe = d.try_as<cppxaml::xaml::FrameworkElement>()) {
122 if (fe.Name() == name)
return d.as<T>();
124 for (
int i = 0; i < cppxaml::xaml::Media::VisualTreeHelper::GetChildrenCount(d); i++) {
125 auto r = FindChildByName<T>(cppxaml::xaml::Media::VisualTreeHelper::GetChild(d, i), name);
126 if (r)
return r.as<T>();
135#define IF_ASSIGNABLE_CONTROL(XAMLTYPE) std::enable_if_t<std::is_assignable_v<cppxaml::xaml::Controls::XAMLTYPE, T>, cppxaml::details::Wrapper<T>>
136#define IF_ASSIGNABLE_CONTROL_TITEMS(XAMLTYPE, TITEMS) std::enable_if_t<std::is_assignable_v<cppxaml::xaml::Controls::XAMLTYPE, T>, cppxaml::details::Wrapper<T, TITEMS>>
137#define DOXY_RT(...) auto
139#define IF_ASSIGNABLE_CONTROL(XAMLTYPE) cppxaml::details::Wrapper<T>
140#define IF_ASSIGNABLE_CONTROL_TITEMS(XAMLTYPE, TITEMS) cppxaml::details::Wrapper<T, TITEMS>
141#define DOXY_RT(...) __VA_ARGS__
auto tolower(std::wstring_view sv)
Definition: utils.h:34
auto transform(TInContainer const &iterable, UnaryOp &&unary_op)
Maps each element in a container via a unary operation on each element.
Definition: utils.h:54
auto transform_with_index(TInContainer const &iterable, UnaryOp &&unary_op)
Maps each element in a container via a unary operation on each element.
Definition: utils.h:100
The main CppXAML namespace.
T FindChildByName(cppxaml::xaml::DependencyObject d, std::wstring_view name)
Finds a XAML element by name.
Definition: utils.h:120