private void LoadFileV1(BinaryReader br, string filepath) { Year = br.ReadInt16(); Month = br.ReadByte(); var days = br.ReadInt32(); for (int i = 0; i < days; i++) { var dayNumber = br.ReadByte(); var actCount = br.ReadInt32(); var acts = new DayActivityList(this, dayNumber); for (int a = 0; a < actCount; a++) { var act = new ActivitySpan(this, acts) { StartSecond = br.ReadUInt32(), EndSecond = br.ReadUInt32(), WasActive = br.ReadBoolean() }; acts.Add(act); } Days.Add(dayNumber, acts); } // Read the footer var footer = br.ReadString(); if (footer != "KTHXBYE") { throw new Exception("Could not read file " + filepath + ", incorrect footer"); } }
/// <summary> /// Copy constructor /// </summary> /// <param name="toCopy"></param> public MonthActivities(MonthActivities toCopy) { Year = toCopy.Year; Month = toCopy.Month; ComputerName = toCopy.ComputerName; ApplicationNames = new List <string>(toCopy.ApplicationNames); WindowTitles = new List <string>(toCopy.WindowTitles); foreach (var day in toCopy.Days) { var activityList = new DayActivityList(this, day.Value.DayNumber); foreach (var act in day.Value) { var copy = new ActivitySpan(activityList, act.StartSecond, act.EndSecond, act.WasActive, act.ApplicationName(), act.WindowTitle()); copy.Classify(act.Classification, act.ClassificationFrom); activityList.Add(copy); } this.Days[day.Key] = activityList; } }