public TaskCategoryViewModel(PlayerTaskViewModel initialTask, IPlayerTasksController playerTasksController, TasksUserData userData) { this.playerTasks = new ObservableCollection<PlayerTaskViewModel>(); this.PlayerTasks = new AutoRefreshCollectionViewSource(); this.PlayerTasks.Source = this.playerTasks; this.playerTasks.Add(initialTask); this.CategoryName = initialTask.Category; this.userData = userData; this.playerTasksController = playerTasksController; this.SortBy = this.userData.TaskTrackerSortProperty; this.EditCategoryCommand = new DelegateCommand(this.Edit); this.DeleteAllCommand = new DelegateCommand(this.DeleteAll); }
public bool Contains(PlayerTaskViewModel playerTask) { return this.playerTasks.Contains(playerTask); }
public void Remove(PlayerTaskViewModel playerTask) { if (this.playerTasks.Contains(playerTask)) this.playerTasks.Remove(playerTask); }
public void Add(PlayerTaskViewModel playerTask) { this.playerTasks.Add(playerTask); }
public TasksController(IZoneService zoneService, IPlayerService playerService, TasksUserData userData, CompositionContainer container) { logger.Debug("Initializing Player Tasks Controller"); this.zoneService = zoneService; this.playerService = playerService; this.container = container; this.isStopped = false; this.CharacterName = this.playerService.CharacterName; this.UserData = userData; this.PlayerTasks = new ObservableCollection<PlayerTaskViewModel>(); // Initialize all loaded tasks logger.Info("Initializing all loaded player tasks"); foreach (var task in this.UserData.Tasks) { var taskVm = new PlayerTaskViewModel(task, zoneService, this, this.container); taskVm.OnNewCharacterDetected(this.CharacterName); this.PlayerTasks.Add(taskVm); } // Initialize refresh timers this.refreshTimer = new Timer(this.Refresh); this.RefreshInterval = 125; this.CurrentMapID = -1; logger.Info("Player Tasks Controller initialized"); }
/// <summary> /// Adds a new task to the collection of player tasks /// </summary> /// <param name="task">The task and viewmodel to add</param> public void AddOrUpdateTask(PlayerTaskViewModel taskViewModel) { // Lock so the refresh thread doesn't use the collection while we are modifying it lock (this.refreshLock) { Threading.InvokeOnUI(() => { var existingTask = this.PlayerTasks.FirstOrDefault(t => t.Task.ID == taskViewModel.Task.ID); if (existingTask == null) { this.UserData.Tasks.Add(taskViewModel.Task); this.PlayerTasks.Add(taskViewModel); } else { existingTask.Task.Name = taskViewModel.Task.Name; existingTask.Task.Description = taskViewModel.Task.Description; existingTask.Task.IsCompletable = taskViewModel.Task.IsCompletable; existingTask.Task.IsAccountCompleted = taskViewModel.Task.IsAccountCompleted; existingTask.Task.IsCompletedPerCharacter = taskViewModel.Task.IsCompletedPerCharacter; existingTask.Task.IsDailyReset = taskViewModel.Task.IsDailyReset; existingTask.Task.AutoComplete = taskViewModel.Task.AutoComplete; existingTask.Task.Location = taskViewModel.Task.Location; existingTask.Task.MapID = taskViewModel.Task.MapID; existingTask.Task.IconUri = taskViewModel.Task.IconUri; existingTask.Task.WaypointCode = taskViewModel.Task.WaypointCode; foreach (var character in taskViewModel.Task.CharacterCompletions.Keys) { if (!existingTask.Task.CharacterCompletions.ContainsKey(character)) existingTask.Task.CharacterCompletions.Add(character, taskViewModel.Task.CharacterCompletions[character]); else existingTask.Task.CharacterCompletions[character] = taskViewModel.Task.CharacterCompletions[character]; } } }); } }
/// <summary> /// Constructs a new Player Marker view model /// </summary> /// <param name="taskViewModel">View model of the marker's corresponding task</param> public PlayerMarkerViewModel(PlayerTaskViewModel taskViewModel, IZoneService zoneService, IPlayerService playerService) { this.taskViewModel = taskViewModel; this.zoneService = zoneService; this.playerService = playerService; this.taskViewModel.PropertyChanged += TaskViewModel_PropertyChanged; this.taskViewModel.Task.PropertyChanged += Task_PropertyChanged; }