public override void ViewDidLoad() { base.ViewDidLoad(); Debug.Assert(this.viewModel.IsInitialized); // Add all of the child items var localRoot = new RootElement(this.viewModel.PageTitle); localRoot.UnevenRows = true; var topSection = new Section(); localRoot.Add(topSection); foreach (var user in this.viewModel.Friends) { UIImage image = UIImage.FromBundle("unknownUserImage_50.png"); var element = new CreateGamePlayerCell(image, user.Name, "", () => { IOSUtilities.ShowSetupGameScreen(user, this.NavigationController, this); }); element.ImageDownloadTask = PopPicImageCache.GetUserProfileImage(user.UserId, user.ProfilePictureUri.ToString()); topSection.Add(element); } this.Root = localRoot; }
private void LoadPage(int index) { if (index < 0 || index >= this.pageControl.Pages) { // If it's outside the range of what you have to display, then do nothing return; } UIImageView pageView; if (this.pages.ContainsKey(index)) { pageView = this.pages [index]; } else { var myFrame = this.scrollView.Frame; RectangleF frame = new RectangleF(myFrame.Width * index, 0, myFrame.Width, myFrame.Height); pageView = new UIImageView(frame); pageView.ContentMode = UIViewContentMode.ScaleAspectFit; var imageItem = this.viewModel.MyBuddyPictures [index]; IOSUtilities.SetImageFromStream(PopPicImageCache.GetPhotoAlbumImage(0, imageItem.PhotoID, imageItem.FullUrl), pageView, this); this.scrollView.AddSubview(pageView); } this.pages [index] = pageView; }
public override void ViewDidLoad() { base.ViewDidLoad(); UIApplication.SharedApplication.StatusBarHidden = true; // this.ControlsOverlay.Frame = this.View.Frame; // this.ControlsOverlay.SetNeedsDisplay (); InitializeCameraLayer(); // Next set up our UI this.FinishRoundButton.TouchUpInside += (sender, e) => { }; this.PlayerOneViewContainer.Layer.BorderColor = this.PlayerTwoViewContainer.Layer.BorderColor = new CGColor(0, 0, 0); this.PlayerOneViewContainer.Layer.BorderWidth = this.PlayerTwoViewContainer.Layer.BorderWidth = 3; this.PlayerOneViewContainer.Layer.CornerRadius = this.PlayerTwoViewContainer.Layer.CornerRadius = 5; this.gameplayView = new GameplayView(this.ControlsOverlay.Frame, this.viewModel); // gameplayView.SetImages (backgroundImage, balloonImage); gameplayView.BalloonPopped += HandleBalloonPopped; this.View.InsertSubview(gameplayView, 0); this.View.UserInteractionEnabled = true; if (this.viewModel != null) { // Go through and set up all of the UI! this.PlayerOneTimeElapsed.Text = viewModel.PlayerTime1; this.PlayerOnePlayerNameLabel.Text = viewModel.PlayerName1; IOSUtilities.SetImageFromStream(PopPicImageCache.GetUserProfileImage( this.viewModel.model.GameRequesterId, this.viewModel.PlayerProfileImage1), this.PlayerOneProfilePictureImage, this); this.PlayerTwoTimeElapsed.Text = viewModel.PlayerTime2; this.PlayerTwoPlayerNameLabel.Text = viewModel.PlayerName2; IOSUtilities.SetImageFromStream(PopPicImageCache.GetUserProfileImage( this.viewModel.model.GameResponderId, this.viewModel.PlayerProfileImage2), this.PlayerTwoProfilePictureImage, this); this.viewModel.Tick += (object sender, bool e) => { InvokeOnMainThread(() => { this.PlayerOneTimeElapsed.Text = viewModel.PlayerTime1; this.PlayerTwoTimeElapsed.Text = viewModel.PlayerTime2; }); }; this.timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromMilliseconds(40), delegate { this.viewModel.TickExternal(); }); } }
public override void ViewDidLoad() { base.ViewDidLoad(); Debug.Assert(this.viewModel.IsInitialized); UIBarButtonItem startGameButton = new UIBarButtonItem("Start", UIBarButtonItemStyle.Done, null); // startGameButton.Style = UIBarButtonItemStyle.Done; startGameButton.Clicked += (object sender, EventArgs e) => { BTProgressHUD.Show("Creating Game", -1, ProgressHUD.MaskType.Black); this.viewModel.CreateNewGame(this.View.Frame.Height, this.View.Frame.Width).ContinueWith(t => { this.InvokeOnMainThread(() => { BTProgressHUD.Dismiss(); if (!t.IsFaulted && t.Result != null) { var gameplayViewController = AppDelegate.GameplayStoryboard.InstantiateViewController("GameplayViewController") as GameplayViewController; gameplayViewController.SetGameplayViewModel(t.Result); // Need to pop off the set up stack var navController = this.NavigationController; var targetController = this.NavigationController.ViewControllers.Where(vc => vc.GetType() == typeof(GameListTableViewController)).FirstOrDefault(); if (targetController != null) { this.NavigationController.PopToViewController(targetController, false); } navController.PushViewController(gameplayViewController, true); } else { // TODO Error } }); }); }; this.NavigationItem.RightBarButtonItems = new UIBarButtonItem[] { startGameButton }; var localRoot = new RootElement("New Game"); var opponentSection = new Section("Opponent"); localRoot.Add(opponentSection); UIImage image = UIImage.FromBundle("unknownUserImage_50.png"); var opponentElement = new CreateGamePlayerCell(image, this.viewModel.Opponent.Name, "", () => { // TODO - allow the user to change who the opponent is }); opponentElement.ImageDownloadTask = PopPicImageCache.GetUserProfileImage(this.viewModel.Opponent.UserId, this.viewModel.Opponent.ProfilePictureUri.ToString()); opponentSection.Add(opponentElement); this.Root = localRoot; }
public void SetData(GameViewModel viewModel) { webClient.CancelAsync(); this.viewModel = viewModel; this.UserNameLabel.Text = this.viewModel.OpponentName; this.LastMoveLabel.Text = this.viewModel.PreviousActionTimeStamp; this.TimeElapsedLabel.Text = this.viewModel.PreviousActionDescription; IOSUtilities.SetImageFromStream(PopPicImageCache.GetUserProfileImage( this.viewModel.Opponent.ID, this.viewModel.Opponent.ProfilePicture.ToString(), TimeSpan.FromMinutes(5)), this.UserProfileImage, this); }
public void SetCellData(Buddy.PicturePublic imageData) { taskCancelled = false; var downloadTask = PopPicImageCache.GetPhotoAlbumImage(0, imageData.PhotoID, imageData.FullUrl).ContinueWith(t => { if (!t.IsFaulted && t.Result != null && !taskCancelled) { return(t.Result); } else { return(null); } }); IOSUtilities.SetImageFromStream(downloadTask, this.imageView, this); }
public override View GetView(int position, View convertView, ViewGroup parent) { View view = this.context.LayoutInflater.Inflate(Resource.Layout.MyTrophiesGalleryThumbnailLayout, null); // view.LayoutParameters = new AbsListView.LayoutParams (this.ViewDimension, this.ViewDimension); var item = this.myPictures [position]; var textView = view.FindViewById <TextView> (Resource.Id.textView1); var imageView = view.FindViewById <ImageView> (Resource.Id.imageView1); textView.Text = ""; PopPicImageCache.GetPhotoAlbumImage(0, item.PhotoID, item.FullUrl).ContinueWith(t => { // TODO: Use the thumbnails instead if (!t.IsFaulted) { var bmp = AndroidUtilities.DecodeBitmapToSize(t.Result, 300); // var bmp = BitmapFactory.DecodeStream(t.Result); this.context.RunOnUiThread(() => imageView.SetImageBitmap(bmp)); } }); return(view); }