public static bool StopBackgroundTaskForMeasurement(MeasurementModel measurement)
        {
            bool isStopped = false;

            if (measurement != null &&
                measurement.Id != null &&
                measurement.Id.Length > 0)
            {
                isStopped = DeregisterBackgroundTask(measurement.Id);
            }
            return isStopped;
        }
        public static async void ExportMeasurementData(MeasurementModel measurement)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            
            StorageFolder resultFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Evaluation");
            StorageFolder resultFolder2 = await resultFolder.GetFolderAsync("Accelerometer");
            StorageFile resultFile = await resultFolder2.GetFileAsync(measurement.Filename);

            //await resultFile.CopyAsync(Windows.Storage.KnownFolders.DocumentsLibrary, "e" + measurement.AccelerometerFilename);

            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Binary-Datei", new List<string>() { ".bin" });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "e" + measurement.Filename;
            savePicker.PickSaveFileAndContinue();
        }
        //###################################################################################
        //##################################### Methods #####################################
        //###################################################################################

        public static MeasurementModel NewDefaultMeasurementModel(SettingModel settingModel)
        {
            MeasurementModel createMeasurementModel = new MeasurementModel();
            createMeasurementModel.Id = String.Format("{0}", DateTime.Now.Ticks);
            createMeasurementModel.Filename = String.Format("Measurement_{0}.bin", createMeasurementModel.Id);
            createMeasurementModel.CreateDateTime = DateTime.Now;
            if (settingModel != null)
            {
                createMeasurementModel.Setting = settingModel;
            }
            else
            {
                createMeasurementModel.Setting = SettingModel.DefaultSettingModel();
            }
            createMeasurementModel.DataSets = MeasurementDataSets.NewDefaultMeasurementDataSets();
            return createMeasurementModel;
        }
 public static async Task<bool> StartBackgroundTaskForMeasurement(MeasurementModel measurement)
 {
     bool isStarted = false;
     if (measurement != null &&
         measurement.Id != null &&
         measurement.Id != String.Empty &&
         canRegisterBackgroundTask() &&
         measurement.Setting != null)
     {
         TaskArguments taskArguments = mapTo(measurement);
         string arguments = JsonConvert.SerializeObject(taskArguments);                
         if (await StartAccelerometerTask(measurement.Id, arguments))
         {
             isStarted = true;    
         }    
     }
     return isStarted;
 }
 /// <summary>
 /// Adds a certain measurement to the list of measurements.
 /// </summary>
 public void Insert(MeasurementModel measurement)
 {
     this._measurements.Insert(0, measurement);
     OnMeasurementListUpdated(EventArgs.Empty);
 }
        private static TaskArguments mapTo(MeasurementModel measurementModel)
        {
            TaskArguments taskArguments = new TaskArguments();
            taskArguments.MeasurementId = measurementModel.Id;
            taskArguments.Filename = measurementModel.Filename;
            taskArguments.TargetDuration = measurementModel.Setting.TargetDuration;
            taskArguments.StartOffsetDuration = measurementModel.Setting.StartOffsetDuration;

            taskArguments.IsUsedEvaluation = measurementModel.Setting.IsUsedEvaluation;
            taskArguments.IsRecordSamplesEvaluation = measurementModel.Setting.IsRecordSamplesEvaluation;
            taskArguments.SampleBufferSize = measurementModel.Setting.SampleBufferSize;
            taskArguments.AccelerometerThreshold = measurementModel.Setting.AccelerometerThreshold;
            taskArguments.GyrometerThreshold = measurementModel.Setting.GyrometerThreshold;
            taskArguments.StepDistance = measurementModel.Setting.StepDistance;
            taskArguments.PeakJoinDistance = measurementModel.Setting.PeakJoinDistance;

            taskArguments.IsUsedAccelerometer = measurementModel.Setting.IsUsedAccelerometer;
            taskArguments.IsRecordSamplesAccelerometer = measurementModel.Setting.IsRecordSamplesAccelerometer;
            taskArguments.ReportIntervalAccelerometer = measurementModel.Setting.ReportIntervalAccelerometer;

            taskArguments.IsUsedGyrometer = measurementModel.Setting.IsUsedGyrometer;
            taskArguments.IsRecordSamplesGyrometer = measurementModel.Setting.IsRecordSamplesGyrometer;
            taskArguments.ReportIntervalGyrometer = measurementModel.Setting.ReportIntervalGyrometer;

            taskArguments.IsUsedQuaternion = measurementModel.Setting.IsUsedQuaternion;
            taskArguments.IsRecordSamplesQuaternion = measurementModel.Setting.IsRecordSamplesQuaternion;
            taskArguments.ReportIntervalQuaternion = measurementModel.Setting.ReportIntervalQuaternion;

            taskArguments.IsUsedGeolocation = measurementModel.Setting.IsUsedGeolocation;
            taskArguments.IsRecordSamplesGeolocation = measurementModel.Setting.IsRecordSamplesGeolocation;
            taskArguments.ReportIntervalGeolocation = measurementModel.Setting.ReportIntervalGeolocation;
            return taskArguments;
        }