/// <summary> /// Constructs a new player task object using the data from the given task /// </summary> /// <param name="other">The other task to construct from</param> public PlayerTask(PlayerTask other) { this.ID = other.ID; this.Name = other.Name; this.Description = other.Description; this.IsCompletable = other.IsCompletable; this.IsCompleted = other.IsCompleted; this.AutoComplete = other.AutoComplete; this.IsDailyReset = other.IsDailyReset; this.Location = other.Location; this.MapID = other.MapID; this.IconUri = other.IconUri; this.WaypointCode = other.WaypointCode; }
/// <summary> /// Default constructor /// </summary> /// <param name="task">The task that this view model wraps</param> /// <param name="zoneService">Service that provides zone information, such as map name</param> public PlayerTaskViewModel(PlayerTask task, IZoneService zoneService, IPlayerTasksController controller, CompositionContainer container) { this.Task = task; this.zoneService = zoneService; this.controller = controller; this.container = container; this.Task.PropertyChanged += (o, e) => { if (e.PropertyName == "MapID") this.RefreshMapName(); }; System.Threading.Tasks.Task.Factory.StartNew(this.RefreshMapName); this.CopyWaypointCommand = new DelegateCommand(this.CopyWaypoint); this.EditCommand = new DelegateCommand(this.Edit); this.DeleteCommand = new DelegateCommand(this.Delete); this.UserData.PropertyChanged += (o, e) => this.RefreshVisibility(); this.Task.PropertyChanged += (o, e) => this.RefreshVisibility(); this.RefreshVisibility(); }
/// <summary> /// Constructs a new player task object using the data from the given task /// </summary> /// <param name="other">The other task to construct from</param> public PlayerTask(PlayerTask other) { this.ID = other.ID; this.Name = other.Name; this.Description = other.Description; this.IsCompletable = other.IsCompletable; this.IsAccountCompleted = other.IsAccountCompleted; this.IsCompletedPerCharacter = other.IsCompletedPerCharacter; this.AutoComplete = other.AutoComplete; this.IsDailyReset = other.IsDailyReset; this.Location = other.Location; this.MapID = other.MapID; this.IconUri = other.IconUri; this.WaypointCode = other.WaypointCode; foreach (var character in other.CharacterCompletions.Keys) { this.CharacterCompletions.Add(character, other.CharacterCompletions[character]); } }
public PlayerTaskViewModel GetPlayerTaskViewModel(PlayerTask task) { return new PlayerTaskViewModel(task, this.zoneService, this.tasksController, this.container); }
/// <summary> /// Default constructor /// </summary> /// <param name="task">The task that this view model wraps</param> /// <param name="zoneService">Service that provides zone information, such as map name</param> public PlayerTaskViewModel(PlayerTask task, IZoneService zoneService, IPlayerTasksController controller, CompositionContainer container) { this.Task = task; this.zoneService = zoneService; this.controller = controller; this.container = container; this.currentCharacterName = string.Empty; this.Task.PropertyChanged += (o, e) => { if (e.PropertyName == "MapID") { this.RefreshMapName(); } else if (e.PropertyName.Contains("Location")) { this.OnPropertyChanged(() => this.HasZoneLocation); this.OnPropertyChanged(() => this.HasContinentLocation); } }; if (this.Task.MapID != -1) System.Threading.Tasks.Task.Factory.StartNew(this.RefreshMapName); this.CopyWaypointCommand = new DelegateCommand(this.CopyWaypoint); this.EditCommand = new DelegateCommand(this.Edit); this.DeleteCommand = new DelegateCommand(this.Delete); this.UserData.PropertyChanged += (o, e) => this.RefreshVisibility(); this.Task.PropertyChanged += (o, e) => this.RefreshVisibility(); this.RefreshVisibility(); }
/// <summary> /// Deletes a task from the collection of player tasks /// </summary> /// <param name="task">The task to delete</param> public void DeleteTask(PlayerTask task) { // Lock so the refresh thread doesn't use the collection while we are modifying it lock (this.refreshLock) { Threading.InvokeOnUI(() => { var taskToRemove = this.PlayerTasks.FirstOrDefault(t => t.Task == task); if (taskToRemove != null) { this.PlayerTasks.Remove(taskToRemove); this.UserData.Tasks.Remove(task); } }); } }
/// <summary> /// Adds a new task to the collection of player tasks /// </summary> /// <param name="task">The task to add</param> public void AddOrUpdateTask(PlayerTask task) { // 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 == task.ID); if (existingTask == null) { this.UserData.Tasks.Add(task); this.PlayerTasks.Add(new PlayerTaskViewModel(task, zoneService, this, this.container)); } else { existingTask.Task.Name = task.Name; existingTask.Task.Description = task.Description; existingTask.Task.IsCompletable = task.IsCompletable; existingTask.Task.IsCompleted = task.IsCompleted; existingTask.Task.IsDailyReset = task.IsDailyReset; existingTask.Task.AutoComplete = task.AutoComplete; existingTask.Task.Location = task.Location; existingTask.Task.MapID = task.MapID; existingTask.Task.IconUri = task.IconUri; existingTask.Task.WaypointCode = task.WaypointCode; } }); } }