View model for a player marker (player task)
Inheritance: BindableBase, IHasMapLocation
コード例 #1
0
        private void PlayerMarkers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // When a player marker is added, check to see if we need to reset the template for that marker
            // (for example, when the user added the marker by drag/dropping it onto the map)
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (PlayerMarkerViewModel newItem in e.NewItems)
                {
                    var template = this.MarkerTemplates.FirstOrDefault(m => m == newItem);
                    if (template != null)
                    {
                        // This marker came from a template

                        // Replace the template
                        var idx = this.MarkerTemplates.IndexOf(template);
                        this.MarkerTemplates.Remove(template);
                        var task = this.playerTaskFactory.GetPlayerTask();
                        task.IconUri = newItem.Icon;
                        var vm          = this.playerTaskFactory.GetPlayerTaskViewModel(task);
                        var newTemplate = new PlayerMarkerViewModel(vm, this.userData, this.currentContinentId, this.zoneService, this.playerService);
                        this.MarkerTemplates.Insert(idx, newTemplate);

                        // Then add the corresponding task
                        this.tasksController.AddOrUpdateTask(newItem.TaskViewModel);
                    }
                }
            }
        }
コード例 #2
0
        private void PlayerMarkers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // When a player marker is added, check to see if we need to reset the template for that marker
            // (for example, when the user added the marker by drag/dropping it onto the map)
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (PlayerMarkerViewModel newItem in e.NewItems)
                {
                    var template = this.MarkerTemplates.FirstOrDefault(m => m == newItem);
                    if (template != null)
                    {
                        // This marker came from a template

                        // Replace the template
                        var idx = this.MarkerTemplates.IndexOf(template);
                        this.MarkerTemplates.Remove(template);
                        var task = this.playerTaskFactory.GetPlayerTask();
                        task.IconUri = newItem.Icon;
                        var vm = this.playerTaskFactory.GetPlayerTaskViewModel(task);
                        var newTemplate = new PlayerMarkerViewModel(vm, this.zoneService, this.playerService);
                        this.MarkerTemplates.Insert(idx, newTemplate);

                        // Then add the corresponding task
                        this.tasksController.AddOrUpdateTask(newItem.TaskViewModel);
                    }
                }
            }
        }