Ejemplo n.º 1
0
        public MainViewModel()
        {
            // Initialize MEF
            var catalog = new DirectoryCatalog("Tricks");
            _container = new CompositionContainer(catalog);

            _container.ComposeParts(this);

            var tricks = new List<TrickViewModel>();

            foreach (var trick in _tricks)
            {
                var Trick = new TrickViewModel
                {
                    Name = trick.Metadata.Name,
                    Description = trick.Metadata.Description
                };

                tricks.Add(Trick);
            }

            Tabs = new ObservableCollection<TabItem>
            {
                new TabItem
                {
                    Header = "All Tricks",
                    IsSelected = true,
                    Content = new TricksTab(tricks)
                }
            };

            Messenger.Default.Register<LoadMessage>(this, (m) => OnLoadTab(m.Trick));
        }
Ejemplo n.º 2
0
        public MainViewModel()
        {
            // Initialize MEF
            var catalog = new DirectoryCatalog("Tricks");

            _container = new CompositionContainer(catalog);

            _container.ComposeParts(this);

            var tricks = new List <TrickViewModel>();

            foreach (var trick in _tricks)
            {
                var Trick = new TrickViewModel
                {
                    Name        = trick.Metadata.Name,
                    Description = trick.Metadata.Description
                };

                tricks.Add(Trick);
            }

            Tabs = new ObservableCollection <TabItem>
            {
                new TabItem
                {
                    Header     = "All Tricks",
                    IsSelected = true,
                    Content    = new TricksTab(tricks)
                }
            };

            Messenger.Default.Register <LoadMessage>(this, (m) => OnLoadTab(m.Trick));
        }
Ejemplo n.º 3
0
        public void OnLoadTab(TrickViewModel selectedTrick)
        {
            var trick = _tricks
                .Where(t => t.Metadata.Name == selectedTrick.Name)
                .FirstOrDefault();

            var tab = new TabItem();

            tab.Header = selectedTrick.Name;
            tab.IsSelected = true;

            tab.Content = trick.CreateExport().Value;

            AddTab(tab);
        }
Ejemplo n.º 4
0
        public void OnLoadTab(TrickViewModel selectedTrick)
        {
            var trick = _tricks
                        .Where(t => t.Metadata.Name == selectedTrick.Name)
                        .FirstOrDefault();

            var tab = new TabItem();

            tab.Header     = selectedTrick.Name;
            tab.IsSelected = true;

            tab.Content = trick.CreateExport().Value;

            AddTab(tab);
        }