void OnTabMessage(TabMessage message) { switch (message.Action) { case TabMessage.ActionType.Add: Add(message.Tab); break; case TabMessage.ActionType.Edit: Edit(message.Tab); break; case TabMessage.ActionType.Remove: Remove(message.Tab); break; case TabMessage.ActionType.Move: Move(message.Tab, message.TabB); break; case TabMessage.ActionType.MoveUp: ReorderTabs(message.Tab, true); break; case TabMessage.ActionType.MoveDown: ReorderTabs(message.Tab, false); break; } }
private void HandleTab(TabMessage tabMessage) { string id = tabMessage.Id ?? tabMessage.ViewModel?.Id; var item = Tabs.FirstOrDefault(x => x.Id == id); switch (tabMessage.Action) { case TabMessageAction.BringToFront: SelectedTab = item; break; case TabMessageAction.Close: Tabs.Remove(item); break; case TabMessageAction.Create: if (item == null) { item = tabMessage.ViewModel; Tabs.Add(tabMessage.ViewModel); } SelectedTab = item; break; } }
private void Close() { var message = new TabMessage { Id = this.Id, Action = TabMessageAction.Close }; this.MessengerInstance.Send(message); }
private async void ShowStatsAsync() { var statsViewModel = ServiceLocator.Current.GetInstance <StatsViewModel>(); var task = statsViewModel.CalulateForAsync(_leagueKey, _seasonKey); string caption = $"stats-{_leagueKey}-{_seasonKey}"; string tooltip = "Stats for season ..."; var tabViewModel = new TabItemViewModel(caption, caption, tooltip, statsViewModel); var message = new TabMessage { Action = TabMessageAction.Create, ViewModel = tabViewModel, }; await task; this.MessengerInstance.Send(message); }
public async void OpenSeasonActionAsync() { var league = this; var matchs = await _openLigaService.LoadMatchesAsync(league.LeagueKey, league.SeasonKey); var matchViewModels = MatchViewModel.FromMatchs(matchs); var seasonViewModel = SeasonViewModel.From(matchViewModels, league.LeagueKey, league.SeasonKey); var tabViewModel = new TabItemViewModel(league.ShortDisplayName, league.ShortDisplayName, league.LongDisplayName, seasonViewModel, true); var message = new TabMessage { Action = TabMessageAction.Create, ViewModel = tabViewModel }; this.MessengerInstance.Send(message); }
private async void LoadTeamsActionAsync() { var teamsViewModel = ServiceLocator.Current.GetInstance <TeamsOfLeagueViewModel>(); var task = teamsViewModel.LoadTeamsAsync(this); var label = $"Teams-{ShortDisplayName}"; var tooltip = $"Teams of {LongDisplayName}"; var tabViewModel = new TabItemViewModel(label, label, tooltip, teamsViewModel, true); var tabMessage = new TabMessage { ViewModel = tabViewModel, Action = TabMessageAction.Create, }; await task; this.MessengerInstance.Send(tabMessage); }