Пример #1
0
 public SubstitutionsEditor(Window parent)
 {
     TransientFor = parent;
     this.Build ();
     tagger = new TeamTagger (new WidgetWrapper (drawingarea));
     tagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
     tagger.PlayersSubstitutionEvent += HandlePlayersSubstitutionEvent;
     incanvas = new SelectionCanvas (new WidgetWrapper (drawingarea2));
     outcanvas = new SelectionCanvas (new WidgetWrapper (drawingarea3));
     inpo = new SportsPlayerObject ();
     outpo = new SportsPlayerObject ();
     inpo.ClickedEvent += HandleClickedEvent;
     outpo.ClickedEvent += HandleClickedEvent;
     inpo.Size = PLAYER_SIZE;
     outpo.Size = PLAYER_SIZE;
     inpo.Center = new Point (PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     outpo.Center = new Point (PLAYER_SIZE / 2, PLAYER_SIZE / 2);
     incanvas.AddObject (inpo);
     outcanvas.AddObject (outpo);
     drawingarea2.WidthRequest = drawingarea2.HeightRequest = PLAYER_SIZE;
     drawingarea3.WidthRequest = drawingarea3.HeightRequest = PLAYER_SIZE;
 }
Пример #2
0
        void Substitute(SportsPlayerObject p1, SportsPlayerObject p2,
		                 List<SportsPlayerObject> playingPlayers,
		                 List<SportsPlayerObject> benchPlayers)
        {
            Point tmpPos;
            List<SportsPlayerObject> p1List, p2List;

            if (playingPlayers.Contains (p1)) {
                p1List = playingPlayers;
            } else {
                p1List = benchPlayers;
            }
            if (playingPlayers.Contains (p2)) {
                p2List = playingPlayers;
            } else {
                p2List = benchPlayers;
            }

            if (p1List == p2List) {
                p1List.Swap (p1, p2);
            } else {
                int p1Index, p2Index;

                p1Index = p1List.IndexOf (p1);
                p2Index = p2List.IndexOf (p2);
                p1List.Remove (p1);
                p2List.Remove (p2);
                p1List.Insert (p1Index, p2);
                p2List.Insert (p2Index, p1);
            }
            tmpPos = p2.Center;
            p2.Center = p1.Center;
            p1.Center = tmpPos;
            ResetSelection ();
            EmitRedrawEvent (this, null);
        }
Пример #3
0
        List<SportsPlayerObject> GetPlayers(List<PlayerLongoMatch> players, TeamType team)
        {
            List<SportsPlayerObject> playerObjects;
            Color color = null;

            if (team == TeamType.LOCAL) {
                color = App.Current.Style.HomeTeamColor;
            } else {
                color = App.Current.Style.AwayTeamColor;
            }

            playerObjects = new List<SportsPlayerObject> ();
            foreach (var player in players) {
                SportsPlayerObject po = new SportsPlayerObject { Player = player, Team = team };
                po.ClickedEvent += HandlePlayerClickedEvent;
                po.RedrawEvent += (co, area) => {
                    EmitRedrawEvent (po, area);
                };
                playerObjects.Add (po);
                if ((team == TeamType.LOCAL) && !homePlayerToPlayerObject.ContainsKey (player)) {
                    homePlayerToPlayerObject.Add (player, po);
                } else if ((team == TeamType.VISITOR) && !awayPlayerToPlayerObject.ContainsKey (player)) {
                    awayPlayerToPlayerObject.Add (player, po);
                }
            }
            return playerObjects;
        }
Пример #4
0
        void EmitSubsitutionEvent(SportsPlayerObject player1, SportsPlayerObject player2)
        {
            SportsTeam team;
            List<SportsPlayerObject> bench;

            if (substitutionPlayer.Team == TeamType.LOCAL) {
                team = homeTeam;
                bench = homeBenchPlayers;
            } else {
                team = awayTeam;
                bench = awayBenchPlayers;
            }
            if (PlayersSubstitutionEvent != null) {
                if (bench.Contains (player1) && bench.Contains (player2)) {
                    PlayersSubstitutionEvent (team, player1.Player, player2.Player,
                        SubstitutionReason.BenchPositionChange, CurrentTime);
                } else if (!bench.Contains (player1) && !bench.Contains (player2)) {
                    PlayersSubstitutionEvent (team, player1.Player, player2.Player,
                        SubstitutionReason.PositionChange, CurrentTime);
                } else if (bench.Contains (player1)) {
                    PlayersSubstitutionEvent (team, player1.Player, player2.Player,
                        SubstitutionReason.PlayersSubstitution, CurrentTime);
                } else {
                    PlayersSubstitutionEvent (team, player2.Player, player1.Player,
                        SubstitutionReason.PlayersSubstitution, CurrentTime);
                }
            }
            ResetSelection ();
            UpdateLineup ();
        }
Пример #5
0
        public override void ClickPressed(Point point, ButtonModifier modif)
        {
            Selection selection = null;

            if (ButtonClickPressed (point, modif, subPlayers, subInjury,
                    homeButton, awayButton)) {
                return;
            }

            if (!SubstitutionMode && SelectionMode != MultiSelectionMode.Multiple) {
                if (SelectionMode == MultiSelectionMode.Single || modif == ButtonModifier.None) {
                    ResetSelection ();
                }
            }

            point = VASDrawing.Utils.ToUserCoords (point, offset, scaleX, scaleY);
            selection = homeBench.GetSelection (point, 0, false);
            if (selection == null) {
                selection = awayBench.GetSelection (point, 0, false);
                if (selection == null) {
                    selection = field.GetSelection (point, 0, false);
                }
            }
            if (selection != null) {
                clickedPlayer = selection.Drawable as SportsPlayerObject;
                if (SubstitutionMode && substitutionPlayer != null &&
                    clickedPlayer.Team != substitutionPlayer.Team) {
                    clickedPlayer = null;
                } else {
                    (selection.Drawable as ICanvasObject).ClickPressed (point, modif);
                }
            } else {
                clickedPlayer = null;
            }
        }
 static void RenderPlayer(IDrawingToolkit tk, PlayerLongoMatch p, Point imagePoint)
 {
     SportsPlayerObject po = new SportsPlayerObject (p);
     po.Position = imagePoint;
     po.Size = StyleConf.ListImageWidth - 2;
     po.Draw (tk, null);
     po.Dispose ();
 }