public AboutForm() { InitializeComponent(); //This form is double buffered SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); //A random number generator for the initial setup var random = new Random(); const int count = 15; // We create white logo bitmaps for (var i = 0; i < count; i++) { var shape = new Picture(whiteLogoBitmap) { Limits = ClientRectangle, Location = new Point(random.Next(ClientRectangle.Width + 16), random.Next(ClientRectangle.Height + 16)), Size = new Size(1 + random.Next(100), 1 + random.Next(100)), BackColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), ForeColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), RotationDelta = random.Next(20), Transparency = (float)random.NextDouble(), LineThickness = random.Next(10), Vector = new Size(-10 + random.Next(20), -10 + random.Next(20)) }; //and added to the list of shapes shapes.Add(shape); } // We create azure logo bitmaps for (var i = 0; i < count; i++) { var shape = new Picture(azureLogoBitmap) { Limits = ClientRectangle, Location = new Point(random.Next(ClientRectangle.Width + 16), random.Next(ClientRectangle.Height + 16)), Size = new Size(1 + random.Next(100), 1 + random.Next(100)), BackColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), ForeColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), RotationDelta = random.Next(20), Transparency = (float)random.NextDouble(), LineThickness = random.Next(10), Vector = new Size(-10 + random.Next(20), -10 + random.Next(20)) }; //and added to the list of shapes shapes.Add(shape); } //set up the timer so that animation can take place timer.Interval = 40; timer.Tick += timer_Tick; timer.Enabled = true; }
private void AboutForm_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 'a') { return; } // Clear shapes collection shapes.Clear(); //A random number generator for the initial setup var random = new Random(); const int count = 15; for (var i = 0; i < count; i++) { var shape = new Picture(heartBitmap) { Limits = ClientRectangle, Location = new Point(random.Next(ClientRectangle.Width + 16), random.Next(ClientRectangle.Height + 16)), Size = new Size(1 + random.Next(100), 1 + random.Next(100)), BackColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), ForeColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), RotationDelta = random.Next(20), Transparency = (float)random.NextDouble(), LineThickness = random.Next(10), Vector = new Size(-10 + random.Next(20), -10 + random.Next(20)) }; //and added to the list of shapes shapes.Add(shape); } }