internal void TagActivity(string tag, SensorEventViewModel sensorEvent)
        {
            sensorEvent.Activity = GetActivityByName(tag);
            int stringIndex = _dictDateEvents[CurrentDate].Offset + _allEventsInView.IndexOf(sensorEvent);

            _eventStringList[stringIndex] = sensorEvent.ToString();
        }
 internal void UntagAllActivities()
 {
     for (int idEvent = 0; idEvent < _eventStringList.Count; idEvent++)
     {
         string strCurrentEvent           = _eventStringList[idEvent];
         SensorEventViewModel sensorEvent = ParseSensorEventFromString(strCurrentEvent);
         sensorEvent.Activity      = ActivityViewModel.NullActivity;
         _eventStringList[idEvent] = sensorEvent.ToString();
     }
     IsEventsModified = true;
 }
 internal void TagAllResidents(string tag)
 {
     for (int idEvent = 0; idEvent < _eventStringList.Count; idEvent++)
     {
         string strCurrentEvent           = _eventStringList[idEvent];
         SensorEventViewModel sensorEvent = ParseSensorEventFromString(strCurrentEvent);
         sensorEvent.Resident      = GetResidentByName(tag);
         _eventStringList[idEvent] = sensorEvent.ToString();
     }
     IsEventsModified = true;
 }
 internal void FillNullActivity()
 {
     for (int idEvent = 0; idEvent < _eventStringList.Count; idEvent++)
     {
         string strCurrentEvent           = _eventStringList[idEvent];
         SensorEventViewModel sensorEvent = ParseSensorEventFromString(strCurrentEvent);
         if (sensorEvent.Activity == ActivityViewModel.NullActivity)
         {
             sensorEvent.Activity = GetActivityByName("Other_Activity", true, true);
             IsEventsModified     = true;
         }
         _eventStringList[idEvent] = sensorEvent.ToString();
     }
 }
 public async Task ImportAnnotationAsync(StorageFile annotationFile)
 {
     using (var inputStream = await annotationFile.OpenReadAsync())
         using (var classicStream = inputStream.AsStreamForRead())
             using (var streamReader = new StreamReader(classicStream))
             {
                 int      lineNo  = 0;
                 int      idEvent = 0;
                 string[] tokenList;
                 // Make sure Other_Activity exists in dataset metadata.
                 ActivityViewModel curActivity      = GetActivityByName("Other_Activity", true, true);
                 string            curAnnotationTag = "";
                 // Add Other Activity to activity list
                 while (streamReader.Peek() >= 0)
                 {
                     string curEventString = streamReader.ReadLine();
                     if (string.IsNullOrWhiteSpace(curEventString))
                     {
                         continue;
                     }
                     tokenList = curEventString.Split(new char[] { ' ', '\t', ',' });
                     // Get the Date of the String and add to dictionary
                     DateTime curEventTimeTag = DateTime.Parse(tokenList[0] + ' ' + tokenList[1]);
                     // Check the activity label of current event
                     if (tokenList.Length > 4 && !string.IsNullOrWhiteSpace(tokenList[4]))
                     {
                         // Process annotation tag
                         string[] subTokenList = tokenList[4].Split(new char[] { '=' });
                         curActivity = GetActivityByName(subTokenList[0], true, true);
                         // In case the ="begin" part is missing in the annotation
                         if (subTokenList.Length < 2)
                         {
                             if (curAnnotationTag == "\"begin\"")
                             {
                                 curAnnotationTag = "\"end\"";
                             }
                             else
                             {
                                 curAnnotationTag = "\"begin\"";
                             }
                         }
                         else
                         {
                             curAnnotationTag = subTokenList[1];
                         }
                     }
                     // Append Activity
                     while (idEvent < _eventStringList.Count)
                     {
                         // Check datetime of current event
                         SensorEventViewModel sensorEvent = ParseSensorEventFromString(_eventStringList[idEvent]);
                         if (sensorEvent.TimeTag.DateTime <= curEventTimeTag)
                         {
                             sensorEvent.Activity      = curActivity;
                             _eventStringList[idEvent] = sensorEvent.ToString();
                             idEvent++;
                         }
                         else
                         {
                             break;
                         }
                     }
                     // If activity end, update annotation token to OtherActivity
                     if (curAnnotationTag == "\"end\"")
                     {
                         curActivity      = GetActivityByName("Other_Activity");;
                         curAnnotationTag = "";
                     }
                     // Log Token
                     lineNo++;
                 }
             }
     this.IsDatasetModified = true;
     this.IsEventsModified  = true;
 }