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); if ((cloudAnchor.Identifier?.Length ?? 0) == 0) { OnAnchorCreationFailed?.Invoke(PlacedVisual, "Failed to create anchor"); return; } AnchorVisual createdAnchor = PlacedVisual; PlacedVisual = null; OnAnchorCreated?.Invoke(createdAnchor); }
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); }