Esempio n. 1
0
        private void Warship_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Warship warship = (Warship)sender;

            if (warship.IsLeader == true)
            {
                warship.IsLeader = false;
            }
            else
            {
                warship.IsLeader = true;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 初始化4个warship,并填入collection
 /// </summary>
 public void InitWarships()
 {
     warships.Clear();
     canvas.Children.Clear();
     for (int i = 1; i < 5; i++)
     {
         Warship warship = new Warship();
         warship.Name = "ws_0" + i;
         Canvas.SetLeft(warship, 36.0 + 100.0 * i);
         Canvas.SetBottom(warship, 20.0);
         warship.MouseLeftButtonDown += Warship_MouseLeftButtonDown;
         warship.Speed = 100.0;
         canvas.Children.Add(warship);
         warships.Add(warship);
     }
     warships[warships.Count - 1].IsLeader = true;
 }