/// <summary> /// Creates a new instance with movie <paramref name="key"/> and collection of <paramref name="movies"/>. /// </summary> /// <param name="key">A key of the movie where relations belong.</param> /// <param name="movies">A collection of all movies to validate keys.</param> public RelatedMovieObservableCollection(IKey key, MovieCollection movies) { Ensure.Condition.NotEmptyKey(key); Ensure.NotNull(movies, "movies"); this.key = key; this.movies = movies; }
/// <summary> /// Creates a new instance. /// </summary> public Library() { ConfigurationDefinition = new ModelDefinition( "LibraryConfiguration", new List <IFieldDefinition>() { new FieldDefinition( nameof(LibraryConfiguration.Name), typeof(string), (MetadataCollection) new MetadataCollection() .AddLabel("Name") .AddIsAutoFocus(true) ), new FieldDefinition( nameof(LibraryConfiguration.FilePath), typeof(string), (MetadataCollection) new MetadataCollection() .AddLabel("File Path") .Add("IsPersistent", false) ), }, new MetadataCollection() ); MovieDefinition = new ModelDefinition( "Movie", new List <IFieldDefinition>() { new FieldDefinition( nameof(Movie.Name), typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 0) .AddGridColumnSpan(2) .AddLabel("Name") .AddIsAutoFocus(true) .Add("Main.Left", true) ), new FieldDefinition( "OriginalName", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 1) .AddGridColumnSpan(2) .AddLabel("Original Name") .Add("Additional.Left", true) ), new FieldDefinition( "Storage", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 2) .AddGridColumnSpan(2) .AddLabel("Storage") .Add("Main.Right", true) ), new FieldDefinition( "Year", typeof(int?), (MetadataCollection) new MetadataCollection() .AddGrid(0, 3) .AddLabel("Year") .Add("Additional.Right", true) ), new FieldDefinition( "Country", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(1, 3) .AddLabel("Country") .Add("Additional.Right", true) ), new FieldDefinition( "Category", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 4) .AddGridColumnSpan(2) .AddLabel("Category") ), new FieldDefinition( nameof(Movie.RelatedMovieKeys), typeof(IEnumerable <IKey>), (MetadataCollection) new MetadataCollection() .AddGrid(0, 5) .AddGridColumnSpan(2) .AddLabel("Related Movies") .Add("IsPersistent", false) .Add("IsSearchable", false) .Add("IsSortable", false) ), new FieldDefinition( "Language", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 6) .AddLabel("Language") .Add("IsSortable", false) .Add("IsSortable", false) ), new FieldDefinition( "Actors", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(1, 6) .AddLabel("Actors") .Add("IsSortable", false) .Add("Additional.Left", true) ), new FieldDefinition( "Description", typeof(string), (MetadataCollection) new MetadataCollection() .AddGrid(0, 7) .AddGridColumnSpan(2) .AddLabel("Description") .Add("IsSortable", false) .Add("IsXmlElementContent", true) ), new FieldDefinition( nameof(Movie.Added), typeof(DateTime), (MetadataCollection) new MetadataCollection() .AddGrid(1, 8) .AddGridColumnSpan(2) .AddLabel("Added") .AddIsReadOnly(true) .Add("IsSearchable", false) ) }, new MetadataCollection() ); Configuration = new LibraryConfiguration(this); Configuration.PropertyChanged += OnConfigurationChanged; Movies = new MovieCollection(); Movies.CollectionChanged += OnMoviesChanged; }
public void Remove(MovieCollection collection, Movie model) { collection.Remove(model); Has = true; Added?.Invoke(); }