Ejemplo n.º 1
0
        public async Task Start()
        {
            await Reset();

            if (!Plugin.Geolocator.CrossGeolocator.Current.IsGeolocationAvailable)
            {
                StartFailed?.Invoke(this, "GPS is not available on this device.");
                return;
            }

            if (!Plugin.Geolocator.CrossGeolocator.Current.IsGeolocationEnabled)
            {
                StartFailed?.Invoke(this, "GPS is not enabled on this device.");
                return;
            }

            Plugin.Geolocator.CrossGeolocator.Current.PositionChanged += Current_PositionChanged;

            Plugin.Geolocator.CrossGeolocator.Current.AllowsBackgroundUpdates = true;
            Plugin.Geolocator.CrossGeolocator.Current.DesiredAccuracy         = 5;
            var started = await Plugin.Geolocator.CrossGeolocator.Current.StartListeningAsync(5000, 50, false);

            if (started)
            {
                Started?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                StartFailed?.Invoke(this, "There was a problem starting GPS Services on your device.");
            }
        }
Ejemplo n.º 2
0
        public override void ResponseReceived(byte[] parameter)
        {
            switch ((WebcamCommunication)parameter[0])
            {
            case WebcamCommunication.ResponseFrame:
                if (_fireStarted)
                {
                    _fireStarted = false;
                    Started?.Invoke(this, EventArgs.Empty);
                    IsStreaming = true;
                }

                ThreadPool.QueueUserWorkItem(state => ProcessImage(parameter, 1));
                break;

            case WebcamCommunication.ResponseWebcams:
                var serializer = new Serializer(typeof(List <WebcamInfo>));
                var webcams    = serializer.Deserialize <List <WebcamInfo> >(parameter, 1);
                Webcams = webcams;
                WebcamsReceived?.Invoke(this, webcams);

                LogService.Receive(string.Format((string)Application.Current.Resources["WebcamsReceived"],
                                                 Webcams.Count));
                break;

            case WebcamCommunication.ResponseResolutionNotFoundUsingDefault:
                LogService.Warn((string)Application.Current.Resources["WebcamResolutionNotFound"]);
                break;

            case WebcamCommunication.ResponseNoFrameReceived:
                _fireStarted = false;
                StartFailed?.Invoke(this, EventArgs.Empty);
                LogService.Error((string)Application.Current.Resources["WebcamNoFrameReceived"]);
                break;

            case WebcamCommunication.ResponseStarted:
                LogService.Receive((string)Application.Current.Resources["WebcamStarted"]);
                GetWebcamImage();
                break;

            case WebcamCommunication.ResponseNotSupported:
                LogService.Error((string)Application.Current.Resources["PlatformNotSupported"]);
                break;

            case WebcamCommunication.ResponseStopped:
                LogService.Receive((string)Application.Current.Resources["WebcamStopped"]);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 3
0
 private static void StartThreadStart()
 {
     if (ServiceHelper.StartTaskManagerAccessService(10000))
     {
         if (Started != null)
         {
             Started.Invoke(null, new EventArgs());
         }
     }
     else
     {
         if (StartFailed != null)
         {
             StartFailed.Invoke(null, new EventArgs());
         }
     }
 }
 protected virtual void OnStartFailed()
 {
     StartFailed?.Invoke(this, EventArgs.Empty);
 }
 internal void OnStartFailed()
 {
     Log.Warning($"Server {this.ID:00} Start Failed.");
     StartFailed.Invoke(this, null);
 }