public void Initialize(MainWindow mainWindow, Bettor bettor) { _view = new MenuWindow(); _bettorClient = new BettorClientServiceClient(); _mainWindow = mainWindow; _bettor = bettor; // Get all seasons var seasons = _bettorClient.GetSeasons(); #region View and ViewModel _viewModel = new MenuWindowViewModel { Bettor = _bettor, Seasons = new ObservableCollection <Season>(seasons.ToList()), SelectedSeason = _selectedSeason ?? seasons.FirstOrDefault(), BettorRankingCommand = new RelayCommand(ExecuteBettorRankingCommand), MatchesCommand = new RelayCommand(ExecuteMatchesCommand), TeamsCommand = new RelayCommand(ExecuteTeamsCommand), }; _selectedSeason = _selectedSeason != null ? _viewModel.SelectedSeason : seasons.FirstOrDefault(); _view.DataContext = _viewModel; #endregion _mainWindow.Content = _view; _mainWindow.Width = 800; _mainWindow.Height = 600; }
/// <summary> /// create 50 rooms in menuwindow /// </summary> private void CreateRooms() { int n = 75; MenuWindowViewModel viewmodel = this.DataContext as MenuWindowViewModel; for (int i = 0; i < n; i++) { #region --- create room --- Button tmp = new Button(); Grid.SetColumn(tmp, i % 5); Grid.SetRow(tmp, i / 5); tmp.Margin = new Thickness(5); tmp.Command = viewmodel.SelectRoomCommand; tmp.CommandParameter = tmp; tmp.Background = Brushes.Blue; #endregion #region --- exit --- Button tmpchild = new Button(); tmpchild.MinWidth = 40; tmpchild.MinHeight = 15; tmpchild.Content = "Exit"; tmpchild.Visibility = Visibility.Hidden; tmpchild.Command = viewmodel.ExitCommand; tmpchild.CommandParameter = tmpchild; //tmpchild.AddHandler(Button.ClickEvent, new RoutedEventHandler(viewmodel.Exit)); tmp.Content = tmpchild; #endregion viewmodel.rooms.Add(tmp); gRooms.Children.Add(tmp); } }
public ClientNet(MenuWindowViewModel mw) { tcp = new TcpClient(); brickbreaker = new GameWindow(); brickbreakermodel = brickbreaker.DataContext as GameWindowViewModel; menuwindowmodel = mw; SetPauseParams(); }
public void Initialize(MainWindow mainWindow) { _mainWindow = mainWindow; #region View and ViewModel _view = new MenuWindow(); _viewModel = new MenuWindowViewModel { BettorCommand = new RelayCommand(ExecuteBettorCommand), TeamCommand = new RelayCommand(ExecuteTeamCommand), SeasonCommand = new RelayCommand(ExecuteSeasonCommand), MatchesCommand = new RelayCommand(ExecuteMatchesCommand) }; _view.DataContext = _viewModel; #endregion _mainWindow.Content = _view; _mainWindow.Show(); }