MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / OnResourcesChanged

Method OnResourcesChanged

Xaml/StyleResources.cpp:18–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 wux::PropertyMetadata(nullptr, OnResourcesChanged));
17
18 void StyleResources::OnResourcesChanged(const wux::DependencyObject &d, const wux::DependencyPropertyChangedEventArgs &e)
19 {
20 if (const auto source = d.try_as<wux::FrameworkElement>())
21 {
22 wfc::IVector<wux::ResourceDictionary> mergedDicts(nullptr);
23 if (const auto resources = source.Resources())
24 {
25 mergedDicts = resources.MergedDictionaries();
26 }
27
28 if (mergedDicts)
29 {
30 const auto begin = mergedDicts.begin();
31 const auto end = mergedDicts.end();
32 const auto it = std::ranges::find_if(begin, end, [](const wux::ResourceDictionary &resDict)
33 {
34 return resDict.try_as<IStyleResourceDictionary>() != nullptr;
35 });
36
37 if (it != end)
38 {
39 mergedDicts.RemoveAt(static_cast<uint32_t>(it - begin));
40 }
41
42 if (const auto newVal = e.NewValue().try_as<wux::ResourceDictionary>())
43 {
44 const auto clonedRes = winrt::make<StyleResourceDictionary>();
45 CloneResourceDictionary(newVal, clonedRes);
46 mergedDicts.Append(clonedRes);
47 }
48 }
49 }
50 }
51
52 wux::ResourceDictionary StyleResources::CloneResourceDictionary(const wux::ResourceDictionary &resource, const wux::ResourceDictionary &destination)
53 {

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected