Exemple #1
0
        //public DocumentationLink(DocumentationLinkType type, string url, string label)
        //{
        //    Label = label ?? type.ToString();
        //    Url = url;
        //    Type = type;
        //    //Open = new AnotherCommandImplementation(Execute);
        //}



        public DocumentationLink(DocumentationLinkType type, string url, string label)
        {
            Label = label ?? type.ToString();
            Url   = url;
            Type  = type;
            Open  = new AnotherCommandImplementation(Execute);
        }
        public TreesViewModel()
        {
            MovieCategories = new ObservableCollection <MovieCategory>
            {
                new MovieCategory("Action",
                                  new Movie("Predator", "John McTiernan"),
                                  new Movie("Alien", "Ridley Scott"),
                                  new Movie("Prometheus", "Ridley Scott")),
                new MovieCategory("Comedy",
                                  new Movie("EuroTrip", "Jeff Schaffer"),
                                  new Movie("EuroTrip", "Jeff Schaffer")
                                  )
            };

            AddCommand = new AnotherCommandImplementation(
                _ =>
            {
                if (!MovieCategories.Any())
                {
                    MovieCategories.Add(new MovieCategory(GenerateString(15)));
                }
                else
                {
                    var index = new Random().Next(0, MovieCategories.Count);

                    MovieCategories[index].Movies.Add(
                        new Movie(GenerateString(15), GenerateString(20)));
                }
            });

            RemoveSelectedItemCommand = new AnotherCommandImplementation(
                _ =>
            {
                var movieCategory = SelectedItem as MovieCategory;
                if (movieCategory != null)
                {
                    MovieCategories.Remove(movieCategory);
                }
                else
                {
                    var movie = SelectedItem as Movie;
                    if (movie == null)
                    {
                        return;
                    }
                    MovieCategories.FirstOrDefault(v => v.Movies.Contains(movie))?.Movies.Remove(movie);
                }
            },
                _ => SelectedItem != null);
        }