public void RemoveTaskViewModel(ITaskViewModel taskViewModel) { if (taskViewModels.Contains(taskViewModel)) { taskViewModels.Remove(taskViewModel); } }
private void InsertWithHeader(int index, ITaskViewModel newTask) { MainLayout.Children.Insert(index, new TaskView(newTask)); MainLayout.Children.Insert(index, new Label { Text = DateToTextConverter.Convert(newTask.ScheduleDate), FontSize = 13, TextColor = ((App)App.Current).ColorPrimary }); }
private void TaskStarted(ITaskViewModel taskViewModel) { try { if (taskViewModel == null) return; if (tabMap.ContainsKey(taskViewModel.Id)) return; var catalogViewModel = taskViewModel as CatalogMediaTaskViewModel; if (catalogViewModel != null) { Catalog(catalogViewModel); return; } var searchViewModel = taskViewModel as SearchTaskViewModel; if (searchViewModel != null) { Search(searchViewModel); return; } } catch (Exception ex) { logger.Error(" TaskResultView.TaskStarted", ex); } }
private void OnItemPaused(ITaskViewModel taskViewModel) { if (playlistController.CurrentItem == null) return; playlistController.CurrentItem.IsPaused = true; }
private void DeleteTask(ITaskViewModel deleteItem) { Tasks.Remove(deleteItem); _taskList.Remove(deleteItem.Task); SaveToXml(); }
private void TaskStarted(ITaskViewModel taskViewModel) { try { if (taskViewModel == null) { return; } if (tabMap.ContainsKey(taskViewModel.Id)) { return; } var catalogViewModel = taskViewModel as CatalogMediaTaskViewModel; if (catalogViewModel != null) { Catalog(catalogViewModel); return; } var searchViewModel = taskViewModel as SearchTaskViewModel; if (searchViewModel != null) { Search(searchViewModel); return; } } catch (Exception ex) { logger.Error(" TaskResultView.TaskStarted", ex); } }
private void AddViewModel(ITaskViewModel taskViewModel, TabItem tabItem) { try { if (tabMap.ContainsKey(taskViewModel.Id)) { throw new InvalidOperationException("There is already a tab for this task. name=" + taskViewModel.Name + " description=" + taskViewModel.Description); } taskViewModel.AddStartedCallback(x => TaskStarted(x)); var taskResultViewModel = new TaskResultViewModel(taskViewModel, tabItem); tabItem.DataContext = taskResultViewModel; taskResultViewModel.AddClosedCallback(x => CloseTab(x)); tabMap.Add(taskViewModel.Id, taskResultViewModel); var existing = taskController.Tasks.Where(x => x.Id == taskViewModel.Id).FirstOrDefault(); if (existing == null) { taskController.AddTaskViewModel(taskViewModel); } } catch (Exception ex) { logger.Error(" TaskResultView.AddViewModel", ex); } }
public void OnItemResumed(ITaskViewModel taskViewModel) { if (playlistController.CurrentItem == null) { return; } playlistController.CurrentItem.IsPlaying = true; }
private void OnItemPaused(ITaskViewModel taskViewModel) { if (playlistController.CurrentItem == null) { return; } playlistController.CurrentItem.IsPaused = true; }
public TaskResultViewModel(ITaskViewModel taskViewModel, TabItem tabItem) { if (taskViewModel == null) throw new ArgumentNullException("taskViewModel"); if (tabItem == null) throw new ArgumentNullException("tabItem"); this.taskViewModel = taskViewModel; this.tabItem = tabItem; taskViewModel.AddCancelCallback(x => IsClosed = true); }
private void RemoveItemWithHeader(int index, ITaskViewModel task) { // Remove item from the main layout MainLayout.Children.RemoveAt(index); // If there is a header above and there is a header or no items below, remove the above header if (MainLayout.Children.Count > 0 && MainLayout.Children[index - 1] is Label && (MainLayout.Children.Count == index || MainLayout.Children[index] is Label)) { MainLayout.Children.RemoveAt(index - 1); } }
private void EditTask(ITaskViewModel taskViewModel) { var temp = Tasks.First(f => f.Equals(taskViewModel)); Tasks.Remove(taskViewModel); _taskList.Remove(taskViewModel.Task); AddTaskVM.TaskDescription = temp.TaskDescription; AddTaskVM.TaskName = temp.TaskName; AddTaskVM.HasBeenEdited = true; ShowAddTask(); }
public TaskHeader(ILogger logger, ITaskViewModel taskViewModel) { if (logger == null) throw new ArgumentNullException("logger"); if (taskViewModel == null) throw new ArgumentNullException("taskViewModel"); InitializeComponent(); this.logger = logger; this.taskViewModel = taskViewModel; this.DataContext = taskViewModel; }
public ITaskModel CreateTaskModel(ITaskViewModel task) { return(new TaskModel { CreateTime = task.CreateTime, Deadline = task.Deadline, Description = task.Description, Done = task.Done, Id = task.Id, Title = task.Title, Reminder = task.Reminder, ScheduleDate = task.ScheduleDate }); }
public void InitializeTest() { _persistance = Mock.Create <IPersistance>(); _dateTime = Mock.Create <IDateTimeProvider>(); _navigationService = Mock.Create <INavigationService>(); _modelFactory = Mock.Create <IModelFactory>(); _taskService = new TaskService { Persistance = _persistance, DateTimeProvider = _dateTime, ModelFactory = _modelFactory, Navigation = _navigationService, }; _habitViewModel = Mock.Create <ITaskViewModel>(); }
protected override void RemoveItem(ITaskViewModel oldItem) { MyLogger.WriteStartMethod(); // Find the view of the task for (int i = 0; i < MainLayout.Children.Count; i++) { if (MainLayout.Children[i] is TaskView taskView && taskView.IsVisible && taskView.ViewModel == oldItem) { // Remove item on this index. // If there is a title above, then if there is anothere title below or no items, remove the title above RemoveItemWithHeader(i, oldItem); } } MyLogger.WriteEndMethod(); }
public TaskResultViewModel(ITaskViewModel taskViewModel, TabItem tabItem) { if (taskViewModel == null) { throw new ArgumentNullException("taskViewModel"); } if (tabItem == null) { throw new ArgumentNullException("tabItem"); } this.taskViewModel = taskViewModel; this.tabItem = tabItem; taskViewModel.AddCancelCallback(x => IsClosed = true); }
private void OnItemStarted(ITaskViewModel task) { try { ClearExistingItemStatus(); var playing = playlistController.Items.Where(x => x.Id == task.CurrentItem.Id).FirstOrDefault(); if (playing != null) { playing.IsPlaying = true; } } catch (Exception ex) { logger.Error(" PlaylistView.OnItemStarted", ex); } }
private void OnItemStarted(ITaskViewModel task) { try { ClearExistingItemStatus(); var playing = playlistController.Items.Where(x => x.Id == task.CurrentItem.Id).FirstOrDefault(); if (playing != null) { playing.IsPlaying = true; } } catch (Exception ex) { logger.Error(" PlaylistView.OnItemStarted", ex); } }
public TaskHeader(ILogger logger, ITaskViewModel taskViewModel) { if (logger == null) { throw new ArgumentNullException("logger"); } if (taskViewModel == null) { throw new ArgumentNullException("taskViewModel"); } InitializeComponent(); this.logger = logger; this.taskViewModel = taskViewModel; this.DataContext = taskViewModel; }
protected override void AddItem(ITaskViewModel newTask) { MyLogger.WriteStartMethod(); if (newTask.ScheduleDate == null) { return; } var scheduleDate = newTask.ScheduleDate.Value.Date; // Find the right place int i = 0; for (; i < MainLayout.Children.Count; i++) { // Skip all the elements with lower date or which are headers if (!(MainLayout.Children[i] is TaskView taskView) || taskView.ViewModel.ScheduleDate.Value.Date < scheduleDate) { continue; } if (taskView.ViewModel.ScheduleDate.Value.Date == scheduleDate) { // Iterate to the end of the section of TaskViews with the same ScheduleDate do { i++; } while (i < MainLayout.Children.Count && MainLayout.Children[i] is TaskView); // Add at the end MainLayout.Children.Insert(i, new TaskView(newTask)); return; } i--; break; } // Add it one index above InsertWithHeader(i, newTask); MyLogger.WriteEndMethod(); }
public void TestInit() { _taskService = Mock.Create <ITaskService>(); _navigationService = Mock.Create <INavigationService>(); _ITaskViewModel = new TaskViewModel(_taskService, _navigationService); }
private void TaskAdded(ITaskViewModel taskVm) { Task.AddChild(taskVm.Task); }
private static void ResetFields(ITaskViewModel trust) { trust.Fields.ForEach(f => f.ResetErrorsAndWarnings()); }
public void AddTaskViewModel(ITaskViewModel taskViewModel) { taskViewModel.AddCancelCallback(x => RemoveTaskViewModel(x)); taskViewModels.Add(taskViewModel); }
public TaskView(ITaskViewModel viewModel) { InitializeComponent(); viewModel.View = this; }
public void OnItemResumed(ITaskViewModel taskViewModel) { if (playlistController.CurrentItem == null) return; playlistController.CurrentItem.IsPlaying = true; }
public void RemoveTaskViewModel(ITaskViewModel taskViewModel) { if (taskViewModels.Contains(taskViewModel)) taskViewModels.Remove(taskViewModel); }
public async Task ConfirmCreationAsync(ITaskViewModel task) { var taskModel = ModelFactory.CreateTaskModel(task); await Persistance.InsertAsync(taskModel); }
public void CancelCreation(ITaskViewModel task) { _tasks.Remove(task); }
public async Task UpdateAsync(ITaskViewModel task) { await Persistance.UpdateAsync(ModelFactory.CreateTaskModel(task)); }
private void AddViewModel(ITaskViewModel taskViewModel, TabItem tabItem) { try { if (tabMap.ContainsKey(taskViewModel.Id)) throw new InvalidOperationException("There is already a tab for this task. name=" + taskViewModel.Name + " description=" + taskViewModel.Description); taskViewModel.AddStartedCallback(x => TaskStarted(x)); var taskResultViewModel = new TaskResultViewModel(taskViewModel, tabItem); tabItem.DataContext = taskResultViewModel; taskResultViewModel.AddClosedCallback(x => CloseTab(x)); tabMap.Add(taskViewModel.Id, taskResultViewModel); var existing = taskController.Tasks.Where(x => x.Id == taskViewModel.Id).FirstOrDefault(); if (existing == null) { taskController.AddTaskViewModel(taskViewModel); } } catch (Exception ex) { logger.Error(" TaskResultView.AddViewModel", ex); } }
public void AddTaskViewModel(ITaskViewModel taskViewModel) { taskViewModel.AddCancelCallback(x => RemoveTaskViewModel(x)); taskViewModels.Add(taskViewModel); }
private void TaskAdded(ITaskViewModel taskVm) { Job.AddTask(taskVm.Task); }
public async Task DeleteAsync(ITaskViewModel task) { _tasks.Remove(task); await Persistance.DeleteAsync(ModelFactory.CreateTaskModel(task)); }