Example #1
0
 public BlogReaderViewModel(Controllers.IBlogReaderController mainController)
 {
     // Asigna el manager de blogs y el controlador de vistas
     BlogManager     = new Application.BlogReaderManager();
     ViewsController = mainController;
     // Asigna los objetos
     ConfigurationViewModel = new Configuration.ConfigurationViewModel(this);
     TreeBlogs           = new Blogs.TreeBlogs.TreeBlogsViewModel(this);
     BlogDownloadProcess = new Controllers.Process.BlogDownloadProcess(this);
 }
        /// <summary>
        ///		Inicializa las propiedades
        /// </summary>
        private void InitProperties()
        {
            MenuGroupViewModel menuGroup;

            // Inicializa los comandos
            OpenOpmlCommand  = new BaseCommand("Abrir archivo OPML", parameter => ExecuteAction(nameof(OpenOpmlCommand), parameter));
            NewFolderCommand = new BaseCommand("Nueva carpeta",
                                               parameter => ExecuteAction(nameof(NewFolderCommand), parameter),
                                               parameter => CanExecuteAction(nameof(NewFolderCommand), parameter))
                               .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode));
            NewBlogCommand = new BaseCommand("Nuevo blog",
                                             parameter => ExecuteAction(nameof(NewBlogCommand), parameter),
                                             parameter => CanExecuteAction(nameof(NewBlogCommand), parameter))
                             .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode));
            DownloadCommand = new BaseCommand("Descargar",
                                              parameter => ExecuteAction(nameof(DownloadCommand), parameter),
                                              parameter => CanExecuteAction(nameof(DownloadCommand), parameter))
                              .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode));
            SeeNewsCommand = new BaseCommand("Ver noticias",
                                             parameter => ExecuteAction(nameof(SeeNewsCommand), parameter),
                                             parameter => CanExecuteAction(nameof(SeeNewsCommand), parameter))
                             .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode));
            DeleteCommand.AddListener(this, nameof(TreeBlogsViewModel.SelectedNode));
            // Añade los menús de la ventana principal
            menuGroup = MenuCompositionData.Menus.Add("Nuevo", MenuGroupViewModel.TargetMenuType.MainMenu,
                                                      MenuGroupViewModel.TargetMainMenuItemType.FileOpenItems);
            menuGroup.MenuItems.Add("Archivo OPML", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewBlog),
                                    OpenOpmlCommand);
            menuGroup = MenuCompositionData.Menus.Add("Nuevo", MenuGroupViewModel.TargetMenuType.MainMenu,
                                                      MenuGroupViewModel.TargetMainMenuItemType.FileNewItems);
            menuGroup.MenuItems.Add("Nueva carpeta", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewFolder),
                                    NewFolderCommand);
            menuGroup.MenuItems.Add("Nuevo blog", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewBlog),
                                    NewBlogCommand);
            // Inicializa el árbol
            Tree = new TreeBlogsViewModel(Folder);
        }