Skip to content

Commit

Permalink
Keeping example simple, uncomment to test randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapusch committed Jan 7, 2024
1 parent 6a95413 commit 23df859
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ public class Spotlight : BoxView
uint AnimationLength { get; set; }
Animation SpotlightAnimation { get; set; }

/// <summary>
/// A rounded BoxView giving impression of a spotlight
/// </summary>
/// <param name="color">Main color of the spotlight</param>
/// <param name="size">Size of the spotlight</param>
/// <param name="positionX">Horizontal position of the spotlight</param>
/// <param name="positionY">Custom vertical position of the spotlight</param>
/// <param name="animationLength">Animation pattern duration in milliseconds</param>
/// <param name="bindableMediaElement">MediaElement to bind the animation to</param>
public Spotlight(Color color, double size, double positionX, double positionY, uint animationLength = 0, MediaElement bindableMediaElement = null)
{
Background = new RadialGradientBrush()
Expand Down
25 changes: 22 additions & 3 deletions Samples/NightClub/Full Solution/NightClub/Views/MusicPlayerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@ public MusicPlayerView()
#region Dance Floor

void InitDanceFloor()
{
// Uncomment if you'd like random spotlights instead
//AbsoluteLayout spotlights = GenerateRandomSpotlights();

AbsoluteLayout spotlights = new AbsoluteLayout()
{
Children =
{
new Spotlight(Colors.Blue, 200, 0, 0, 2000, MusicPlayer),
new Spotlight(Colors.Orange, 150, 0.8, 0.9, 1000, MusicPlayer),
new Spotlight(Colors.Pink, 100, 0.9, 0.2, 500, MusicPlayer),
new Spotlight(Colors.Yellow, 120, 0.3, 0.6, 1500, MusicPlayer),
}
};

TopLayout.Add(spotlights);
TopLayout.Add(new Image() { Source = "speakers.png" }.Bottom());
TopLayout.Add(new Image() { Source = "joyful_dancers.png" }.Bottom());
}

AbsoluteLayout GenerateRandomSpotlights()
{
AbsoluteLayout spotlights = new AbsoluteLayout();
Random randomGenerator = new Random();
Expand All @@ -130,9 +151,7 @@ void InitDanceFloor()
}
}

TopLayout.Add(spotlights);
TopLayout.Add(new Image() { Source = "speakers.png" }.Bottom());
TopLayout.Add(new Image() { Source = "joyful_dancers.png" }.Bottom());
return spotlights;
}

#endregion
Expand Down

0 comments on commit 23df859

Please sign in to comment.