/// <summary> /// Constructor of the class /// </summary> /// <param name="taskModel"></param> /// <param name="targetList"></param> /// <param name="dataConnector"></param> /// <param name="mainPage"></param> /// <param name="state"></param> public DefaultTaskViewModel(ITaskModel taskModel, ObservableCollection<ITaskViewModel> targetList, IDataConnector dataConnector, MainPage mainPage, TaskState state) { TaskModel = taskModel; _targetList = targetList; _dataConnector = dataConnector; ItemVisualWidth = mainPage.ActualWidth; // Commands Break = new ViewModelCommand() { Command = new RelayCommand(r => BreakTask()), Text = "Break" }; PunchOut = new ViewModelCommand { Command = new RelayCommand(r => FinishTask()), Text = "Finished", ImagePath = @"Images/finish.png" }; DeleteFromList = new ViewModelCommand { Command = new RelayCommand( r => { if (targetList != null && targetList.Contains(this)) { targetList.Remove(this); _dataConnector.DeleteTask(taskModel.Id); } }), Text = "Delete", ImagePath = "Images/delete.png" }; // Timer Init _timer = new DispatcherTimer(); _timer.Tick += timer_Tick; _timer.Interval = TimeSpan.FromSeconds(1); _timer.Start(); // Setstate State = state; _initLoad = false; }