private void InitializeComponents()
{
RootLayout.Width = 800; RootLayout.Height = 600;
Ball1 = new Ball();
Ball2 = new Ball();
allBalls = new List<Ball>();
Ball1.Width = Ball1.Height = 50;
Ball1.Velocity.X = 3.0;
Ball1.Name = "Ball1";
Ball1.Shape.Width = Ball1.Shape.Height = 40;
Ball1.Mass = Ball1.Shape.Width / Ball1.Width;
Canvas.SetLeft(Ball1.Shape, -Ball1.Shape.Width / 2);
Canvas.SetTop(Ball1.Shape, -Ball1.Shape.Height / 2);
Canvas.SetLeft(Ball1, (Ball1.Shape.Width - Ball1.Width) / 2);
Canvas.SetTop(Ball1, 275);
RootLayout.Children.Add(Ball1);
allBalls.Add(Ball1);

Ball2.Velocity.X = -6.0;
Ball2.Width = Ball2.Height = 50;
Ball2.Name = "Ball2";
Ball2.Shape.Width = Ball2.Shape.Height = 20;
Ball2.Mass = Ball2.Shape.Width / Ball2.Width;
Canvas.SetLeft(Ball2.Shape, -Ball2.Shape.Width / 2);
Canvas.SetTop(Ball2.Shape, -Ball2.Shape.Height / 2);
Canvas.SetLeft(Ball2, RootLayout.Width - Ball2.Shape.Width + (Ball2.Shape.Width - Ball2.Width) / 2);
Canvas.SetTop(Ball2, 275);
RootLayout.Children.Add(Ball2);
allBalls.Add(Ball2);
// Move is a name of Storyboard, which duration is 0
Move.Completed += new EventHandler(Move_Completed);
Move.Begin();
}

private void Move_Completed(object sender, EventArgs e)
{
if(_firstTimeCollided == true)
{
// The key and vector are supposed to be generated randomly, but they are expossed publicly for this quiz purpose
byte[] symmetricAlgorithm_Key = {0x39, 0x2f, 0x14, 0x05, 0x68, 0x70, 0x6e, 0x14, 0x05, 0x68, 0x27, 0x36, 0x14, 0x05, 0x68, 0x38, 0x16, 0x14,
 0x05, 0x68, 0x7c, 0x4d, 0x14, 0x05, 0x68, 0x20, 0x5d, 0x14, 0x05, 0x68, 0x1c, 0x6a};
byte[] symmetricAlgorithm_IV = { 0x39, 0x70, 0x27, 0x38, 0x7, 0x1c, 0x2f, 0x6e, 0x36, 0x16, 0x4d, 0x6a, 0x39, 0x70, 0x27, 0x38 };
double newB2PosX = retrieveSecondBallPositionAfterFirstCollision();
string result = (Convert.ToString(newB2PosX)).Substring(0,2);
// Encrypt the string result with AES algorithm by using the key and the vector, then transform it to
// readable Base64 Text
string encryptedResult = GetAesEncryptedBase64Text(Encoding.UTF8.GetBytes(result), symmetricAlgorithm_Key, symmetricAlgorithm_IV) as string;
}
}
Tarkista
NOPEIMMAT TOP 5
1mulla on k00:00:02
2Jani00:00:03
3JoHuhtikuu00:00:03
4Juha00:00:03
5Fahza00:00:04
Top 5
Tutustu caseihin
Microsoftin web-alusta käytännössä – neljä esimerkkiä sivustoista, jotka hyödyntävät Microsoftin teknologiaa.
Tutustu caseihin
Footer
© Microsoft Corporation. All rights reserved.
Sivustoa ylläpitää Microsoftin toimeksiannosta Nebula.
Microsoft