private void CalculateValidationErrors() { validationErrors.Clear(); if (totalTimeInfo.IsZeroTime) { validationErrors.Add("Please set your Total Time to at least one second."); return; } if (tasks.Count == 0) { validationErrors.Add("Please add at least one task."); return; } TimeInfoViewModel timeRemaining = GetTimeRemaining(); if (timeRemaining.IsPositiveTime) { validationErrors.Add(String.Format("Please use up the remaining {0}, or remove that much time from your Total Time.", timeRemaining.ToEnglishString())); } else if (timeRemaining.IsNegativeTime) { validationErrors.Add(String.Format("Please remove {0} from your tasks, or add that much time to your Total Time.", new TimeInfoViewModel(-timeRemaining.TotalSeconds).ToEnglishString())); } NotifyOfPropertyChange(() => HasValidationErrors); }
public TimedTasksViewModel(Conductor <Screen> .Collection.OneActive parent, TimeInfoViewModel totalTimeInfo, List <TaskViewModel> _tasks, SetupViewModel setupViewModel, IWindowManager windowManager) { this.parent = parent; this.setupViewModel = setupViewModel; this.totalTimeInfo = totalTimeInfo; this.windowManager = windowManager; timeLeft.TotalSeconds = totalTimeInfo.TotalSeconds; this.timer = new Timer(1000); this.timer.Elapsed += timer_Elapsed; foreach (var task in _tasks) { tasks.Add(task); } //tasksView = CollectionViewSource.GetDefaultView(tasks); //tasksView.CurrentChanging += TasksView_CurrentChanging; this.settings = IoC.Get <SettingsViewModel>(); if (settings != null) { AutomaticallySwitchTasks = settings.AutoSwitchTasks; } soundPlayer = new SoundPlayer(new Uri("pack://application:,,,/TimeManagementApp;component/Resources/threeBeep.mp3")); soundPlayer.Initialize(); }
public TaskViewModel(string name, ColorInfo colorInfo, TimeInfoViewModel originalTime) { this.name = name; this.colorInfo = colorInfo; this.originalTime = originalTime; this.elapsedTime.PropertyChanged += ElapsedTime_PropertyChanged; this.originalTime.PropertyChanged += OriginalTime_PropertyChanged; }
private TaskViewModel InternalAddTask(String name, ColorInfo colorInfo, TimeInfoViewModel timeInfo) { //Add it var task = new TaskViewModel(name, colorInfo, timeInfo); tasks.Add(task); task.OriginalTime.PropertyChanged += task_OriginalTime_PropertyChanged; return(task); }
public SetupViewModel(Conductor <Screen> .Collection.OneActive parent, TimeInfoViewModel totalTime, List <TaskViewModel> tasks, IWindowManager windowManager) { this.parent = parent; this.windowManager = windowManager; this.totalTimeInfo.TotalSeconds = totalTime.TotalSeconds; foreach (var task in tasks) { this.tasks.Add(task); } DoSetup(); }
private void AddTimeToTask(TaskViewModel task, TimeInfoViewModel time) { if (task == null) { return; } if (time.IsZeroTime) { return; } //TaskViewModel theNextTask = null; //while((theNextTask = FindNextTask(task)) != null && time.IsPositiveTime) //{ // int delta = Math.Min(time.TotalSeconds, theNextTask.TimeLeft.TotalSeconds); // task.OriginalTime.TotalSeconds += //} }
public AddTimeViewModel(TaskViewModel task, TimeInfoViewModel timeLeft) { this.task = task; this.timeLeft = timeLeft; timeLeft.PropertyChanged += TimeLeft_PropertyChanged; }