Example #1
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="dataManager">Der DataManager, mit dessen Daten das View Model befüllt wird.</param>
        internal AboutPageViewModel(DataManager dataManager)
        {
            this.dataManager = dataManager;

            this.UserFirstName = this.dataManager.User.FirstName;
            this.UserLastName = this.dataManager.User.Name;
            this.PushNotficationsEnabled = this.dataManager.GetNotificationsEnabled();
        }
Example #2
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="dataManager">Der DataManager, mit dessen Daten das View Model befüllt wird.</param>
        internal FinishedTasksViewModel(DataManager dataManager)
        {
            this.dataManager = dataManager;

            this.dataManager.Tasks.CollectionChanged += DataManagerTasks_CollectionChanged;
            this.dataManager.PropertyChanged += dataManager_PropertyChanged;

            foreach (Task task in this.dataManager.Tasks)
                task.PropertyChanged += new PropertyChangedEventHandler(task_PropertyChanged);
            DataManagerTasks_CollectionChanged(this, null);
        }
Example #3
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="dataManager">Daten für das ViewModel.</param>
        internal MainPageViewModel(DataManager dataManager)
        {
            this.dataManager = dataManager;

            //foreach (Task task in this.dataManager.Tasks)
            //    task.PropertyChanged += new PropertyChangedEventHandler(task_PropertyChanged);
            DataManagerTasks_CollectionChanged(null, null);

            this.dataManager.TaskAssignedToChanged += DataManagerTasks_CollectionChanged;
            this.dataManager.Tasks.CollectionChanged += DataManagerTasks_CollectionChanged;
            this.dataManager.PropertyChanged += dataManager_PropertyChanged;
            dataManager.User.PropertyChanged += User_PropertyChanged;
        }
Example #4
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="task">Der Task als Datenquelle des ViewModels.</param>
        internal TaskPreviewViewModel(DataManager dataManager, Task task)
        {
            this.task = task;
            this.dataManager = dataManager;

            LoadCreatorIfNotUser();

            this.dataManager.PropertyChanged += dataManager_PropertyChanged;
            this.task.PropertyChanged += AllPropertiesChanged;
        }
Example #5
0
        /// <summary>
        /// Lädt den korrekten DataManager.
        /// </summary>
        private void LoadDataManager()
        { 
            try
            {
                App.DataManager = Data.DataManager.TryLoad();

                //Im Fall des Ersten Starts:
                if (App.DataManager == null)
                    App.DataManager = Data.DataManager.CreateNew();
            }
            catch
            {
                MessageBox.Show(Localization.Strings.AppErrorLoading);
                App.DataManager = Data.DataManager.CreateNew();
            }
        }
Example #6
0
        internal static TaskPageViewModel CreateTask(DataManager dataManager, string taskCopyId)
        {
            var viewModel = CreateTask(dataManager);
            Task copyTask = dataManager.Tasks.First(p => p.TaskId == taskCopyId);

            viewModel.Description = copyTask.Description;
            viewModel.isDueTimeSet = copyTask.IsDueTimeSet;
            viewModel.DueTime = copyTask.DueTime;

            return viewModel;
        }
Example #7
0
 internal static TaskPageViewModel CreateTask(DataManager dataManager)
 {
     var query = new Data.Queries.CreateTaskQuery();
     dataManager.AddQuery(query);
     return new TaskPageViewModel(dataManager, dataManager.Tasks.First(p => p.TaskId == query.TaskId)) { isFirstEdit = true };
 }
Example #8
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="dataManager">Daten für das ViewModel.</param>
        /// <param name="task">Aktueller Task für das ViewModel.</param>
        internal TaskPageViewModel(DataManager dataManager, Task task)
        {
            this.dataManager = dataManager;
            this.taskId = task.TaskId;
            this.isFromUser = task.IsFromUser(dataManager.User);

            //IsDone und Score
            this.IsDone = this.dataManager.GetTaskIsDone(task, out this.oldScore);
            this.IsDoneChangeable = !this.IsDone;
            this.Score = this.oldScore;

            //Sonstige Eigenschaften
            this.Description = task.Description;
            this.dueDate = task.DueDate;
            this.oldDueDate = task.DueDate;
            this.IsDueTimeSet = task.IsDueTimeSet;
            this.DueTime = task.DueTime;

            //TaskAssigned To
            LoadTaskAssignedTo(task);

            //Reminder
            var reminder = ScheduledActionService.Find(this.GetReminderName()) as Reminder;
            if (reminder != null)
            {
                this.IsReminderSet = true;
                this.ReminderDateTime = reminder.BeginTime;
                ScheduledActionService.Remove(this.GetReminderName());
            }
            else if (this.isDueTimeSet)
                this.ReminderDateTime = this.DueDate.Date + this.DueTime.TimeOfDay;
            else
                this.ReminderDateTime = this.DueDate.Date + DateTime.Now.TimeOfDay;

            //Events
            task.PropertyChanged += AllPropertiesChanged;
            dataManager.PropertyChanged += dataManager_PropertyChanged;
        }