Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Create a new imagepicker
            imagePicker = new UIImagePickerController();
            imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
            imagePicker.Canceled             += Handle_Canceled;
            imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
            imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);

            //Adds a tapgesture to the imageview
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(TapProfileImageView);

            profileImage.AddGestureRecognizer(tapGesture);

            //Dismiss keyboard when return is pressed
            tfUsername.ShouldReturn += (tfUsername) =>
            {
                ((UITextField)tfUsername).ResignFirstResponder();
                return(true);
            };

            IOSImageUtil.makeRoundImageView(profileImage);
        }
Example #2
0
        /**
         * Creates a datasource for the listview
         */
        public async void setupDatasource(List <Game> newGames)
        {
            var dict = new Dictionary <Game, Dictionary <int, UIImage> >();

            foreach (var game in newGames)
            {
                var imageTeam1Player1 = await IOSImageUtil.FromUrl(game.team1.player1.imageUrl);

                var imageTeam1Player2 = await IOSImageUtil.FromUrl(game.team1.player2.imageUrl);

                var imageTeam2Player1 = await IOSImageUtil.FromUrl(game.team2.player1.imageUrl);

                var imageTeam2Player2 = await IOSImageUtil.FromUrl(game.team2.player2.imageUrl);

                Dictionary <int, UIImage> images = new Dictionary <int, UIImage>();
                images.Add(1, imageTeam1Player1);
                images.Add(2, imageTeam1Player2);
                images.Add(3, imageTeam2Player1);
                images.Add(4, imageTeam2Player2);

                dict.Add(game, images);
                System.Diagnostics.Debug.WriteLine("Set datasource");
                gameTableView.Source = new TableViewSource(newGames, dict, this);
                gameTableView.ReloadData();
            }
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            users = new List <iOSUser>();

            //Get all the users (for better performance, convert to paginated lists)
            var userList = await UserCall.getUsers();

            if (userList == null)
            {
                var alertController = UIAlertController.Create("Warning", "Could not connect to server, please try again.", UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Try Again", UIAlertActionStyle.Default, alert => ViewDidLoad()));
                alertController.AddAction(UIAlertAction.Create("No thanks", UIAlertActionStyle.Default, alert => System.Diagnostics.Debug.Write("No thanks was selected")));
                this.PresentViewController(alertController, true, null);
            }
            else
            {
                // Get the image and reload the list when done
                foreach (var user in userList)
                {
                    UIImage image = await IOSImageUtil.FromUrl(user.imageUrl);

                    var iosUser = new iOSUser(image, user);
                    users.Add(iosUser);
                    System.Diagnostics.Debug.WriteLine("NR OF USERS IN LIST: " + users.Count);
                    playersTableView.Source = new SelectPlayerDatasource(users, this);
                    playersTableView.ReloadData();
                }
            }
        }
Example #4
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            SelectPlayerCell cell = tableView.DequeueReusableCell(cellIdentifier) as SelectPlayerCell;
            iOSUser          user = users[indexPath.Row];

            if (cell == null)
            {
                cell = new SelectPlayerCell();
            }

            UIImage image;

            if (userDict.ContainsKey(user))
            {
                image = userDict[user];
            }
            else
            {
                image = user.image;
                userDict.Add(user, image);
            }

            cell.ImgProfile.Image = image;
            IOSImageUtil.makeRoundImageView(cell.ImgProfile);
            cell.LblPlayerUsername.Text = user.username;
            cell.LblPlayerRank.Text     = "Wins: " + user.wins + "  Losses " + user.losses;

            return(cell);
        }
        public override void ViewDidLoad()
        {
            barButtonEdit = new UIBarButtonItem("Edit", UIBarButtonItemStyle.Plain, (sender, e) => editScore());
            if (isOwnerOfTheGame && game.isActive)
            {
                this.NavigationItem.SetRightBarButtonItem(barButtonEdit, true);
            }

            lblTeam1Score.Text = game.team1.score.ToString();
            lblTeam2Score.Text = game.team2.score.ToString();

            lblTeam2Player1.Text = game.team2.player1.username;
            lblTeam2Player2.Text = game.team2.player2.username;
            lblTeam1Player2.Text = game.team1.player2.username;
            lblTeam1Player1.Text = game.team1.player1.username;

            imageViews = new List <UIImageView>();
            imageViews.Add(imgTeam1Player1);
            imageViews.Add(imgTeam1Player2);
            imageViews.Add(imgTeam2Player1);
            imageViews.Add(imgTeam2Player2);
            imageViews.Add(imgTeam1Player1Detail);
            imageViews.Add(imgTeam1Player2Detail);
            imageViews.Add(imgTeam2Player1Detail);
            imageViews.Add(imgTeam2Player2Detail);

            imgTeam1Player1.Image = team1Player1Image;
            imgTeam1Player2.Image = team1Player2Image;
            imgTeam2Player1.Image = team2Player1Image;
            imgTeam2Player2.Image = team2Player2Image;

            imgTeam1Player1Detail.Image = team1Player1Image;
            imgTeam1Player2Detail.Image = team1Player2Image;
            imgTeam2Player1Detail.Image = team2Player1Image;
            imgTeam2Player2Detail.Image = team2Player2Image;

            System.Diagnostics.Debug.WriteLine("Height: " + scrollView.Bounds.Height + ", Width: " + scrollView.Bounds.Width);
            System.Diagnostics.Debug.WriteLine("Content Height: " + scrollView.ContentSize.Height + ", Content Width: " + scrollView.ContentSize.Width);
            System.Diagnostics.Debug.WriteLine("LSV Y + Height: " + (LivestreamView.Frame.Y + LivestreamView.Bounds.Height));

            foreach (var imageView in imageViews)
            {
                IOSImageUtil.makeRoundImageView(imageView);
            }

            var tapGuesture = new UITapGestureRecognizer(GotoLivestream);

            LivestreamView.AddGestureRecognizer(tapGuesture);
        }
Example #6
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            GameTableViewCell cell = tableView.DequeueReusableCell(cellIdentifier) as GameTableViewCell;
            Game game = games[indexPath.Row];

            if (cell == null)
            {
                cell = new GameTableViewCell();
            }

            cell.LblTeam1Score.Text = game.team1.score.ToString();
            cell.LblTeam2Score.Text = game.team2.score.ToString();

            var ImgTeam1Player1 = dict[game][1];
            var ImgTeam1Player2 = dict[game][2];
            var ImgTeam2Player1 = dict[game][3];
            var ImgTeam2Player2 = dict[game][4];

            cell.ImgTeam1Player1.Image = ImgTeam1Player1;
            cell.ImgTeam1Player2.Image = ImgTeam1Player2;
            cell.ImgTeam2Player1.Image = ImgTeam2Player1;
            cell.ImgTeam2Player2.Image = ImgTeam2Player2;

            IOSImageUtil.makeRoundImageView(cell.ImgTeam1Player1);
            IOSImageUtil.makeRoundImageView(cell.ImgTeam1Player2);
            IOSImageUtil.makeRoundImageView(cell.ImgTeam2Player1);
            IOSImageUtil.makeRoundImageView(cell.ImgTeam2Player2);

            owner.imgTeam1Player1 = ImgTeam1Player1;
            owner.imgTeam1Player2 = ImgTeam1Player2;
            owner.imgTeam2Player1 = ImgTeam2Player1;
            owner.imgTeam2Player2 = ImgTeam2Player2;



            if (game.owner.id == userId)
            {
                cell.ImgIsOwner.Alpha = 1;
            }


            return(cell);
        }
Example #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Make the imageviews round
            IOSImageUtil.makeRoundImageView(imgTeam1Player1);
            IOSImageUtil.makeRoundImageView(imgTeam1Player2);
            IOSImageUtil.makeRoundImageView(imgTeam2Player1);
            IOSImageUtil.makeRoundImageView(imgTeam2Player2);

            //Create and add guesture recognizers for the views
            var firstGesture  = new UITapGestureRecognizer(FirstPlayer);
            var secondGesture = new UITapGestureRecognizer(SecondPlayer);
            var thirdGesture  = new UITapGestureRecognizer(ThirdPlayer);
            var fourthGesture = new UITapGestureRecognizer(FourthPlayer);

            team1Player1View.AddGestureRecognizer(firstGesture);
            team1Player2View.AddGestureRecognizer(secondGesture);
            team2Player1View.AddGestureRecognizer(thirdGesture);
            team2Player2View.AddGestureRecognizer(fourthGesture);
        }
Example #8
0
        //Prepares and performs an api call to register the new user
        public async void handleRegisterUser()
        {
            var  byteArray = IOSImageUtil.CompressImage(profileImage.Image);
            User user      = new User();

            user.username = tfUsername.Text;
            var userId = await UserCall.createUser(byteArray, "jpg", user);

            if (userId == -1)
            {
                lblWarning.Text = "Something went wrong, try again";
            }
            else
            {
                var plist = NSUserDefaults.StandardUserDefaults;
                plist.SetString(tfUsername.Text, "username");
                plist.SetString(imageUrl, "imageUrl");
                plist.SetInt(userId, "userId");
                DismissViewController(true, null);
            }
        }