public void ReloadStats(PlayerLongoMatch player) { PlayerStats playerStats; TreeIter iter; TreePath selected = null; playerStats = pstats.GetPlayerStats (player); treeview.Selection.GetSelected (out iter); if (store.IterIsValid (iter)) selected = store.GetPath (iter); store.Clear (); foreach (PlayerEventTypeStats petats in playerStats.PlayerEventStats) { store.AppendValues (petats, petats.EventType.Name); } /* Keep the selected category for when we reload the stats changing players */ if (selected != null) { store.GetIter (out iter, selected); } else { store.GetIterFirst (out iter); } treeview.Selection.SelectIter (iter); categoryviewer.LoadStats (store.GetValue (iter, 0) as PlayerEventTypeStats); }
public void TestToString() { PlayerLongoMatch player = new PlayerLongoMatch { Name = "andoni", LastName = "morales", Number = 1 }; Assert.AreEqual ("1-andoni morales", player.ToString ()); player.NickName = "ylatuya"; Assert.AreEqual ("1-ylatuya", player.ToString ()); }
public PlayersFilterTreeView() : base() { visitorTeam = new PlayerLongoMatch (); localTeam = new PlayerLongoMatch (); HeadersVisible = false; }
public void TestPhoto() { PlayerLongoMatch player = new PlayerLongoMatch {Name = "andoni", Position = "runner", Number = 5, Birthday = new DateTime (1984, 6, 11), Nationality = "spanish", Height = 1.73f, Weight = 70, Playing = true }; player.Photo = Utils.LoadImageFromFile (); Utils.CheckSerialization (player); Assert.AreEqual (player.Photo.Width, 16); Assert.AreEqual (player.Photo.Height, 16); }
public PlayerStats(ProjectLongoMatch project, EventsFilter filter, PlayerLongoMatch player) { this.project = project; this.filter = filter; this.Player = player; PlayerEventStats = new List<PlayerEventTypeStats> (); foreach (EventType evtType in project.EventTypes) { if (!(evtType is SubstitutionEventType)) { PlayerEventStats.Add (new PlayerEventTypeStats (project, filter, player, evtType)); } } UpdateTimePlayed (); }
public void TestSerialization() { PlayerLongoMatch player = new PlayerLongoMatch {Name = "andoni", Position = "runner", Number = 5, Birthday = new DateTime (1984, 6, 11), Nationality = "spanish", Height = 1.73f, Weight = 70, Playing = true, Mail = "test@test", Color = Color.Red }; Utils.CheckSerialization (player); PlayerLongoMatch newPlayer = Utils.SerializeDeserialize (player); Assert.AreEqual (player.Name, newPlayer.Name); Assert.AreEqual (player.Position, newPlayer.Position); Assert.AreEqual (player.Number, newPlayer.Number); Assert.AreEqual (player.Birthday, newPlayer.Birthday); Assert.AreEqual (player.Nationality, newPlayer.Nationality); Assert.AreEqual (player.Height, newPlayer.Height); Assert.AreEqual (player.Weight, newPlayer.Weight); Assert.AreEqual (player.Playing, newPlayer.Playing); Assert.AreEqual (player.Mail, newPlayer.Mail); Assert.IsNull (newPlayer.Color); }
public void TestPlayingPlayers() { SportsTeam t = new SportsTeam (); PlayerLongoMatch p1, p2, p3; t.Name = "test"; t.TeamName = "team"; Assert.AreEqual (t.PlayingPlayersList.Count, 0); p1 = new PlayerLongoMatch { Name = "P1", Playing = true }; p2 = new PlayerLongoMatch { Name = "P2", Playing = false }; p3 = new PlayerLongoMatch { Name = "P3", Playing = true }; t.List.Add (p1); Assert.AreEqual (t.PlayingPlayersList.Count, 1); t.List.Add (p2); Assert.AreEqual (t.PlayingPlayersList.Count, 1); t.List.Add (p3); Assert.AreEqual (t.PlayingPlayersList.Count, 2); Assert.AreEqual (t.PlayingPlayersList [0], p1); Assert.AreEqual (t.PlayingPlayersList [1], p3); }
public SportsPlayerObject(PlayerLongoMatch player, Point position = null) { // Set the base Player too, because it's a different Property base.Player = Player = player; Init (position); }
Pixbuf PlayerPhoto(PlayerLongoMatch p) { Pixbuf playerImage; if (p.Photo != null) { playerImage = p.Photo.Value; } else { playerImage = Misc.LoadIcon ("longomatch-player-pic", 45, IconLookupFlags.ForceSvg); } return playerImage; }
public SubstitutionEvent SubsitutePlayer(SportsTeam team, PlayerLongoMatch playerIn, PlayerLongoMatch playerOut, SubstitutionReason reason, Time subsTime) { LineupEvent lineup; SubstitutionEvent se; lineup = Timeline.OfType<LineupEvent> ().FirstOrDefault (); if (lineup == null) { throw new SubstitutionException (Catalog.GetString ("No lineup events found")); } if (subsTime < lineup.EventTime) { throw new SubstitutionException (Catalog.GetString ("A substitution can't happen before the lineup event")); } se = new SubstitutionEvent (); se.EventType = SubstitutionsEventType; se.In = playerIn; se.Out = playerOut; se.Reason = reason; se.EventTime = subsTime; se.Teams.Add (team); Timeline.Add (se); return se; }
void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2, SubstitutionReason reason, Time time) { widget?.ReDraw (); if (PlayersSubstitutionEvent != null) { PlayersSubstitutionEvent (team, p1, p2, reason, time); } }
List<ProjectLongoMatch> CreateProjects() { PlayerLongoMatch andoni = new PlayerLongoMatch { Name = "Andoni" }; PlayerLongoMatch jorge = new PlayerLongoMatch { Name = "Jorge" }; PlayerLongoMatch victor = new PlayerLongoMatch { Name = "Victor" }; PlayerLongoMatch josep = new PlayerLongoMatch { Name = "Josep" }; PlayerLongoMatch davide = new PlayerLongoMatch { Name = "Davide" }; PlayerLongoMatch saray = new PlayerLongoMatch { Name = "Saray" }; PlayerLongoMatch ivan = new PlayerLongoMatch { Name = "Ivan" }; PlayerLongoMatch adria = new PlayerLongoMatch { Name = "Adria" }; SportsTeam devteam = new SportsTeam { Name = "DevTeam" }; SportsTeam qateam = new SportsTeam { Name = "QA" }; devteam.List.AddRange (new List<PlayerLongoMatch> { andoni, jorge, victor, josep, davide }); qateam.List.AddRange (new List<PlayerLongoMatch> { saray, ivan, adria }); DashboardLongoMatch dashbaord = DashboardLongoMatch.DefaultTemplate (5); var projects = new List<ProjectLongoMatch> (); for (int i = 0; i < 5; i++) { ProjectLongoMatch p = new ProjectLongoMatch (); p.Dashboard = dashbaord.Clone (); p.LocalTeamTemplate = devteam; p.VisitorTeamTemplate = qateam; p.Description = new ProjectDescription (); foreach (var player in devteam.List.Concat (qateam.List)) { foreach (var button in p.Dashboard.List.OfType<AnalysisEventButton> ()) { TimelineEventLongoMatch evt = p.AddEvent (button.EventType, new Time (0), new Time (10), new Time (5), null) as TimelineEventLongoMatch; evt.Players.Add (player); if (qateam.List.Contains (player)) { evt.Teams.Add (qateam); } else { evt.Teams.Add (devteam); } } } projects.Add (p); storage.Store (p); } return projects; }
void HandleCursorChanged(object sender, EventArgs e) { TreeIter iter; treeview1.Selection.GetSelected (out iter); current = store.GetValue (iter, 1) as PlayerLongoMatch; if (current != null) { categoriesviewer.ReloadStats (current); } }
void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2, SubstitutionReason reason, Time time) { tagger.Substitute (p1, p2, team); if (team.ID == homeTeam.ID) { homeTeam.List.Swap (p1, p2); } else { awayTeam.List.Swap (p1, p2); } }
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 (); }
public void TagPlayer(PlayerLongoMatch player) { teamtagger.Select (player); }
public static void RenderSubstitution(Color color, Time evt, PlayerLongoMatch playerIn, PlayerLongoMatch playerOut, bool selected, bool isExpanded, IDrawingToolkit tk, IContext context, Area backgroundArea, Area cellArea, CellState state) { Point selectPoint, textPoint, imagePoint, circlePoint; Point inPoint, imgPoint, outPoint, timePoint; double textWidth; if (subsImage == null) { subsImage = Resources.LoadImage (StyleConf.SubsIcon); } tk.Context = context; tk.Begin (); RenderTimelineEventBase (color, null, selected, null, tk, context, backgroundArea, cellArea, state, out selectPoint, out textPoint, out imagePoint, out circlePoint, out textWidth); inPoint = textPoint; imgPoint = new Point (textPoint.X + StyleConf.ListImageWidth + StyleConf.ListRowSeparator, textPoint.Y); outPoint = new Point (imgPoint.X + 20 + StyleConf.ListRowSeparator, imgPoint.Y); RenderPlayer (tk, playerIn, inPoint); tk.DrawImage (imgPoint, 20, cellArea.Height, subsImage, ScaleMode.AspectFit); RenderPlayer (tk, playerOut, outPoint); timePoint = new Point (outPoint.X + StyleConf.ListImageWidth + StyleConf.ListRowSeparator, textPoint.Y); tk.FontSize = 10; tk.FontWeight = FontWeight.Normal; tk.StrokeColor = App.Current.Style.PaletteSelected; tk.FontAlignment = FontAlignment.Left; tk.DrawText (timePoint, 100, cellArea.Height, evt.ToSecondsString ()); RenderSeparationLine (tk, context, backgroundArea); tk.End (); }
public static void RenderPlayer(PlayerLongoMatch player, int count, bool isExpanded, IDrawingToolkit tk, IContext context, Area backgroundArea, Area cellArea) { Point image, text; double textWidth; image = new Point (StyleConf.ListTextOffset, cellArea.Start.Y); text = new Point (image.X + StyleConf.ListRowSeparator + StyleConf.ListImageWidth, cellArea.Start.Y); textWidth = cellArea.Start.X + cellArea.Width - text.X; tk.Context = context; tk.Begin (); RenderBackgroundAndText (isExpanded, tk, backgroundArea, text, textWidth, player.ToString ()); /* Photo */ RenderPlayer (tk, player, image); RenderCount (isExpanded, player.Color, count, tk, backgroundArea, cellArea); RenderSeparationLine (tk, context, backgroundArea); tk.End (); }
public void TestQueryEventsByNoPlayerOrTeam() { PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" }; TimelineEventLongoMatch evt = new TimelineEventLongoMatch (); evt.Players.Add (messi); storage.Store (evt); evt = new TimelineEventLongoMatch (); storage.Store (evt); QueryFilter filter = new QueryFilter (); PlayerLongoMatch nullPlayer = null; SportsTeam nullTeam = null; filter.Add ("Player", nullPlayer); Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter = new QueryFilter (); filter.Add ("Team", nullTeam); Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter = new QueryFilter (); QueryFilter teamsAndPlayersFilter = new QueryFilter { Operator = QueryOperator.Or }; filter.Children.Add (teamsAndPlayersFilter); teamsAndPlayersFilter.Add ("Team", nullTeam); teamsAndPlayersFilter.Add ("Player", nullPlayer); filter.Operator = QueryOperator.Or; Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); }
public void Select(PlayerLongoMatch player, bool silent = false, bool reset = false) { SportsPlayerObject po; po = homePlayers.FirstOrDefault (p => p.Player == player); if (po == null) { po = awayPlayers.FirstOrDefault (p => p.Player == player); } if (po != null) { if (reset) { ResetSelection (); } SelectedPlayers.Add (player); po.Active = true; if (!silent && PlayersSelectionChangedEvent != null) { PlayersSelectionChangedEvent (SelectedPlayers); } } }
public void Substitute(PlayerLongoMatch p1, PlayerLongoMatch p2, SportsTeam team) { tagger.Substitute (p1, p2, team); }
public void Substitute(PlayerLongoMatch p1, PlayerLongoMatch p2, SportsTeam team) { if (team == homeTeam) { Substitute (homePlayers.FirstOrDefault (p => p.Player == p1), homePlayers.FirstOrDefault (p => p.Player == p2), homePlayingPlayers, homeBenchPlayers); } else { Substitute (awayPlayers.FirstOrDefault (p => p.Player == p1), awayPlayers.FirstOrDefault (p => p.Player == p2), awayPlayingPlayers, awayBenchPlayers); } }
void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2, SubstitutionReason reason, Time time) { team.List.Swap (p1, p2); teamtagger.Substitute (p1, p2, team); Edited = true; }
void SwitchPlayer(PlayerLongoMatch inPlayer, PlayerLongoMatch outPlayer) { if (inPlayer != null) { this.inPlayer = inPlayer; inpo.Player = inPlayer; inpo.Active = false; drawingarea2.QueueDraw (); tagger.ResetSelection (); } else { inframe.Visible = false; } if (outPlayer != null) { this.outPlayer = outPlayer; outpo.Player = outPlayer; outpo.Active = false; drawingarea3.QueueDraw (); tagger.ResetSelection (); } else { outframe.Visible = false; } selectedPlayer = null; }
void LoadPlayer(PlayerLongoMatch p) { ignoreChanges = true; loadedPlayer = p; nameentry.Text = p.Name ?? ""; lastnameentry.Text = p.LastName ?? ""; nicknameentry.Text = p.NickName ?? ""; positionentry.Text = p.Position ?? ""; numberspinbutton.Value = p.Number; heightspinbutton.Value = p.Height; weightspinbutton.Value = p.Weight; nationalityentry.Text = p.Nationality ?? ""; bdaydatepicker.Date = p.Birthday; mailentry.Text = p.Mail ?? ""; playerimage.Pixbuf = PlayerPhoto (p); playerframe.Sensitive = true; ignoreChanges = false; }
void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2, SubstitutionReason reason, Time time) { App.Current.EventsBroker.Publish<PlayerSubstitutionEvent> ( new PlayerSubstitutionEvent { Team = team, Player1 = p1, Player2 = p2, SubstitutionReason = reason, Time = time } ); }
public void TestQueryEventsByPlayer() { PlayerLongoMatch andoni = new PlayerLongoMatch { Name = "Andoni" }; PlayerLongoMatch jorge = new PlayerLongoMatch { Name = "Jorge" }; PlayerLongoMatch victor = new PlayerLongoMatch { Name = "Victor" }; PlayerLongoMatch josep = new PlayerLongoMatch { Name = "Josep" }; PlayerLongoMatch davide = new PlayerLongoMatch { Name = "Davide" }; PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" }; PlayerLongoMatch ukelele = new PlayerLongoMatch { Name = "ukelele" }; var players = new List<PlayerLongoMatch> { andoni, jorge, victor, josep, davide }; foreach (PlayerLongoMatch player in players) { TimelineEventLongoMatch evt = new TimelineEventLongoMatch (); evt.Players.Add (player); evt.Players.Add (messi); storage.Store (evt); } QueryFilter filter = new QueryFilter (); filter.Add ("Player", messi); Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter.Add ("Player", andoni); Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter.Add ("Player", andoni, jorge, josep); Assert.AreEqual (3, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter.Add ("Player", victor, ukelele); Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); filter.Add ("Player", players); Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ()); }
void ClearPlayer() { ignoreChanges = true; playerframe.Sensitive = false; loadedPlayer = null; nameentry.Text = ""; lastnameentry.Text = ""; nicknameentry.Text = ""; positionentry.Text = ""; numberspinbutton.Value = 0; heightspinbutton.Value = 0; weightspinbutton.Value = 0; nationalityentry.Text = ""; bdaydatepicker.Date = new DateTime (); mailentry.Text = ""; playerimage.Pixbuf = playerimage.Pixbuf = Helpers.Misc.LoadIcon ("longomatch-player-pic", 45, IconLookupFlags.ForceSvg); ignoreChanges = false; }
public void Select(PlayerLongoMatch p) { tagger.Select (p); }