예제 #1
0
        public void TestRemovePlayers()
        {
            LMTeam t = LMTeam.DefaultTemplate(15);

            t.FormationStr = "1-2-3-4";

            /* Removing a player from the starting list must be swapped
             * with the first player in the bench to keep the same lineup */
            t.RemovePlayers(new List <LMPlayer> {
                t.Players [0]
            }, false);
            Assert.AreEqual(15, t.Players.Count);
            Assert.AreEqual(11, t.Players [0].Number);
            Assert.AreEqual(2, t.Players [1].Number);
            Assert.AreEqual(1, t.Players [14].Number);
            t.RemovePlayers(new List <LMPlayer> {
                t.Players [0]
            }, true);
            Assert.AreEqual(14, t.Players.Count);
            Assert.AreEqual(12, t.Players [0].Number);

            t.RemovePlayers(new List <LMPlayer> {
                new LMPlayer()
            }, true);
            Assert.AreEqual(14, t.Players.Count);

            t.RemovePlayers(new List <LMPlayer> {
                new LMPlayer(), t.Players [12]
            }, true);
            Assert.AreEqual(13, t.Players.Count);
        }
예제 #2
0
        void HandleShowMenuEvent(List <LMPlayer> players)
        {
            Menu     menu = new Menu();
            MenuItem item;

            if (players.Count > 0)
            {
                item            = new MenuItem("Remove for this match");
                item.Activated += (sender, e) => {
                    //FIXME: this logic should be handled in a Controller (NewProjectController?)
                    // When this View is Ported fully to MVVM
                    hometemplate.RemovePlayers(players, false);
                    awaytemplate.RemovePlayers(players, false);
                    App.Current.EventsBroker.Publish(new UpdateLineup());
                };
            }
            else
            {
                item            = new MenuItem("Reset players");
                item.Activated += (sender, e) => {
                    //FIXME: this logic should be handled in a Controller (NewProjectController?)
                    // When this View is Ported fully to MVVM
                    hometemplate.ResetPlayers();
                    awaytemplate.ResetPlayers();
                    App.Current.EventsBroker.Publish(new UpdateLineup());
                };
            }
            menu.Add(item);
            menu.ShowAll();
            menu.Popup();
        }