public void LoadFromDisk() { if (!File.Exists(_filePath)) { return; } var serializer = new XmlSerializer(typeof(ObservableCollection <AppGroup>)); using (var reader = new StreamReader(_filePath)) { AppTimes.Clear(); foreach (var app in (ObservableCollection <AppGroup>)serializer.Deserialize(reader)) { AppTimes.Add(app); } reader.Close(); } foreach (var app in AppTimes) { app.App.LoadIcon(); app.PropertyChanged += Nts_PropertyChanged; foreach (var timeslot in app.Windows) { timeslot.PropertyChanged += app.TimeSlot_PropertyChanged; } } UpdateProps(); }
public void SetOrAddAppTime(WindowExe app, int lastAction, int timeInc = 1) { if (AppTimes.Any(o => o.App.Exe == app.Exe)) { AppTimes.First(o => o.App.Exe == app.Exe).IncrementWindow(app.Title, lastAction, timeInc); } else { var nts = new AppGroup(app); nts.PropertyChanged += Nts_PropertyChanged; nts.IncrementWindow(app.Title, lastAction, timeInc); AppTimes.Add(nts); } PropChanged("IncludedTime"); PropChanged("ExcludedTime"); PropChanged("TotalTime"); }
public void SetOrAddAppTime(WindowExe app, int lastAction, int timeInc = 1) { if (AppTimes.Any(o => o.App.Exe == app.Exe)) { AppTimes.First(o => o.App.Exe == app.Exe).IncrementWindow(app.Title, lastAction, timeInc); if (Properties.Settings.Default.Autosort) { AppTimes.BubbleSort(); } } else { app.LoadIcon(); var nts = new AppGroup(app); nts.PropertyChanged += Nts_PropertyChanged; nts.IncrementWindow(app.Title, lastAction, timeInc); AppTimes.Add(nts); } PropChanged("IncludedTime"); PropChanged("ExcludedTime"); PropChanged("TotalTime"); }