コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: sumitkm/recorder
 /// <summary>
 /// Handles a state change of the recording instance
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="rec">Recording instance</param>
 /// <param name="marker">Ellipse instance</param>
 private void HandleStateChange(object sender, Recording rec, Ellipse marker)
 {
     if (rec.ItemState == Status.Empty)
     {
         // Start recording
         rec.ItemState = Status.Recording;
         rec.StarTime = DateTime.Now;
     }
     else if (rec.ItemState == Status.Recording)
     {
         // Stop recording
         rec.ItemState = Status.Stopped;
     }
     else if (rec.ItemState == Status.Stopped)
     {
         // Stop recording
         rec.ItemState = Status.Empty;
     }
     ChangeButtonState(sender as Button, rec.ItemState);
     ChangeMarkerColor(marker, rec.ItemState);
 }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: sumitkm/recorder
 /// <summary>
 /// Initialize SensorCore 
 /// </summary>
 /// <param name="rec">Recording instance</param>
 /// <param name="type">Sense type</param>
 /// <returns>Asynchronous task</returns>
 private async Task HandleSensorActivity(Recording rec, SenseType type)
 {           
     if (rec.Recorder == null)
     {
         if (await CallSensorcoreApiAsync(async () =>
         {
             switch (type)
             {
                 case SenseType.Activity:
                     _aMonitor = await ActivityMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Places:
                     _pMonitor = await PlaceMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Route:
                     _rTracker = await TrackPointMonitor.GetDefaultAsync();
                     break;
                 case SenseType.Steps:
                     _sCounter = await StepCounter.GetDefaultAsync();
                     break;
             }
         }))
         {
             Debug.WriteLine("Recorder initialized.");
             switch (type)
             {
                 case SenseType.Activity:
                     rec.Recorder = new SenseRecorder(_aMonitor);
                     break;
                 case SenseType.Places:
                     rec.Recorder = new SenseRecorder(_pMonitor);
                     break;
                 case SenseType.Route:
                     rec.Recorder = new SenseRecorder(_rTracker);
                     break;
                 case SenseType.Steps:
                     rec.Recorder = new SenseRecorder(_sCounter);
                     break;
             }
         }
         else return;
     }
     if (rec.Recorder == null)
         return;
     else
     {
         await ActivateAsync();
         switch (rec.ItemState)
         {
             case Status.Recording:
                 await rec.Recorder.StartAsync();
                 break;
             case Status.Stopped:
                 await rec.Recorder.StopAsync();
                 break;
             case Status.Empty:
                 await rec.Recorder.GetRecording().SaveAsync();
                 break;
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Initialize SensorCore
        /// </summary>
        /// <param name="rec">Recording instance</param>
        /// <param name="type">Sense type</param>
        /// <returns>Asynchronous task</returns>
        private async Task HandleSensorActivity(Recording rec, SenseType type)
        {
            if (rec.Recorder == null)
            {
                if (await CallSensorcoreApiAsync(async() =>
                {
                    switch (type)
                    {
                    case SenseType.Activity:
                        _aMonitor = await ActivityMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Places:
                        _pMonitor = await PlaceMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Route:
                        _rTracker = await TrackPointMonitor.GetDefaultAsync();
                        break;

                    case SenseType.Steps:
                        _sCounter = await StepCounter.GetDefaultAsync();
                        break;
                    }
                }))
                {
                    Debug.WriteLine("Recorder initialized.");
                    switch (type)
                    {
                    case SenseType.Activity:
                        rec.Recorder = new SenseRecorder(_aMonitor);
                        break;

                    case SenseType.Places:
                        rec.Recorder = new SenseRecorder(_pMonitor);
                        break;

                    case SenseType.Route:
                        rec.Recorder = new SenseRecorder(_rTracker);
                        break;

                    case SenseType.Steps:
                        rec.Recorder = new SenseRecorder(_sCounter);
                        break;
                    }
                }
                else
                {
                    return;
                }
            }
            if (rec.Recorder == null)
            {
                return;
            }
            else
            {
                await ActivateAsync();

                switch (rec.ItemState)
                {
                case Status.Recording:
                    await rec.Recorder.StartAsync();

                    break;

                case Status.Stopped:
                    await rec.Recorder.StopAsync();

                    break;

                case Status.Empty:
                    await rec.Recorder.GetRecording().SaveAsync();

                    break;
                }
            }
        }