void CancelPost(NSObject sender) { // Hides the keyboards and then returns back to SubmitPostViewController HiddenText.EndEditing(true); TagField.EndEditing(true); DismissViewController(true, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Sets the preview to the image record passed in ImageView.Image = ImageRecord.FullImage; // sets up font picker and picks a random font model = new PickerViewModel(this); FontPicker.Model = model; var randomFont = (new Random()).Next() % UIFont.FamilyNames.Length; FontPicker.Select(randomFont, 0, false); // Sets up the label with random font ImageLabel.Font = UIFont.FromName(UIFont.FamilyNames [randomFont], 24); // sets delegates so enter dimsisses keyboard TagField.ShouldReturn = TextFieldShouldReturn; HiddenText.ShouldReturn = TextFieldShouldReturn; // typing into the hiddent text field automatically updates the label on the image HiddenText.EditingChanged += OnDidEditField; // start editing the text field as soon as the view is done loading HiddenText.BecomeFirstResponder(); }
void Start() { //instantiate reference classes //healthManager = FindObjectOfType<HealthManager> (); elderMonk = FindObjectOfType <ElderMonk> (); hiddenText = FindObjectOfType <HiddenText> (); playerController = FindObjectOfType <PlayerController> (); //set starting values roundEnd = false; roundResetTimeCounter = roundResetTime; }
public float roundResetTimeCounter; // time variable between rounds void Start () { //instantiate reference classes healthManager = FindObjectOfType<HealthManager> (); elderMonk = FindObjectOfType<ElderMonk> (); hiddenText = FindObjectOfType<HiddenText> (); playerController = FindObjectOfType<PlayerController> (); //find animators anim01 = Player01.GetComponent<Animator> (); anim02 = Player02.GetComponent<Animator> (); //player02 rigidbody body02 = Player02.GetComponent<Rigidbody2D> (); //set starting values roundEnd = false; roundResetTimeCounter = roundResetTime; }
void PublishPost(NSObject sender) { // Prevents multiple posting, locks as soon as a post is made PostButton.Enabled = false; UIActivityIndicatorView indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); indicator.StartAnimating(); PostButton.CustomView = indicator; // Hides the keyboards and dispatches a UI update to show the upload progress HiddenText.EndEditing(true); TagField.EndEditing(true); ProgressBar.Hidden = false; // Creates post record type and initizalizes all of its values CKRecord newRecord = new CKRecord(Post.RecordType); newRecord [Post.FontKey] = (NSString)ImageLabel.Font.Name; newRecord [Post.ImageRefKey] = new CKReference(ImageRecord.Record.Id, CKReferenceAction.DeleteSelf); newRecord [Post.TextKey] = (NSString)HiddenText.Text; string[] tags = TagField.Text.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); newRecord [Post.TagsKey] = NSArray.FromObjects(tags); Post newPost = new Post(newRecord); newPost.ImageRecord = ImageRecord; // Only upload image record if it is not on server, otherwise just upload the new post record CKRecord[] recordsToSave = ImageRecord.IsOnServer ? new CKRecord[] { newRecord } : new CKRecord[] { newRecord, ImageRecord.Record }; // TODO: https://trello.com/c/A9T8Spyp second param is null CKModifyRecordsOperation saveOp = new CKModifyRecordsOperation(recordsToSave, new CKRecordID[0]); saveOp.PerRecordProgress = (CKRecord record, double progress) => { // Image record type is probably going to take the longest to upload. Reflect it's progress in the progress bar if (record.RecordType == Image.RecordType) { InvokeOnMainThread(() => { var val = (float)(progress * 0.95); ProgressBar.SetProgress(val, true); }); } }; // When completed it notifies the tableView to add the post we just uploaded, displays error if it didn't work saveOp.Completed = (CKRecord[] savedRecords, CKRecordID[] deletedRecordIDs, NSError operationError) => { Error errorResponse = HandleError(operationError); switch (errorResponse) { case Error.Success: // Tells delegate to update so it can display our new post InvokeOnMainThread(() => { DismissViewController(true, null); MainController.Submit(newPost); }); break; case Error.Retry: CKErrorInfo errorInfo = new CKErrorInfo(operationError.UserInfo); nint retryAfter = errorInfo.RetryAfter.HasValue ? errorInfo.RetryAfter.Value : 3; Console.WriteLine("Error: {0}. Recoverable, retry after {1} seconds", operationError.Description, retryAfter); Task.Delay((int)retryAfter * 1000).ContinueWith(_ => PublishPost(sender)); break; case Error.Ignore: Console.WriteLine("Error saving record: {0}", operationError.Description); string errorTitle = "Error"; string dismissButton = "Okay"; string errorMessage = operationError.Code == (long)CKErrorCode.NotAuthenticated ? "You must be logged in to iCloud in order to post" : "Unrecoverable error with the upload, check console logs"; InvokeOnMainThread(() => { UIAlertController alert = UIAlertController.Create(errorTitle, errorMessage, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(dismissButton, UIAlertActionStyle.Cancel, null)); PostButton.Enabled = true; PresentViewController(alert, true, null); ProgressBar.Hidden = true; PostButton.CustomView = null; }); break; default: throw new NotImplementedException(); } }; CKContainer.DefaultContainer.PublicCloudDatabase.AddOperation(saveOp); }
void EditText(NSObject sender) { // Pulls up the keyboard for the hidden text field when photo is tapped HiddenText.BecomeFirstResponder(); }
void Start() { //other classes gameOverManager = FindObjectOfType <GameOverManager>(); hiddenText = FindObjectOfType <HiddenText>(); }
/// <summary> /// Returns true when the character index is within a hidden range. /// </summary> public bool HideCharacter(int index) { return(HiddenText.Any(hideRange => index > hideRange.Start - 1 && index < hideRange.End + 1)); }
void Start() { //other classes gameOverManager = FindObjectOfType<GameOverManager>(); hiddenText = FindObjectOfType<HiddenText>(); }