Пример #1
0
 async protected virtual void Start()
 {
     IsSupported           = QRCodeWatcher.IsSupported();
     capabilityTask        = QRCodeWatcher.RequestAccessAsync();
     accessStatus          = await capabilityTask;
     capabilityInitialized = true;
 }
        /// <summary>
        /// Record whether the QRCodeWatcher reports itself as supported, and request access.
        /// </summary>
        private async void Start()
        {
            isSupported = QRCodeWatcher.IsSupported();
            var capabilityTask = QRCodeWatcher.RequestAccessAsync();

            accessStatus = await capabilityTask;
            SimpleConsole.AddLine(log, $"Requested caps, access: {accessStatus.ToString()}");
        }
Пример #3
0
 /// <summary>
 /// Record whether the QRCodeWatcher reports itself as supported, and request access.
 /// </summary>
 private async void Start()
 {
     _isSupported           = QRCodeWatcher.IsSupported();
     _capabilityTask        = QRCodeWatcher.RequestAccessAsync();
     _accessStatus          = await _capabilityTask;
     _capabilityInitialized = true;
     SimpleConsole.AddLine(log, $"Requested caps, access: {_accessStatus.ToString()}");
 }
Пример #4
0
 private void ProcessTrackerCapabilityReturned(QRCodeWatcherAccessStatus ast)
 {
     if (ast != QRCodeWatcherAccessStatus.Allowed)
     {
         InitializationFail($"QR tracker could not be initialized: {ast}");
     }
     accessStatus = ast;
 }
Пример #5
0
        async private void RequestCapability()
        {
            // Windows.Security.Authorization.AppCapabilityAccess.AppCapability cap = Windows.Security.Authorization.AppCapabilityAccess.AppCapability.Create("webcam");
            // accessStatus = await cap.RequestAccessAsync();

            accessStatus = await QRCodeWatcher.RequestAccessAsync();

            capabilityInitialized = true;
        }
Пример #6
0
 // Use this for initialization
 async protected virtual void Start()
 {
     IsSupported           = QRCodeWatcher.IsSupported();
     capabilityTask        = QRCodeWatcher.RequestAccessAsync();
     accessStatus          = await capabilityTask;
     capabilityInitialized = true;
     //AROA EDIT
     //qrCodesList.Clear();//Clear list on initialization
 }
        /// <summary>
        /// Record whether the QRCodeWatcher reports itself as supported, and request access.
        /// </summary>
        /// <remarks>
        /// If the camera permission has not already been granted (GetPermissions has successfully completed),
        /// then the call to QRCodeWather.RequestAccessAsync will never return, even after the user grants permissions.
        /// See https://github.com/microsoft/MixedReality-WorldLockingTools-Samples/issues/20
        /// </remarks>
        private async void Start()
        {
            isSupported = QRCodeWatcher.IsSupported();
            SimpleConsole.AddLine(log, $"QRCodeWatcher.IsSupported={isSupported}");
            bool gotPermission = await GetPermissions();

            if (gotPermission)
            {
                var capabilityTask = QRCodeWatcher.RequestAccessAsync();
                accessStatus = await capabilityTask;
                SimpleConsole.AddLine(log, $"Requested caps, access: {accessStatus.ToString()}");
            }
        }
Пример #8
0
        private async void GetAccessStatus()
        {
            if (IsSupported && (!_capabilityInitialized || _accessStatus != QRCodeWatcherAccessStatus.Allowed))
            {
                if (_currentTime <= _maxTime)
                {
                    _currentTime += Time.deltaTime;
                    return;
                }
                _currentTime = 0;

                _capabilityTask        = QRCodeWatcher.RequestAccessAsync();
                _accessStatus          = await _capabilityTask;
                _capabilityInitialized = true;
            }
        }
        private async Task <QRCodeWatcherAccessStatus> StartQRWatchingAsyncImpl(CancellationToken token)
        {
            QRCodeWatcherAccessStatus accessStatus = QRCodeWatcherAccessStatus.DeniedBySystem;

#if WINDOWS_UWP
            DebugLog("Requesting QRCodeWatcher capability");
            accessStatus = await QRCodeWatcher.RequestAccessAsync();

            if (accessStatus != QRCodeWatcherAccessStatus.Allowed)
            {
                DebugLog("Failed to obtain QRCodeWatcher capability. QR Codes will not be detected");
            }
            else
            {
                DebugLog("QRCodeWatcher capability granted.");
            }
#endif

            if (accessStatus == QRCodeWatcherAccessStatus.Allowed)
            {
                // Note: If the QRCodeWatcher is created prior to obtaining the QRCodeWatcher capability, initialization will fail.
                if (qrWatcher == null)
                {
                    DebugLog("Creating qr tracker");
                    qrWatcher          = new QRCodeWatcher();
                    qrWatcher.Added   += QRWatcherAdded;
                    qrWatcher.Updated += QRWatcherUpdated;
                    qrWatcher.Removed += QRWatcherRemoved;
                }

                if (!token.IsCancellationRequested &&
                    !IsWatcherRunning)
                {
                    qrWatcher.Start();
                    IsWatcherRunning = true;
                }
            }

            return(await Task.FromResult(accessStatus));
        }