/// <summary> /// Will add some random squashed mosquitoes on screen from a given parent control /// </summary> /// <param name="r"></param> public void ShowMosquito(RelativePanel inParentPanel, int r = 0) { Random random = new Random(DateTime.Now.Millisecond * DateTime.Now.Year / (DateTime.Now.Second + 1)); if (r == 0) { r = random.Next(0, 1000); } int mosquitoCount = random.Next(1, 15); if (r >= 40 && r <= 44) { while (mosquitoCount > 0) { int X = 0; int Y = 0; X = ((int)(random.Next(0, Convert.ToInt16(inParentPanel.ActualWidth)))); Y = ((int)(random.Next(0, Convert.ToInt16(inParentPanel.ActualHeight)))); CompositeTransform transform = new CompositeTransform(); transform.TranslateX = X; transform.TranslateY = Y; transform.Rotation = random.Next(0, 360); BitmapImage mosquitoSourceImage = new BitmapImage(new Uri("ms-appx:///Assets/mosquito.png")); Image newMosquito = new Image(); newMosquito.RenderTransform = transform; newMosquito.Source = mosquitoSourceImage; newMosquito.Height = 60; newMosquito.Width = 60; newMosquito.Name = "mosquito" + mosquitoCount.ToString(); newMosquito.Visibility = Visibility.Visible; inParentPanel.Children.Add(newMosquito); inParentPanel.UpdateLayout(); mosquitoCount--; } } }