MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / UserControl_Loaded

Method UserControl_Loaded

FastCopy/ProgressBarEx.xaml.cpp:37–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 );
36
37 void ProgressBarEx::UserControl_Loaded(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e)
38 {
39 auto visual = winrt::Microsoft::UI::Xaml::Hosting::ElementCompositionPreview::GetElementVisual(Bar());
40 auto compositor = visual.Compositor();
41 m_propertySet = compositor.CreatePropertySet();
42 m_propertySet.InsertScalar(L"width", 50);
43
44 m_pointLight = compositor.CreatePointLight();
45 m_pointLight.Color(winrt::Microsoft::UI::Colors::White());
46 m_pointLight.CoordinateSpace(visual);
47 m_pointLight.Targets().Add(visual);
48 m_pointLight.Offset(
49 {
50 (float)-Bar().ActualWidth(),
51 (float)Bar().ActualHeight() / 2.0f,
52 (float)30
53 });
54
55 m_animation = compositor.CreateScalarKeyFrameAnimation();
56 //m_animation.InsertKeyFrame(1.0f, 2 * Bar().ActualWidth());
57 m_animation.SetReferenceParameter(L"propertySet", m_propertySet);
58 m_animation.InsertExpressionKeyFrame(1.0f, L"propertySet.width");
59 m_animation.Duration(std::chrono::seconds{ 3 });
60 m_animation.IterationBehavior(winrt::Microsoft::UI::Composition::AnimationIterationBehavior::Forever);
61 m_animation.Target(L"Offset.X");
62
63 auto intensityAnimation = compositor.CreateScalarKeyFrameAnimation();
64 intensityAnimation.Target(L"Intensity");
65 intensityAnimation.Duration(std::chrono::seconds{ 3 });
66 intensityAnimation.IterationBehavior(winrt::Microsoft::UI::Composition::AnimationIterationBehavior::Forever);
67 intensityAnimation.InsertKeyFrame(0.0, 0.0);
68 intensityAnimation.InsertKeyFrame(0.2, 1.0);
69 intensityAnimation.InsertKeyFrame(0.6, 1.0);
70 intensityAnimation.InsertKeyFrame(1.0, 0.0);
71
72
73 auto group = compositor.CreateAnimationGroup();
74 group.Add(m_animation);
75 group.Add(intensityAnimation);
76
77 //m_pointLight.StartAnimation(L"Offset.X", animation);
78 m_pointLight.StartAnimationGroup(group);
79
80 m_ambientLight = compositor.CreateAmbientLight();
81 m_ambientLight.Intensity(1.0);
82 m_ambientLight.Color(winrt::Microsoft::UI::Colors::White());
83 m_ambientLight.Targets().Add(visual);
84 }
85
86 void ProgressBarEx::Bar_SizeChanged(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::SizeChangedEventArgs const&)
87 {

Callers

nothing calls this directly

Calls 1

ColorMethod · 0.80

Tested by

no test coverage detected