示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterViewModel"/> class.
 /// </summary>
 /// <param name="character">The <see cref="Character"/> for which to create this viewmodel.</param>
 /// <param name="getIdForModelFunc">A function returning the Id for the provided model.</param>
 public CharacterViewModel(RedYarn.Character character, Func <object, Guid> getIdForModelFunc = null)
 {
     if (getIdForModelFunc != null)
     {
         Id = getIdForModelFunc(character);
     }
     Name        = character.Name;
     Description = character.Description;
     Aliases.AddRange(character.Aliases.Select(alias => new AliasViewModel(alias, getIdForModelFunc)).ToList());
 }
示例#2
0
        /// <summary>
        /// Update the provided model with the values in this viewmodel.
        /// </summary>
        /// <param name="model">The model to update.</param>
        public void UpdateModel(RedYarn.Character model)
        {
            // Only set the properties we can set, so don't set shadow properties like the Id.
            model.Name        = Name;
            model.Description = Description;

            // Aliases are specific to this character, so we can safely delete all aliases attached to the model and add the ones in this viewmodel.
            model.Aliases.Clear();
            model.Aliases.AddRange(Aliases.Select(aliasViewModel => new Alias()
            {
                Name = aliasViewModel.Name
            }));

            model.Authors.Clear();
            model.Authors.AddRange(Authors.Select(authorViewModel => new Author()
            {
                Name = authorViewModel.Name
            }));
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterViewModel"/> class.
 /// </summary>
 /// <param name="character">The <see cref="Character"/> for which to create this viewmodel.</param>
 /// <param name="characterNode">The <see cref="CharacterNode"/> with which to create this viewmodel.</param>
 /// <param name="getIdForModelFunc">A function returning the Id for the provided model.</param>
 public CharacterViewModel(RedYarn.Character character, Database.CharacterNode characterNode, Func <object, Guid> getIdForModelFunc = null)
     : this(character, characterNode.XPosition, characterNode.YPosition, getIdForModelFunc)
 {
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterViewModel"/> class.
 /// </summary>
 /// <param name="character">The <see cref="Character"/> for which to create this viewmodel.</param>
 /// <param name="xPosition">The X position of the viewmodel in the diagram.</param>
 /// <param name="yPosition">The Y position of the viewmodel in the diagram.</param>
 /// <param name="getIdForModelFunc">A function returning the Id for the provided model.</param>
 public CharacterViewModel(RedYarn.Character character, float xPosition, float yPosition, Func <object, Guid> getIdForModelFunc = null)
     : this(character, getIdForModelFunc)
 {
     XPosition = xPosition;
     YPosition = yPosition;
 }