void HandleTeamTagging(LMTeamVM team, string taggedPlayer) { // limitation to the number of temporal contexts that can be created int position = taggedPlayer.Length; if (position == 3) { HandleTaggedPlayer(team, taggedPlayer); } KeyTemporalContext tempContext = new KeyTemporalContext { }; for (int i = 0; i < 10; i++) { string newTaggedPlayer = taggedPlayer + i; VKeyAction action = new VKeyAction(new KeyConfig { Name = taggedPlayer, Key = App.Current.Keyboard.ParseName(i.ToString()) }, () => HandleTeamTagging(team, newTaggedPlayer)); tempContext.AddAction(action); } tempContext.Duration = Constants.TEMP_TAGGING_DURATION; tempContext.ExpiredTimeAction = () => HandleTaggedPlayer(team, taggedPlayer); App.Current.KeyContextManager.AddContext(tempContext); }
public LMTeamTaggerVM() { HomeTeam = new LMTeamVM(); AwayTeam = new LMTeamVM(); ShowSubstitutionButtons = true; SelectionMode = MultiSelectionMode.Single; CurrentTime = new Time(0); }
void RenderIcon(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { LMTeamVM teamVM = (LMTeamVM)model.GetValue(iter, COL_TEAM); CellRendererImage renderer = (cell as CellRendererImage); renderer.Width = SHIELD_SIZE; renderer.Height = SHIELD_SIZE; renderer.Image = teamVM.Icon; }
void RenderIcon(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { LMTeamVM teamVM = (LMTeamVM)model.GetValue(iter, COL_TEAM); CellRendererImage renderer = (cell as CellRendererImage); renderer.Width = SHIELD_SIZE; renderer.Height = SHIELD_SIZE; renderer.Image = teamVM.Icon ?? App.Current.ResourcesLocator.LoadIcon(Icons.DefaultShield); renderer.MaskColor = teamVM.Icon == null ? Colors.DefaultShield : null; }
void UpdatePlayTeams(LMTeamVM team) { if (team.Tagged && !playEditor.Play.Teams.Contains(team.Model)) { playEditor.Play.Teams.Add(team.Model); } else if (!team.Tagged && playEditor.Play.Teams.Contains(team.Model)) { playEditor.Play.Teams.Remove(team.Model); } }
protected override TeamVM CreateInstance(Team model) { LMTeamVM lMTeamVM = new LMTeamVM { Model = (LMTeam)model }; if (model.Static) { StaticViewModels.Add(lMTeamVM); } return(lMTeamVM); }
void UpdatePlayTeams(LMTeamVM team) { //FIXME: this is using playEditorVM.Play as Model, it should use TimelineEventVM, //when the PlayEditor view is fully migrated to MVVM if (team.Tagged && !playEditorVM.Play.Teams.Contains(team.Model)) { playEditorVM.Play.Teams.Add(team.Model); } else if (!team.Tagged && playEditorVM.Play.Teams.Contains(team.Model)) { playEditorVM.Play.Teams.Remove(team.Model); } }
public void OneTimeSetUp() { SetupClass.SetUp(); Mock <IGUIToolkit> mockGuiToolkit = new Mock <IGUIToolkit> (); mockGuiToolkit.Setup(m => m.DeviceScaleFactor).Returns(1); App.Current.GUIToolkit = mockGuiToolkit.Object; eventsFilterController = new LMEventsFilterController(); homeTeam = new LMTeamVM { Model = LMTeam.DefaultTemplate(2) }; awayTeam = new LMTeamVM { Model = LMTeam.DefaultTemplate(3) }; }
protected override void UpdateTeamsPredicates() { bool oldIgnoreEvents = ViewModel.Filters.IgnoreEvents; ViewModel.Filters.IgnoreEvents = true; ViewModel.TeamsPredicate.Clear(); var teamsPredicates = new List <IPredicate <TimelineEventVM> > (); LMTimelineVM lmTimeline = (LMTimelineVM)ViewModel; LMTeamVM homeTeamVM = (LMTeamVM)lmTimeline.HomeTeamTimelineVM.Team; LMTeamVM awayTeamVM = (LMTeamVM)lmTimeline.AwayTeamTimelineVM.Team; teamsPredicates.Add(new Predicate { Name = Catalog.GetString("No team / player tagged"), Expression = ev => (!(ev.Model as LMTimelineEvent).Teams.Any() && !(ev.Model as LMTimelineEvent).Players.Any()) }); foreach (var team in new LMTeamVM [] { homeTeamVM, awayTeamVM }) { var playersPredicates = new List <IPredicate <TimelineEventVM> > (); var teamPredicate = new OrPredicate <TimelineEventVM> { Name = team.Name, }; playersPredicates.Add(new Predicate { Name = Catalog.GetString("Team tagged"), Expression = ev => (ev.Model as LMTimelineEvent).Teams.Contains(team.Model) }); foreach (var player in team) { playersPredicates.Add(new Predicate { Name = player.Model.Name, Expression = ev => (ev.Model as LMTimelineEvent).Players.Contains(player.Model) }); } teamPredicate.AddRange(playersPredicates); teamsPredicates.Add(teamPredicate); } ViewModel.TeamsPredicate.AddRange(teamsPredicates); ViewModel.Filters.IgnoreEvents = oldIgnoreEvents; if (!ViewModel.Filters.IgnoreEvents) { ViewModel.Filters.EmitPredicateChanged(); } }
void HandleTaggedPlayer(LMTeamVM team, string taggedPlayer) { if (taggedPlayer != string.Empty) { PlayerVM player = team.ViewModels.FirstOrDefault(x => ((LMPlayerVM)x).Number == Convert.ToInt32(taggedPlayer)); if (player != null) { App.Current.EventsBroker.Publish(new TagPlayerEvent { Player = player, Team = team, Modifier = ButtonModifier.None, Sender = player }); } } }
public TeamsManagerVM() { LoadedTemplate = new LMTeamVM(); NewCommand.Icon = App.Current.ResourcesLocator.LoadIcon("vas-add", StyleConf.TemplatesIconSize); SaveCommand.Icon = App.Current.ResourcesLocator.LoadIcon("vas-save", StyleConf.TemplatesIconSize); DeleteCommand.Icon = App.Current.ResourcesLocator.LoadIcon("vas-delete", StyleConf.TemplatesIconSize); ExportCommand.Icon = App.Current.ResourcesLocator.LoadIcon("lm-export", StyleConf.TemplatesIconSize); ImportCommand.Icon = App.Current.ResourcesLocator.LoadIcon("vas-import", StyleConf.TemplatesIconSize); TeamTagger = new LMTeamTaggerVM(); TeamTagger.HomeTeam = (LMTeamVM)LoadedTemplate; TeamTagger.AwayTeam = null; TeamTagger.Background = App.Current.HHalfFieldBackground; TeamTagger.SelectionMode = MultiSelectionMode.MultipleWithModifier; TeamEditor = new LMTeamEditorVM(); TeamEditor.Team = (LMTeamVM)LoadedTemplate; TeamEditor.Team.TemplateEditorMode = true; }
void EmitSubstitutionEvent(LMPlayerVM player1, LMPlayerVM player2, LMTeamVM team) { if (isAnalysis) { SubstitutionReason reason; var player1Model = player1.Model; var player2Model = player2.Model; if (team.BenchPlayersList.Contains(player1) && team.BenchPlayersList.Contains(player2)) { reason = SubstitutionReason.BenchPositionChange; } else if (!team.BenchPlayersList.Contains(player1) && !team.BenchPlayersList.Contains(player2)) { reason = SubstitutionReason.PositionChange; } else if (team.BenchPlayersList.Contains(player1)) { reason = SubstitutionReason.PlayersSubstitution; } else { player1Model = player2.Model; player2Model = player1.Model; reason = SubstitutionReason.PlayersSubstitution; } App.Current.EventsBroker.Publish(new PlayerSubstitutionEvent { Team = team.Model, Player1 = player1Model, Player2 = player2Model, SubstitutionReason = reason, Time = teamTagger.CurrentTime }); UpdateLineup(); } else { team.SubViewModel.ViewModels.Swap(player1, player2); ChangeLineUp(team); } ClearSelection(); }
void ChangeLineUp(LMTeamVM team, IEnumerable <LMPlayerVM> players = null) { if (players == null) { players = team.CalledPlayersList; } var fieldPlayers = players.Take(team.Model.StartingPlayers); foreach (var player in fieldPlayers) { player.Playing = true; } var benchPlayers = players.Except(fieldPlayers); foreach (var player in benchPlayers) { player.Playing = false; } team.FieldPlayersList = fieldPlayers; team.BenchPlayersList = benchPlayers; }
void RenderTemplateName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { LMTeamVM teamVM = (LMTeamVM)model.GetValue(iter, COL_TEAM); (cell as CellRendererText).Text = teamVM.Name; }