Exemple #1
0
 public void RemoveTaskViewModel(ITaskViewModel taskViewModel)
 {
     if (taskViewModels.Contains(taskViewModel))
     {
         taskViewModels.Remove(taskViewModel);
     }
 }
Exemple #2
0
 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;
        }
Exemple #5
0
        private void DeleteTask(ITaskViewModel deleteItem)
        {
            Tasks.Remove(deleteItem);
            _taskList.Remove(deleteItem.Task);

            SaveToXml();
        }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        public void OnItemResumed(ITaskViewModel taskViewModel)
        {
            if (playlistController.CurrentItem == null)
            {
                return;
            }

            playlistController.CurrentItem.IsPlaying = true;
        }
Exemple #9
0
        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);
        }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
        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;
        }
Exemple #14
0
 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>();
 }
Exemple #16
0
 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);
            }
        }
Exemple #19
0
        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;
        }
Exemple #21
0
        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();
        }
Exemple #22
0
 public void TestInit()
 {
     _taskService       = Mock.Create <ITaskService>();
     _navigationService = Mock.Create <INavigationService>();
     _ITaskViewModel    = new TaskViewModel(_taskService, _navigationService);
 }
Exemple #23
0
 private void TaskAdded(ITaskViewModel taskVm)
 {
     Task.AddChild(taskVm.Task);
 }
Exemple #24
0
 private static void ResetFields(ITaskViewModel trust)
 {
     trust.Fields.ForEach(f => f.ResetErrorsAndWarnings());
 }
Exemple #25
0
 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);
 }
Exemple #29
0
 public async Task ConfirmCreationAsync(ITaskViewModel task)
 {
     var taskModel = ModelFactory.CreateTaskModel(task);
     await Persistance.InsertAsync(taskModel);
 }
Exemple #30
0
 public void CancelCreation(ITaskViewModel task)
 {
     _tasks.Remove(task);
 }
Exemple #31
0
 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);
 }
Exemple #34
0
 private void TaskAdded(ITaskViewModel taskVm)
 {
     Job.AddTask(taskVm.Task);
 }
Exemple #35
0
 public async Task DeleteAsync(ITaskViewModel task)
 {
     _tasks.Remove(task);
     await Persistance.DeleteAsync(ModelFactory.CreateTaskModel(task));
 }