Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ViewIdentityPage.xaml.cs
2using SkiaSharp.Extended.UI.Controls;
3using System; // For IDisposable
4using System.Threading; // Added for cancellation support
5
7{
11 public partial class ViewIdentityPage
12 {
18 {
19 this.InitializeComponent();
20 this.ContentPageModel = Vm;
21 }
22
23 protected override void OnSizeAllocated(double width, double height)
24 {
25 base.OnSizeAllocated(width, height);
26 try
27 {
28 if (this.RainbowView is null || this.ConfettiView is null)
29 {
30 return;
31 }
32
33 // Set the size of the rainbow view
34 this.RainbowView.WidthRequest = height + 200;
35 this.RainbowView.HeightRequest = width + 200;
36
37 // Prepare the confetti system:
38 this.ConfettiView.Systems?.Clear();
39
40 double BandHeight = 40;
41 double BandWidth = 40;
42
43 // Bottom‑left rectangle:
44 Rect BottomLeftRect = new Rect(
45 x: 0,
46 y: height - BandHeight,
47 width: BandWidth,
48 height: BandHeight);
49
50 // Bottom‑right rectangle:
51 Rect BottomRightRect = new Rect(
52 x: width - BandWidth,
53 y: height - BandHeight,
54 width: BandWidth,
55 height: BandHeight);
56
57 this.ConfettiView.Systems?.Add(this.CreateSideSystem(SKConfettiEmitterSide.Left, BottomLeftRect));
58 this.ConfettiView.Systems?.Add(this.CreateSideSystem(SKConfettiEmitterSide.Right, BottomRightRect));
59 }
60 catch (Exception ex)
61 {
62 // Handle any exceptions that may occur during the update
63 Console.WriteLine($"Error updating rainbow view: {ex.Message}");
64 }
65 }
66
68 public override Task OnDisappearingAsync()
69 {
71 return base.OnDisappearingAsync();
72 }
73
74
75 private SKConfettiSystem CreateSideSystem(SKConfettiEmitterSide side, Rect p)
76 {
77 SKConfettiSystem Sys = new SKConfettiSystem
78 {
79 // 2‑second gravity‑driven burst, then fade
80 Emitter = SKConfettiEmitter.Stream(100, 2),
81 Lifetime = 4,
82 FadeOut = true,
83 Gravity = new Point(0, 40),
84 MinimumInitialVelocity = 500,
85 MaximumInitialVelocity = 800,
86 MinimumRotationVelocity = 0,
87 MaximumRotationVelocity = 360,
88 MaximumVelocity = 800,
89
90 // colors, physics & shapes
91 Colors = new SKConfettiColorCollection
92 {
93 Colors.Red, Colors.Yellow, Colors.Green, Colors.Blue
94 },
95 Physics = new SKConfettiPhysicsCollection
96 {
97 new SKConfettiPhysics (8,1),
98 new SKConfettiPhysics (12,0.6)
99 },
100 Shapes = new SKConfettiShapeCollection
101 {
102 new SKConfettiSquareShape(),
103 new SKConfettiCircleShape()
104 },
105
106 // spawn from the exact side line by default:
107 EmitterBounds = new SKConfettiEmitterBounds(p)
108 };
109
110 // angle them inward horizontally:
111 if (side == SKConfettiEmitterSide.Left)
112 {
113 // Fan into the center from bottom‐left:
114 Sys.StartAngle = 280;
115 Sys.EndAngle = 320;
116 }
117 else
118 {
119 // Fan into the center from bottom‐right:
120 Sys.StartAngle = 220;
121 Sys.EndAngle = 260;
122 }
123
124 return Sys;
125 }
126
127 private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
128 {
129 try
130 {
131 if (this.ContentPageModel is ViewIdentityViewModel VM)
132 {
133 if (!this.BottomSheet.IsExpanded)
134 {
135 this.BottomSheet?.ToggleExpanded();
136 }
137 }
138 }
139 catch (Exception Ex)
140 {
141 ServiceRef.LogService.LogException(Ex);
142 }
143 }
144
145 }
146}
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
A page to display when the user wants to view an identity.
ViewIdentityPage(ViewIdentityViewModel Vm)
Creates a new instance of the ViewIdentityPage class.