public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.White; this.Title = "Xamagon Hunt!"; var anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); UIButton shareDemoButton = new UIButton(UIButtonType.System) { Frame = new CGRect(this.View.Frame.Width / 2 - 40, 150, 75, 44), BackgroundColor = UIColor.LightGray.ColorWithAlpha((System.nfloat) 0.6) }; shareDemoButton.SetTitle("Start Here", UIControlState.Normal); shareDemoButton.SetTitleColor(UIColor.White, UIControlState.Normal); this.View.AddSubview(shareDemoButton); UILabel shareDemoLabel = new UILabel() { Text = "List of Anchors? Click Me!", TextAlignment = UITextAlignment.Center, Frame = new CGRect(10, 200, this.View.Frame.Width - 20, 44), }; UILabel listOfAnchors = new UILabel() { Text = "...", TextAlignment = UITextAlignment.Natural, Frame = new CGRect(10, 230, this.View.Frame.Width - 20, 300), //LineBreakMode = UILineBreakMode.WordWrap, Lines = 10 }; UITapGestureRecognizer labelTap = new UITapGestureRecognizer(async() => { var test = await anchorSharingServiceClient.RetrieveAllAnchors(); var listItemString = string.Empty; int count = 0; foreach (var item in test) { count++; char[] MyChar = { '[', ' ', ']', '"' }; string NewString = item.Trim(MyChar); listItemString += count.ToString() + ". " + NewString + "\n"; } listOfAnchors.Text = listItemString; }); shareDemoLabel.UserInteractionEnabled = true; shareDemoLabel.AddGestureRecognizer(labelTap); shareDemoButton.TouchUpInside += (sender, e) => { this.NavigationController.PushViewController(new ShareDemoController(), true); }; this.View.AddSubview(shareDemoLabel); this.View.AddSubview(listOfAnchors); }
public SharedDemoViewController(IntPtr handle) : base(handle) { this.anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); this.OnLocateAnchorsCompleted += (sender, args) => MoveToNextStepAfterLocateAnchorsCompleted(); }
async void IOnClickListener.OnClick(View view) { if (!CanCreateAnchor()) { return; } createAnchorButton.Enabled = false; CloudSpatialAnchor cloudAnchor = new CloudSpatialAnchor(); cloudAnchor.LocalAnchor = PlacedVisual.LocalAnchor; cloudAnchor.AppProperties.Add("Shape", PlacedVisual.Shape.ToString()); isCreatingAnchor = true; await CloudAnchorManager.CreateAnchorAsync(cloudAnchor) .ContinueWith(async cloudAnchorTask => { try { CloudSpatialAnchor anchor = await cloudAnchorTask; string anchorId = anchor.Identifier; Log.Debug("ASADemo", "anchorId: " + anchorId); var anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); SendAnchorResponse response = await anchorSharingServiceClient.SendAnchorIdAsync(anchorId); } catch (CloudSpatialException) { // to do //this.CreateAnchorExceptionCompletion($"{ex.Message}, {ex.ErrorCode}"); } catch (Exception) { // to do //this.CreateAnchorExceptionCompletion(ex.Message); //visual.SetColor(this, Color.Red); } }); AnchorVisual createdAnchor = PlacedVisual; PlacedVisual = null; OnAnchorCreated?.Invoke(createdAnchor); }
protected override void OnResume() { base.OnResume(); // ArFragment of Sceneform automatically requests the camera permission before creating the AR session, // so we don't need to request the camera permission explicitly. // This will cause onResume to be called again after the user responds to the permission request. if (!SceneformHelper.HasCameraPermission(this)) { return; } if (this.sceneView?.Session is null && !SceneformHelper.TrySetupSessionForSceneView(this, this.sceneView)) { // Exception will be logged and SceneForm will handle any ARCore specific issues. this.Finish(); return; } if (string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountId) || AccountDetails.SpatialAnchorsAccountId == "Set me" || string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountKey) || AccountDetails.SpatialAnchorsAccountKey == "Set me" || string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountDomain) || AccountDetails.SpatialAnchorsAccountDomain == "Set me") { Toast.MakeText(this, $"\"Set {AccountDetails.SpatialAnchorsAccountId}, {AccountDetails.SpatialAnchorsAccountKey}, and {AccountDetails.SpatialAnchorsAccountDomain} in {nameof(AccountDetails)}.cs\"", ToastLength.Long) .Show(); this.Finish(); return; } if (string.IsNullOrEmpty(AccountDetails.AnchorSharingServiceUrl) || AccountDetails.AnchorSharingServiceUrl == "Set me") { Toast.MakeText(this, $"Set the {AccountDetails.AnchorSharingServiceUrl} in {nameof(AccountDetails)}.cs", ToastLength.Long) .Show(); this.Finish(); return; } this.anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); this.UpdateStatic(); }
public async void OnLinksClick(object sender, EventArgs e) { anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); var test = await anchorSharingServiceClient.RetrieveAllAnchors(); var listItemString = string.Empty; int count = 0; foreach (var item in test) { count++; char[] MyChar = { '[', ' ', ']', '"' }; string NewString = item.Trim(MyChar); listItemString += count.ToString() + ". " + NewString + "\n"; } this.RunOnUiThread(() => { listofAnchors.Text = listItemString; }); }
protected override void OnResume() { base.OnResume(); // ArFragment of Sceneform automatically requests the camera permission before creating the AR session, // so we don't need to request the camera permission explicitly. // This will cause onResume to be called again after the user responds to the permission request. if (!SceneformHelper.HasCameraPermission(this)) { return; } if (this.sceneView != null && this.sceneView.Session == null) { SceneformHelper.TrySetupSessionForSceneView(this, this.sceneView); } if (string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountId) || AccountDetails.SpatialAnchorsAccountId == "Set me" || string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountKey) || AccountDetails.SpatialAnchorsAccountKey == "Set me") { Toast.MakeText(this, "\"Set SpatialAnchorsAccountId and SpatialAnchorsAccountKey in AzureSpatialAnchorsManager.java\"", ToastLength.Long) .Show(); this.Finish(); return; } if (string.IsNullOrEmpty(AccountDetails.AnchorSharingServiceUrl) || AccountDetails.AnchorSharingServiceUrl == "Set me") { Toast.MakeText(this, "Set the SharingAnchorsServiceUrl in SharedActivity.java", ToastLength.Long) .Show(); this.Finish(); } this.anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); this.UpdateStatic(); }
public ShareDemoController() { this.anchorSharingServiceClient = new AnchorSharingServiceClient(AccountDetails.AnchorSharingServiceUrl); }