예제 #1
0
        private UICollectionSynchronizer(IList<CardViewModel> collection, INotifyCollectionChanged collectionChanged, StackLayout stackLayout, GamePageModel gamePageModel)
        {
            this.stackLayout = stackLayout;
            this.gamePageModel = gamePageModel;
            ((INotifyCollectionChanged)collection).CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => {
                if (e.Action == NotifyCollectionChangedAction.Reset) {
                    this.stackLayout.Children.Clear ();
                    this.mapper.Clear ();
                } else {
                    if(e.OldItems != null)
                    {
                        foreach (CardViewModel card in e.OldItems) {
                            this.RemoveItem(card);
                        }
                    }

                    if(e.NewItems != null)
                    {
                        foreach (CardViewModel card in e.NewItems) {
                            this.AddItem(card);
                        }
                    }
                }
            };
            foreach (CardViewModel card in collection) {
                this.AddItem (card);
            }
        }
예제 #2
0
        public GamePage()
        {
            InitializeComponent();

            BindingContext = new GamePageModel();

            SetValue(NavigationPage.HasNavigationBarProperty, false);

            d = new DirectoryInfo(Pytania.dataDir);

            if (d.Exists)
            {
                ViewModel.LoadQuestions();
                lbl.Text = "Stuknij w ekran, aby kontynuować";
            }
        }
예제 #3
0
        public ActionResult GAME(int id)
        {
            if (User.IsInRole("Judge"))
            {
                if (id == 0)
                {
                    //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                var GamePageModel = new GamePageModel();

                //GAME ID CHANGES BASED ON WHATEVER IS PASSED THROUGH CONTROLLER
                //1 IS A TEST VALUE
                var GAME = (from a in db.GAMES where a.GameID == id select a).FirstOrDefault();
                //Count the amount of teams
                //Where function will have to change based on competition
                //Create variable "i" to count with each competition so it can find amount of teams attached to each competition
                //Attach "i" to the where function



                GamePageModel.Desc   = GAME.Desc;
                GamePageModel.GameID = GAME.GameID;
                GamePageModel.Name   = GAME.Name;
                foreach (var c in db.Competitions.Where(a => a.GameID == 1).ToList())
                {
                    int i = 0;
                    foreach (var s in db.StudentTeams.Where(a => a.CompID == c.CompID))
                    {
                        i++;
                    }
                    var Competition          = (from a in db.Competitions where a.CompID == c.CompID select a).FirstOrDefault();
                    var CompetitionPageModel = new CompetitionPageModel();
                    CompetitionPageModel.CompID    = Competition.CompID;
                    CompetitionPageModel.Date      = Competition.Date;
                    CompetitionPageModel.Location  = Competition.Location;
                    CompetitionPageModel.ExtraData = Competition.ExtraData;
                    CompetitionPageModel.TeamCount = i;
                    GamePageModel.Competitions.Add(CompetitionPageModel);
                }

                return(View(GamePageModel));
            }
            else
            {
                return(View("IsNotAuthenticated"));
            }
        }
예제 #4
0
        public GamePage()
        {
            App.CurrentGame = new LocalGame ();
            Kingdom kingdom = new Kingdom (null, null, GameSets.Any, 2);
            App.CurrentGame.GamePageModel.Kingdom = kingdom;
            App.CurrentGame.PlayGame ();

            this.gamePageModel = App.CurrentGame.GamePageModel;
            this.BindingContext = this.gamePageModel;
            InitializeComponent ();
            App.CurrentGame.GamePageModel.GameViewModel.GameInitialized += (object sender, EventArgs e) => Device.BeginInvokeOnMainThread(() => this.OnGameStarted());

            App.CurrentGame.GamePageModel.GameViewModel.TextLog.Turns.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
                if(e.NewItems != null)
                {
                    foreach(LogTurn turn in e.NewItems)
                    {
                        turn.Lines.CollectionChanged += (object sender2, NotifyCollectionChangedEventArgs e2) => {
                            if(e2.NewItems != null)
                            {
                                foreach(string line in e2.NewItems)
                                {
                                    Label turnLabel = new Label() { Text = line };
                                    this.TextLog.Children.Add(turnLabel);
                                    this.LogScrollViewer.ScrollToAsync(turnLabel, ScrollToPosition.MakeVisible, true);
                                }
                            }
                        };
                        foreach(string line in turn.Lines)
                        {
                            Label turnLabel = new Label() { Text = line };
                            this.TextLog.Children.Add(turnLabel);
                            this.LogScrollViewer.ScrollToAsync(turnLabel, ScrollToPosition.MakeVisible, true);
                        }
                    }
                }
            };
        }
예제 #5
0
 public UICollectionSynchronizer(ObservableCollection<CardViewModel> collection, StackLayout stackLayout, GamePageModel gamePageModel)
     : this(collection, collection, stackLayout, gamePageModel)
 {
 }
예제 #6
0
 private void HookModel(GamePageModel model)
 {
     this.gamePageModel = model;
     this.DataContext = this.gamePageModel;
     this.gamePageModel.GameViewModel.TextLog.PropertyChanged += TextLog_PropertyChanged;
     this.gamePageModel.GameException += gamePageModel_GameException;
     if (model.GameViewModel.GameModel.ExtraPiles.Count == 0 && this.gamePageModel.GameViewModel.GameModel.Has10KingdomPiles)
     {
         Grid.SetRow(this.CardScrollViewer, 2);
         Grid.SetRowSpan(this.CardScrollViewer, 4);
     }
     else
     {
         Grid.SetRow(this.CardScrollViewer, 3);
         Grid.SetRowSpan(this.CardScrollViewer, 3);
     }
 }
예제 #7
0
 private void StartLocalGame()
 {
     this.gamePageModel = new LocalGamePageModel();
     this.gamePageModel.Kingdom = new Kingdom(null, null, GameSets.Any, 2);
     this.gamePageModel.SetupGame();
     this.gameViewModel = this.gamePageModel.GameViewModel;
     ((App)App.Current).GameViewModel = this.gameViewModel;
     ((App)App.Current).GamePageModel = this.gamePageModel;
     this.LayoutRoot.DataContext = this.gamePageModel;
     this.gamePageModel.GameViewModel.GameModel.GameInitialized += GameModel_GameInitialized;
     Thread thread = new Thread(new ThreadStart(this.gamePageModel.PlayGame));
     thread.Start();
 }
예제 #8
0
 private void Model_ServerGameStarted(object sender, EventArgs e)
 {
     this.gamePageModel = App.CurrentGame.GamePageModel;
     this.gameViewModel = this.gamePageModel.GameViewModel;
     this.LayoutRoot.DataContext = App.CurrentGame.GamePageModel;
     this.gamePageModel.GameViewModel.GameModel.GameInitialized += GameModel_GameInitialized;
     this.gamePageGrid.Visibility = System.Windows.Visibility.Visible;
 }
예제 #9
0
 public GamePage()
 {
     InitializeComponent();
     BindingContext = new GamePageModel(Navigation);
     auth           = DependencyService.Get <IAuth>();
 }
예제 #10
0
 private void HookModel(GamePageModel model)
 {
     this.gamePageModel = model;
     this.DataContext = this.gamePageModel;
     this.gamePageModel.GameViewModel.TextLog.PropertyChanged += TextLog_PropertyChanged;
     this.gamePageModel.GameException += gamePageModel_GameException;
 }