public void Remove(ViewContainer item)
 {
     _views.Remove(item);
 }
 public void Register(ViewContainer item)
 {
     _views.AddOrUpdate(item);
 }
Example #3
0
        public void OpenFile(FileInfo file)
        {
            var scheduler = _objectProvider.Get<ISchedulerProvider>();

            scheduler.Background.Schedule(() =>
            {
                //Handle errors

                //2. resolve TailViewModel
                var factory = _objectProvider.Get<FileTailerViewModelFactory>();
                var viewModel = factory.Create(file);

                //3. Display it
                var newItem = new ViewContainer(file.Name, viewModel);
                //do the work on the ui thread
                scheduler.MainThread.Schedule(() =>
                {
                    Views.Add(newItem);
                    Selected = newItem;
                });
            });
        }
        private void OpenFile(FileInfo file)
        {
            _schedulerProvider.Background.Schedule(() =>
            {
                try
                {
                    _logger.Info($"Attempting to open '{file.FullName}'");

                    RecentFiles.Add(file);

                    //1. resolve TailViewModel
                    var factory = _objectProvider.Get<FileTailerViewModelFactory>();
                    var viewModel = factory.Create(file);

                    //2. Display it
                    var newItem = new ViewContainer(new FileHeader(file), viewModel);
                    
                    _windowsController.Register(newItem);

                    _logger.Info($"Objects for '{file.FullName}' has been created.");
                    //do the work on the ui thread
                    _schedulerProvider.MainThread.Schedule(() =>
                    {
                        
                        Views.Add(newItem);
                        _logger.Info($"Opened '{file.FullName}'");
                        Selected = newItem;
                    });
                }
                catch (Exception ex)
                {
                    //TODO: Create a failed to load view
                    _logger.Error(ex, $"There was a problem opening '{file.FullName}'");
                }
            });
        }
Example #5
0
        public void OpenFile(FileInfo file)
        {
            //2. resolve TailViewModel
            var factory = _objectProvider.Get<FileTailerViewModelFactory>();
            var viewModel = factory.Create(file);

            //3. Display it
            var newItem = new ViewContainer(file.Name, viewModel);
            Views.Add(newItem);
            Selected = newItem;
        }