void OnGUI() { KitchenSink.OnGUIBack(); if (CoreXT.IsDevice) { GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, 100)); //Screen.height/2 - 50)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Front/Back", GUILayout.ExpandHeight(true))) { _cameraVideo.Stop(); _cameraVideo.useFrontCamera = !_cameraVideo.useFrontCamera; _cameraVideo.Play(); } if (GUILayout.Button("Detection On/Off", GUILayout.ExpandHeight(true))) { if (_isDetecting) { StopDetection(); } else { StartDetection(); } } if (GUILayout.Button("Show/Hide Log", GUILayout.ExpandHeight(true))) { _showingLog = !_showingLog; } if (GUILayout.Button("Clear Log", GUILayout.ExpandHeight(true))) { _log = ""; } GUILayout.EndHorizontal(); GUILayout.EndArea(); // draw faces if (_faces != null) { foreach (var face in _faces) { GUI.Box(face.bounds, ""); // approximate mouth and eye sizes because face detection doesn't return size if (face.hasLeftEyePosition) { var rect = new Rect(face.leftEyePosition.x, face.leftEyePosition.y, face.bounds.width / 5, face.bounds.width / 10); rect.x -= rect.width / 2; rect.y -= rect.height / 2; GUI.Box(rect, ""); } if (face.hasRightEyePosition) { var rect = new Rect(face.rightEyePosition.x, face.rightEyePosition.y, face.bounds.width / 5, face.bounds.width / 10); rect.x -= rect.width / 2; rect.y -= rect.height / 2; GUI.Box(rect, ""); } if (face.hasMouthPosition) { var rect = new Rect(face.mouthPosition.x, face.mouthPosition.y, face.bounds.width / 3, face.bounds.width / 6); rect.x -= rect.width / 2; rect.y -= rect.height / 2; GUI.Box(rect, ""); } } } } if (_showingLog) { OnGUILog(); } }
private void OnGUI() { KitchenSink.OnGUIBack(); GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50)); //this is the original way of how objective C use call back functions: Delegates using separate files. //in this case the file is PeoplePickerNavigationControllerDelegate.cs //we have have it easier to use delegates instead of creating new files for each delegate. //see examples above. Ex: PersonalXT.CalendarAccess += delegate( .... if (GUILayout.Button("pick/select from contacts", GUILayout.ExpandHeight(true))) { ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController(); if (pickerDelegate == null) { pickerDelegate = new PeoplePickerNavigationControllerDelegate(); } picker.peoplePickerDelegate = pickerDelegate; UIApplication.deviceRootViewController.PresentViewController(picker, true, null); } if (GUILayout.Button("get all contacts", GUILayout.ExpandHeight(true))) { Log("Address book authorization status: " + ABAddressBook.GetAuthorizationStatus()); var addressBook = ABAddressBook.Create(null, null); addressBook.RequestAccess(delegate(bool granted, NSError error) { Log("Granted: " + granted); //convienent function to get the names of the contacts string[] contactList = PersonalXT.GetAllContactNames(); for (int i = 0; i < contactList.Length; i++) { Log("Contact " + i + ": " + contactList[i]); } }); } if (GUILayout.Button("add new contacts", GUILayout.ExpandHeight(true))) { addNewContact(); } if (GUILayout.Button("init Calendar and show events within 30 days", GUILayout.ExpandHeight(true))) { checkEventStoreAccessForCalendar(); } if (GUILayout.Button("add an event for tomorrow", GUILayout.ExpandHeight(true))) { addEventForTomorrow(); } if (GUILayout.Button("add alarm to events", GUILayout.ExpandHeight(true))) { createAlarmForEvents(); } if (GUILayout.Button("add reminder with geolocation of current location", GUILayout.ExpandHeight(true))) { PersonalXT.RequestReminderAccess(); } if (GUILayout.Button("reverse geocode happiest place on earth", GUILayout.ExpandHeight(true))) { CLLocation location = new CLLocation(33.809, -117.919); CLGeocoder geocoder = new CLGeocoder(); geocoder.ReverseGeocodeLocation(location, delegate(object[] placemarks, NSError error) { if (error != null) { Debug.Log(error.LocalizedDescription()); } else { foreach (var p in placemarks) { var placemark = p as CLPlacemark; Debug.Log("placemark: " + placemark.name + "\n" + ABAddressFormatting.ABCreateString(placemark.addressDictionary, true)); } } }); } if (GUILayout.Button("Significant location change", GUILayout.ExpandHeight(true))) { if (!CLLocationManager.LocationServicesEnabled() || !CLLocationManager.SignificantLocationChangeMonitoringAvailable()) { Debug.Log("Significant change monitoring not available."); } else { // CLLocationManager manager = new CLLocationManager(); manager.StartMonitoringSignificantLocationChanges(); } } //commented out remove all events and reminders so users don't accidentally remove important events /* * if (GUILayout.Button("remove all Events", GUILayout.ExpandHeight(true))) { * PersonalXT.RemoveAllEvents(); * Log ("Removed events"); * } * * if (GUILayout.Button("remove all Reminders", GUILayout.ExpandHeight(true))) { * PersonalXT.GetAllReminders(); //you can get all the reminders and handle them in line 59 above * //PersonalXT.RemoveAllReminders(); //or you can simply call removeAllReminders * }*/ GUILayout.EndArea(); OnGUILog(); }
void OnGUI() { KitchenSink.OnGUIBack(); if (CoreXT.IsDevice) { GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Load Player Photo", GUILayout.ExpandHeight(true))) { GameKitXT.localPlayer.LoadPhoto(GKPhotoSize.Normal, delegate(Texture2D photo) { if (photo != null) { Log("Loaded photo"); GameObject.Find("PlayerPhoto").guiTexture.texture = photo; } else { Log("Local player has no photo or error loading photo."); } }); } if (GUILayout.Button("Show Game Center", GUILayout.ExpandHeight(true))) { GameKitXT.ShowGameCenter(); } if (GUILayout.Button("Show Banner", GUILayout.ExpandHeight(true))) { GameKitXT.ShowBanner("Game Kit Basics", "Hello from U3DXT!"); } if (GUILayout.Button("Show Leaderboard", GUILayout.ExpandHeight(true))) { GameKitXT.ShowLeaderboard(leaderboardID); } if (GUILayout.Button("Show Achievement", GUILayout.ExpandHeight(true))) { GameKitXT.ShowAchievements(); } if (GUILayout.Button("Get Leaderboard", GUILayout.ExpandHeight(true))) { RetrieveTopTenScores(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); scoreText = GUILayout.TextField(scoreText, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Report Score", GUILayout.ExpandHeight(true))) { GameKitXT.ReportScore(leaderboardID, Convert.ToInt64(scoreText)); } achievementText = GUILayout.TextField(achievementText, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Report Achievement", GUILayout.ExpandHeight(true))) { GameKitXT.ReportAchievement(achievementID, Convert.ToDouble(achievementText)); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } OnGUILog(); }
private async Task <bool> ProcessJob(ConvertDocumentJob job) { try { _logger.LogInformation("Recieved '{JobName}' job.", job.Name); if (string.IsNullOrWhiteSpace(job.OriginalExtension)) { _logger.LogError("Job '{JobName}' failed because it didn't contain the original extension.", job.Name); } var fileName = job.FileId + "." + job.OriginalExtension; var fullPath = Path.Combine(_workFolder, fileName); using (var file = File.OpenWrite(fullPath)) { var storageFile = await _provider.GetObject(Shared.Constants.Buckets.Original, job.FileId); using (var stream = storageFile.Data) { await stream.CopyToAsync(file); } } var result = Converter.Convert(fullPath, job.DesiredExtension, _workFolder); if (result.Successful) { var resultPath = await CopyFile(result.OutputFile, _outputFolder); var info = new FileInfo(resultPath); var contentType = KitchenSink.GetContentTypeFromExtension(info.Extension); using (var file = File.OpenRead(resultPath)) { await _provider.UploadObject(file, Shared.Constants.Buckets.Result, job.FileId, contentType); } var notifyJob = new NotifyUserJob { IsSuccessful = true, FileId = job.FileId }; _messageQueue.QueueJob(notifyJob); _logger.LogInformation("Job '{JobName}' was processed successfuly. Took {milliseconds} ms.", job.Name, result.Time.TotalMilliseconds); return(true); } else if (result.TimedOut) { _logger.LogError("Job '{JobName}' timed out after {milliseconds} ms.", job.Name, result.Time.TotalMilliseconds); // TODO: Let user know when task fails } else { _logger.LogError("Job '{JobName}' failed. Reason: {Reason} Took {milliseconds} ms.", job.Name, result.Output, result.Time.TotalMilliseconds); // TODO: Let user know when task fails } } catch (Exception ex) { _logger.LogError(ex, "Job 'JobName' failed because: {Message}.", job.Name, ex.Message); } return(false); }
void OnGUI() { KitchenSink.OnGUIBack(); OnGUILog(); }
void OnGUI() { KitchenSink.OnGUIBack(); // display the currently speaking text GUI.Label(new Rect(50, 50, Screen.width - 100, Screen.height / 4 - 60), speakingText, labelStyle); // ask for input inputText = GUI.TextField(new Rect(50, Screen.height / 4, (float)(Screen.width * 0.8 - 50), 80), inputText); // speak the input text if (GUI.Button(new Rect((float)(Screen.width * 0.8), Screen.height / 4, (float)(Screen.width * 0.2 - 50), 80), "Speak")) { SpeechXT.settings.pitchMultiplier = pitchValue; SpeechXT.settings.rate = speedValue; SpeechXT.settings.volume = volumeValue; SpeechXT.settings.voice = AVSpeechSynthesisVoice.Voice(comboBoxList[selectedItemIndex].text); SpeechXT.Speak(inputText); } // combo box for selecting languages GUI.Label(new Rect(50, Screen.height / 4 + 100, 100, 50), "Language"); selectedItemIndex = comboBoxControl.List( new Rect(150, Screen.height / 4 + 100, 100, 50), selectedItemIndex, comboBoxList, listStyle); GUILayout.BeginArea(new Rect(50, Screen.height / 4 + 200, Screen.width / 2 - 100, Screen.height / 4 * 3 - 250)); // manually change pitch, speed, and volume pitchValue = GUILayout.HorizontalSlider(pitchValue, 0.5f, 2.0f); GUILayout.Label("Pitch: " + pitchValue, GUILayout.ExpandHeight(true)); speedValue = GUILayout.HorizontalSlider(speedValue, 0.0f, 1.0f); GUILayout.Label("Speed: " + speedValue, GUILayout.ExpandHeight(true)); volumeValue = GUILayout.HorizontalSlider(volumeValue, 0.0f, 1.0f); GUILayout.Label("Volume: " + volumeValue, GUILayout.ExpandHeight(true)); GUILayout.EndArea(); // predefined examples in different languages GUI.Label(new Rect(Screen.width / 4 * 3 - 50, Screen.height / 4 + 100, 100, 50), "Examples"); GUILayout.BeginArea(new Rect(Screen.width / 2 + 50, Screen.height / 4 + 150, Screen.width / 4 - 60, Screen.height / 4 * 3 - 200)); if (GUILayout.Button("American English", GUILayout.ExpandHeight(true))) { SpeechXT.settings.pitchMultiplier = 1f; SpeechXT.settings.rate = 0.25f; SpeechXT.settings.volume = 1f; SpeechXT.settings.voice = AVSpeechSynthesisVoice.Voice("en-US"); SpeechXT.Speak("Hello, I have Siri's voice."); } if (GUILayout.Button("Mexican Spanish", GUILayout.ExpandHeight(true))) { SpeechXT.settings.voice = AVSpeechSynthesisVoice.Voice("es-MX"); SpeechXT.Speak("Buenos días"); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(Screen.width / 4 * 3 + 10, Screen.height / 4 + 150, Screen.width / 4 - 60, Screen.height / 4 * 3 - 200)); if (GUILayout.Button("Aussie", GUILayout.ExpandHeight(true))) { SpeechXT.settings.voice = AVSpeechSynthesisVoice.Voice("en-AU"); SpeechXT.Speak("Good day, mate."); } if (GUILayout.Button("French", GUILayout.ExpandHeight(true))) { SpeechXT.settings.voice = AVSpeechSynthesisVoice.Voice("fr-FR"); SpeechXT.Speak("bonjour, mon amour."); } GUILayout.EndArea(); }
void OnGUI() { KitchenSink.OnGUIBack(); if (CoreXT.IsDevice) { GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50)); GUILayout.Label("MUST first setup iCloud in iOS Developer Portal and Xcode."); GUILayout.BeginHorizontal(); nameText = GUILayout.TextField(nameText, GUILayout.ExpandWidth(true), GUILayout.Height(100)); if (GUILayout.Button("Set Name", GUILayout.ExpandHeight(true))) { SetName(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); scoreText = GUILayout.TextField(scoreText, GUILayout.ExpandWidth(true), GUILayout.Height(100)); if (GUILayout.Button("Set High Score", GUILayout.ExpandHeight(true))) { SetHighScore(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); moneyText = GUILayout.TextField(moneyText, GUILayout.ExpandWidth(true), GUILayout.Height(100)); if (GUILayout.Button("Set Money", GUILayout.ExpandHeight(true))) { SetMoney(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Manual Sync", GUILayout.ExpandHeight(true))) { // don't really need to do this manually Log("Manually syncing."); iCloudPrefs.Synchronize(); } if (GUILayout.Button("Delete All", GUILayout.ExpandHeight(true))) { Log("Deleting all iCloudPrefs data."); iCloudPrefs.DeleteAll(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Copy name into clipboard", GUILayout.ExpandHeight(true))) { UIPasteboard pasteboard = UIPasteboard.GeneralPasteboard(); pasteboard.String = nameText; Log("Copied name into clipboard."); } if (GUILayout.Button("Copy clipboard to name", GUILayout.ExpandHeight(true))) { UIPasteboard pasteboard = UIPasteboard.GeneralPasteboard(); nameText = pasteboard.String; Log("Copied clipboard to name."); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } OnGUILog(); }